0

我正在使用 TomEE 部署一个 EAR 文件,其中包含一个 EJB JAR 和一个 WAR。

我想使用默认提供程序添加实体。我在 tomee.xml 中创建了一个资源来使用 MySQL DB。然后我想使用实体管理器,所以我尝试在 EJB JAR META-INF 目录中创建以下 persistence.xml:

<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">

        <persistence-unit name="MyProjectDataBase" transaction-type="JTA">
                <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
                <jta-data-source>MyProjectDS</jta-data-source>
                <non-jta-data-source>MyProjectDSUnmanaged</non-jta-data-source>
                <properties>
                        <property name="openjpa.jdbc.DBDictionary" value="mysql" />
                        <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema" />
                </properties>
        </persistence-unit>

</persistence>

MyProject & MyProjectUnmanaged 是我在 tomee.xml 中创建的资源 Id。

添加此 persistence.xml 后,我在 catalina.out 中收到以下异常,并且未部署我的应用程序:

SEVERE: Application could not be deployed:  /Users/avitale/Development/apache-tomee-jaxrs-1.5.0/apps/projecteam-ear
org.apache.openejb.OpenEJBException: Creating application failed: /Users/avitale/Development/apache-tomee-jaxrs-1.5.0/apps/projecteam-ear: loader (instance of  org/apache/catalina/loader/StandardClassLoader): attempted  duplicate class definition for name: "org/apache/openejb/cdi/CdiPlugin"
        at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:940)
        at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:532)
        at org.apache.openejb.assembler.classic.Assembler.buildContainerSystem(Assembler.java:433)
        at org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:341)
        at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:144)
        at org.apache.openejb.OpenEJB.init(OpenEJB.java:290)
        at org.apache.tomee.catalina.TomcatLoader.initialize(TomcatLoader.java:231)
        at org.apache.tomee.catalina.TomcatLoader.init(TomcatLoader.java:131)
        at org.apache.tomee.catalina.ServerListener.lifecycleEvent(ServerListener.java:113)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
        at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
        at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:401)
        at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:110)
        at org.apache.catalina.startup.Catalina.load(Catalina.java:633)
        at org.apache.catalina.startup.Catalina.load(Catalina.java:658)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:281)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:450)
Caused by: java.lang.LinkageError: loader (instance of  org/apache/catalina/loader/StandardClassLoader): attempted  duplicate class definition for name: "org/apache/openejb/cdi/CdiPlugin"
        at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
        at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:295)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
        at org.apache.openejb.cdi.OptimizedLoaderService.loadWebBeansPlugins(OptimizedLoaderService.java:70)
        at org.apache.openejb.cdi.OptimizedLoaderService.load(OptimizedLoaderService.java:53)
        at org.apache.openejb.cdi.OptimizedLoaderService.load(OptimizedLoaderService.java:47)
        at org.apache.webbeans.plugins.PluginLoader.startUp(PluginLoader.java:75)
        at org.apache.openejb.cdi.OpenEJBLifecycle.startApplication(OpenEJBLifecycle.java:159)
        at org.apache.openejb.cdi.ThreadSingletonServiceImpl.initialize(ThreadSingletonServiceImpl.java:150)
        at org.apache.openejb.cdi.CdiBuilder.build(CdiBuilder.java:44)
        at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:794)
        ... 20 more

一旦我删除了 persistence.xml,那么应用程序就成功部署了。请帮助我,因为我不明白如何进行:(

提前致谢。

4

1 回答 1

2

如果您可以指定您实际使用的版本,将会很有帮助。

此外,您是否检查过您不会在您的 EAR 文件(我的意思是 lib/ 或 WEB-INF/lib)中提供 TomEE 或任何相关的依赖项?

供您参考,TomEE 1.5.1 将很快发布,其中包含一些围绕 EAR 部署的修复。

于 2012-12-06T08:47:38.360 回答