springwebsphere-8jcacommonj

How to get a JCA Workmanager on Websphere 8 for Springs WorkManagerTaskExecutor


We use an Websphere 8 Application Server and I want to use the servers workmanager in our webapplication. I am trying to get a reference to a jca workmanager javax.resource.spi.work.Workmanager to use it with Springs org.springframework.jca.work.WorkManagerTaskExecutor.

The resource-ref in the web.xml looks like this:

<resource-ref>
 <res-ref-name>workmanager/web</res-ref-name>
 <res-type>javax.resource.spi.work.WorkManager</res-type>
 <res-auth>Container</res-auth>
 <res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>

Using that configuration, i get the following exception:

Caused by: com.ibm.ws.asynchbeans.exception.AsynchBeanException: ASYN0064E: The value javax.resource.spi.work.WorkManager of the res-type resource reference element WorkManager is not right. Only the following values are allowed: com.ibm.websphere.asynchbeans.WorkManager, commonj.work.WorkManager.
at com.ibm.ws.asynchbeans.naming.WorkManagerFactory.validateWMResRef(WorkManagerFactory.java:379)
at com.ibm.ws.asynchbeans.naming.WorkManagerFactory.getObjectInstance(WorkManagerFactory.java:147)
at org.apache.aries.jndi.ObjectFactoryHelper$7.run(ObjectFactoryHelper.java:338)
at java.security.AccessController.doPrivileged(AccessController.java:362)
at org.apache.aries.jndi.Utils.doWithRestoredPrivileges(Utils.java:155)
at org.apache.aries.jndi.ObjectFactoryHelper.getObjectInstanceUsingObjectFactoryBuilders(ObjectFactoryHelper.java:336)
at org.apache.aries.jndi.ObjectFactoryHelper.doGetObjectInstance(ObjectFactoryHelper.java:136)
at org.apache.aries.jndi.ObjectFactoryHelper.access$000(ObjectFactoryHelper.java:60)
at org.apache.aries.jndi.ObjectFactoryHelper$1.run(ObjectFactoryHelper.java:98)
at java.security.AccessController.doPrivileged(AccessController.java:327)
at org.apache.aries.jndi.Utils.doPrivileged(Utils.java:146)
at org.apache.aries.jndi.ObjectFactoryHelper.getObjectInstance(ObjectFactoryHelper.java:96)
at org.apache.aries.jndi.OSGiObjectFactoryBuilder.getObjectInstance(OSGiObjectFactoryBuilder.java:57)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:349)
at com.ibm.ws.naming.util.Helpers.processSerializedObjectForLookupExt(Helpers.java:993)
... 89 more

It says here my resource-ref must be of the type com.ibm.websphere.asynchbeans.WorkManager or commonj.work.WorkManager. Neither of them extends from the JCA-Workmanager-Interface.

If I switch the resource type to commonj.work.WorkManager and use Springs org.springframework.scheduling.commonj.WorkManagerTaskExecutor in my application, everything works fine.

To get a JCA Workmanager working with Websphere, do I need to configure something special on server-side? I havent found any setting in the admin-console to switch the implementation. Websphere 8 supports Java EE 6, so it should be able to deal with JCA.


Solution

  • Why do you want to use JCA-specific WorkManagerTaskExecutor rather than the commonj one? The JCA WorkManager is only intended to be used by resource adapters, not referenced by arbitrary EE components, and the Spring documentation for the JCA-specific WorkManagerTaskExecutor is consistent with that:

    This is mainly intended for use within a JCA ResourceAdapter implementation

    Just use the commonj WorkManager and corresponding WorkManagerTaskExecutor.