EJB JAR中的tomee persistence.xml META-INF崩溃了我的应用程序部署

时间:2012-11-10 15:55:24

标签: persistence.xml apache-tomee

我正在使用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&amp; MyProjectUnmanaged是我在tomee.xml中创建的资源。

一旦我添加了这个persistence.xml,我在catalina.out中得到以下异常并且我的app没有部署:

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后,应用程序已成功部署。 请帮助我,因为我不明白如何继续:(

提前致谢。

1 个答案:

答案 0 :(得分:2)

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

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

为了您的信息,TomEE 1.5.1将很快发布,并对EAR部署进行一些修复。