简体   繁体   English

Spring Boot JNDI CommonJ资源

[英]Spring Boot JNDI CommonJ resource

Trying to get WorkManagers working with CommonJ in a Spring Boot app, hosted in TomEE. 试图让托管在TomEE中的Spring Boot应用程序中的WorkManager与CommonJ一起使用。

Currently have the following configuration: 当前具有以下配置:

Tomcat context.xml 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 春季应用程序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. 我在Tomcat的lib目录中有从http://commonj.myfoo.de/install.shtml下载的CommonJ jar。

I feel like I'm getting pretty close but slightly puzzled by this exception. 我觉得我已经很接近了,但是对此异常感到有些困惑。

Any help would be much appreciated. 任何帮助将非常感激。

UPDATE UPDATE

If I remove the two CommonJ jars from TomEE lib folder, I get this exception 如果我从TomEE lib文件夹中删除两个CommonJ jar,则会出现此异常

Caused by: java.lang.ClassNotFoundException: commonj.work.WorkManager 引起原因:java.lang.ClassNotFoundException:commonj.work.WorkManager

Which is what I would expect. 这是我所期望的。

If I remove the factory property from the resource element I get: 如果从资源元素中删除factory属性,则会得到:

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] 由以下原因引起:org.springframework.jndi.TypeMismatchNamingException:在JNDI位置[java:comp / env / wm / default]可用的[class org.apache.openejb.core.ivm.naming.IvmContext]类型的对象不可分配给[ commonj.work.WorkManager]

Im encounter with same issue, when try to start my app locally in maven-jetty-plugin. 我尝试在maven-jetty-plugin中本地启动我的应用程序时遇到相同的问题。 M. Deinum comment was very helpful. M. Deinum的评论非常有帮助。 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. 如果您在Application Server的共享库和Web应用程序的WEB-INF / lib文件夹中都有lib jar,则会发生此错误,因为服务器使用一个jar创建资源(父类加载器),而应用程序使用self jar(子类加载器)并且它具有两个不同的类层次结构,因此FooWorkManager不能强制转换为WorkManager。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM