Search code examples
javawebspherederby

embedded derby starts with J2C error


I create a datasource as

    @DataSourceDefinition
(
  name="java:app/env/myDataSource",
  className="org.apache.derby.jdbc.EmbeddedXADataSource40",
  databaseName="myDB",
  properties=
  {
    // Vendor properties for Derby Embedded JDBC driver:
    "createDatabase=create",
    "connectionAttributes=upgrade=true",

    // Custom properties for WebSphere Application Server:
    "connectionTimeout=60",
    "dataStoreHelperClass=com.ibm.websphere.rsadapter.DerbyDataStoreHelper",
    "validateNewConnection=true",
    "validateNewConnectionRetryCount=5"
  },
  serverName=""
)

Then I put it into the startup code.

@Startup
@Singleton
public class StartUp {

    @Resource(lookup = "java:app/env/myDataSource")
    private javax.sql.DataSource dataSource;
...

When websphere server starts up, I got the below error and more

[12/12/16 15:05:28:136 EST] 0000003b J2CXAResource W J2CA0061W: Error creating XA Connection and Resource java.lang.Exception: Parameter xaResInfo lacks an RA wrapper and an RA wrapper could not be resolved using RA key. at com.ibm.ejs.j2c.J2CXAResourceFactory$1.run(J2CXAResourceFactory.java:264) at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:118) at com.ibm.ejs.j2c.J2CXAResourceFactory.getXAResource(J2CXAResourceFactory.java:199) at com.ibm.ws.Transaction.JTA.XARecoveryData.getXARminst(XARecoveryData.java:492) at com.ibm.ws.Transaction.JTA.XARecoveryData.recover(XARecoveryData.java:658) at com.ibm.tx.jta.impl.PartnerLogTable.recover(PartnerLogTable.java:432) at com.ibm.tx.jta.impl.RecoveryManager.resync(RecoveryManager.java:1543) at com.ibm.tx.jta.impl.RecoveryManager.performResync(RecoveryManager.java:2276) at com.ibm.ws.tx.jta.RecoveryManager.performResync(RecoveryManager.java:119) at com.ibm.tx.jta.impl.RecoveryManager.run(RecoveryManager.java:2229) at java.lang.Thread.run(Thread.java:798)

Any thought? I think the embedded derby doesn't need the J2C.


Solution

  • As aguibert said, the server is attempting to perform XA recovery, which is failing. Here's a link with info about recovering from a failed recovery:

    https://www.ibm.com/developerworks/community/blogs/aimsupport/entry/recovering_from_failed_transaction_recovery_websphere_application_server?lang=en

    In cases where the logged transaction is of no concern, you can simply stop the application server, navigate to the tranlog and partnerlog directories and delete the contents (log1 & log2) of both directories, then restart the app server.

    For reference, unless changed by your configuration, the default directories are typically located in the paths:

    C:WebSphere\AppServer\profiles\AppSrv01\tranlog\MyNode01Cell\MyNode02\server1\transaction\partnerlog\

    C:WebSphere\AppServer\profiles\AppSrv01\tranlog\MyNode01Cell\MyNode02\server1\transaction\tranlog\