WebLogic-Methode TransactionHelper getUserTransaction nicht verwenden

Diese Regel markiert die Verwendung der Methode weblogic.transaction.TransactionHelper getUserTransaction(). Die Implementierung dieser Methode muss für WebSphere Application Server migriert werden.

Lösung

Verwenden Sie anstelle der WebLogic-spezifischen Methode getUserTransaction() den folgenden Code.

public static UserTransaction getUserTransaction() {
UserTransaction txn = null;
try {
Properties params = getInitialContextProperties();
      javax.naming.InitialContext ctx = new javax.naming.InitialContext(params);
      txn = (UserTransaction) ctx.lookup("java:comp/UserTransaction");
} catch(Throwable t) {
t.printStackTrace();
}
return txn;

}

public static Properties getInitialContextProperties() {
Properties props = new Properties();

props.put(Context.INITIAL_CONTEXT_FACTORY, getInitialContextFactoryName());
props.put(Context.URL_PKG_PREFIXES, "com.ibm.ws.runtime:com.ibm.ws.naming");
props.put("org.omg.CORBA.ORBClass", "com.ibm.CORBA.iiop.ORB");
return props;
}

Weitere Informationen enthält der Artikel Globale Transaktionen für Network Deployment.