tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Blevins <david.blev...@visi.com>
Subject Re: persistence.xml in a Jar in Tomcat Common classloader (ERROR : PersistenceUnit already deployed)
Date Thu, 16 Oct 2008 07:55:41 GMT
Hi Maxime,

It should be possible to put the service.jar in the Tomcat lib/  
directory without a persistence.xml in it and then include that  
persistence xml in your webapp.  You should be able to include a <jar- 
file> element in the unit declaration that points to the C:/tomcat6/ 
lib/service.jar so all the entities will be discovered without having  
to explicitly list them via the <class> element.  You'd have to  
include the same persistence.xml in each webapp that wanted to reuse  
the classes in service.jar.

Not entirely sure though if that's really what you're after.  We don't  
currently have any support for "global" persistence units.  Meaning  
say a persistence unit declared outside of an ear at server level and  
available to all ears/apps deployed.  It might be something we could  
add if that's really what you're after.

-David


On Oct 16, 2008, at 12:25 AM, Maxime Thieu wrote:

>
> Hello everybody,
>
> I am developping ejb-jar module (let's call it service.jar) which  
> contains
> EJB, Entity, Service and persistence.xml (in META-INF).
>
> I am developping webapp module (let's call it test.war) which contains
> Servlets who are calling some Service in service.jar (using  
> entityManager to
> persist some data).
>
> I am trying to make this work under Tomcat 6.xx using OpenEJB 3.1  
> (build:
> 20081009-03:31).
>
> A.jar is present in the common classloader of Tomcat (in lib  
> directory) in
> order to be visible by all webapps.
> In this case, during Tomcat starting, OpenEJB show the following  
> Error :
> "ERROR - Unable to deploy collapsed ear in war /test: Exception:  
> Creating
> application failed: C:\tomcat6\webapps\test: PersistenceUnit already
> deployed: /C:/tomcat6/lib/service.jar"
>
>
> If service.jar is present in the WEB-INF/lib of test.war, everything  
> works
> well, but this is not I want (classes of service.jar should be  
> visible by
> all webapps).
>
>
> Do I miss something? Is this possible with OpenEJB?
>
> I make several try and search but I do not find how to solve this  
> (and I am
> a beginner in OpenEJB).
>
> Thanks in advance, any help would be appreciated.
>
> Maxime
>
> here is the complete StackTrace of the Error in the log :
>
> ERROR - Unable to deploy collapsed ear in war /test: Exception:  
> Creating
> application failed: C:\tomcat6\webapps\test: PersistenceUnit already
> deployed: /C:/tomcat6/lib/service.jar
> org.apache.openejb.OpenEJBException: Creating application failed:
> C:\tomcat6\webapps\test: PersistenceUnit already deployed:
> /C:/tomcat6/lib/service.jar
>     at
> org 
> .apache 
> .openejb 
> .assembler.classic.Assembler.createApplication(Assembler.java:650)
>     at
> org 
> .apache 
> .openejb 
> .assembler.classic.Assembler.createApplication(Assembler.java:447)
>     at
> org 
> .apache 
> .openejb 
> .tomcat.catalina.TomcatWebAppBuilder.start(TomcatWebAppBuilder.java: 
> 241)
>     at
> org 
> .apache 
> .openejb 
> .tomcat 
> .catalina.TomcatLoader.processRunningApplications(TomcatLoader.java: 
> 228)
>     at
> org 
> .apache.openejb.tomcat.catalina.TomcatLoader.init(TomcatLoader.java: 
> 139)
>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>     at
> sun 
> .reflect 
> .NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
>     at
> sun 
> .reflect 
> .DelegatingMethodAccessorImpl 
> .invoke(DelegatingMethodAccessorImpl.java:43)
>     at java.lang.reflect.Method.invoke(Method.java:615)
>     at org.apache.openejb.loader.Embedder.init(Embedder.java:75)
>     at  
> org.apache.openejb.tomcat.loader.TomcatHook.hook(TomcatHook.java:98)
>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>     at
> sun 
> .reflect 
> .NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
>     at
> sun 
> .reflect 
> .DelegatingMethodAccessorImpl 
> .invoke(DelegatingMethodAccessorImpl.java:43)
>     at java.lang.reflect.Method.invoke(Method.java:615)
>     at
> org 
> .apache 
> .openejb.tomcat.loader.TomcatEmbedder.embed(TomcatEmbedder.java:74)
>     at
> org 
> .apache.openejb.tomcat.loader.LoaderServlet.init(LoaderServlet.java: 
> 44)
>     at
> org 
> .apache 
> .catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1161)
>     at
> org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java: 
> 981)
>     at
> org 
> .apache 
> .catalina.core.StandardContext.loadOnStartup(StandardContext.java: 
> 4055)
>     at
> org.apache.catalina.core.StandardContext.start(StandardContext.java: 
> 4361)
>     at
> org 
> .apache 
> .catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
>     at
> org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java: 
> 771)
>     at
> org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
>     at
> org 
> .apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java: 
> 626)
>     at
> org 
> .apache 
> .catalina.startup.HostConfig.deployDescriptors(HostConfig.java:553)
>     at
> org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:488)
>     at org.apache.catalina.startup.HostConfig.start(HostConfig.java: 
> 1138)
>     at
> org 
> .apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java: 
> 311)
>     at
> org 
> .apache 
> .catalina 
> .util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
>     at
> org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
>     at org.apache.catalina.core.StandardHost.start(StandardHost.java: 
> 719)
>     at
> org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
>     at
> org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
>     at
> org.apache.catalina.core.StandardService.start(StandardService.java: 
> 516)
>     at
> org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
>     at org.apache.catalina.startup.Catalina.start(Catalina.java:576)
>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>     at
> sun 
> .reflect 
> .NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
>     at
> sun 
> .reflect 
> .DelegatingMethodAccessorImpl 
> .invoke(DelegatingMethodAccessorImpl.java:43)
>     at java.lang.reflect.Method.invoke(Method.java:615)
>     at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
>     at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
> Caused by:
> org.apache.openejb.OpenEJBException: PersistenceUnit already deployed:
> /C:/tomcat6/lib/service.jar
>     at
> org 
> .apache 
> .openejb 
> .assembler.classic.Assembler.createApplication(Assembler.java:490)
>     ... 42 more
>
> -- 
> View this message in context: http://www.nabble.com/persistence.xml-in-a-Jar-in-Tomcat-Common-classloader-%28ERROR-%3A-PersistenceUnit-already-deployed%29-tp20008468p20008468.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>
>


Mime
View raw message