2
votes

Trying to get WorkManagers working with CommonJ in a Spring Boot app, hosted in TomEE.

Currently have the following configuration:

Tomcat context.xml

<Context>
  <Resource name="myWorkManager"
    auth="Container"
    type="commonj.work.WorkManager"
    factory="de.myfoo.commonj.work.FooWorkManagerFactory"
    maxThreads="5" />
  <ResourceLink
    name="myWorkManager"
    global="myWorkManager"
    type="commonj.work.WorkManager" />
</Context>

Spring app web.xml

<resource-ref>
    <res-ref-name>myWorkManager</res-ref-name>
    <res-type>commonj.work.WorkManager</res-type>
    <res-auth>Container</res-auth>
</resource-ref>

This is currently throwing the following exception when the app loads:

Caused by: org.springframework.jndi.TypeMismatchNamingException: Object of type [class de.myfoo.commonj.work.FooWorkManager] available at JNDI location [java:comp/env/myWorkManager] is not assignable to [commonj.work.WorkManager]
    at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:182)
    at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:95)
    at org.springframework.scheduling.commonj.WorkManagerTaskExecutor.afterPropertiesSet(WorkManagerTaskExecutor.java:110)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
    ... 53 more

I have the CommonJ jars downloaded from http://commonj.myfoo.de/install.shtml in my Tomcat lib directory.

I feel like I'm getting pretty close but slightly puzzled by this exception.

Any help would be much appreciated.

UPDATE

If I remove the two CommonJ jars from TomEE lib folder, I get this exception

Caused by: java.lang.ClassNotFoundException: commonj.work.WorkManager

Which is what I would expect.

If I remove the factory property from the resource element I get:

Caused by: org.springframework.jndi.TypeMismatchNamingException: Object of type [class org.apache.openejb.core.ivm.naming.IvmContext] available at JNDI location [java:comp/env/wm/default] is not assignable to [commonj.work.WorkManager]

1
Make sure you don't have the jars in your web application. - M. Deinum
Have updated based on your suggestion - timothyclifford
No you haven't... You shouldn't remove them from the tomcat lib but you should remove them from your applications lib directory i.e WEB-INF/lib. You also appear NOT to be using Tomcat but TomEE which is a bit of a different beast. - M. Deinum
Yes sorry, I am using TomEE, will update question - timothyclifford
I've also confirmed these jars are not in my application either - timothyclifford

1 Answers

1
votes

Im encounter with same issue, when try to start my app locally in maven-jetty-plugin. M. Deinum comment was very helpful. This error happens if you have lib jar in shared lib of your Application Server and in your WEB-INF/lib folder of web application, because server use one jar to create resource (parent classloader), but application use self jar(child classloader) and it two different classes hierarchy, so FooWorkManager cant be cast to WorkManager.