Hi I am sure this is a common issue but I looked it up on google and nobody seem to have a real good fix about this. Or maybe there is something I don't understand something... ? here is my problem:
I try to use the glassfish appserv-rt.jar client library to enable my webapp to call EJBs remotely in my tomcat 6 context. With a simple test application. I can successfully call an EJB from a servlet. I place my jars (javaee.jar and appserver-rt and the necessary dependencies) in my WEB-INF/lib/ direcectory. I build the InitialContext by hand and set the properties that will serve to initialise the jndi jndi name resolver. This is my base app I used test that everything is working. In another app. With more complex libraries (ex: Seam, richfaces, etc). I have a classloading issue. If I put the appserver-rt.jar and javaee.jar in my web-app /WEB-INF/lib directory the web-app won't deploy because the classloading is not done in the right order so when it's some on my seam componenent instantiate and I try to fill some cache from the EJBs, the call fails because the appserver-rt-jar as not yet been loader (or I guess, is not loaded by the class loader because of the javax.* java.* constraint of the servlet specification?) I tried to move things arround... and put the appserver-rt.jar in CATALINA_BASE/lib forlder If I put the javaee.jar in CATALINA_BASE/lib/ there is no problem. If I put the appserver-rt file into the CATALINA_BASE/lib/ folder the server does not start because of a NamingException. I am not sure I understand why there seems to be a problem/conlict between the ressourcefactory in the appserver-rt.jar and tomcat's resourcefactory. Anyone know how to get arround this problem in a clean way? I am seen solutions like renaming the appserver-rt.jar to zappserver-rt.jar so it is loader last... but this is not a clean solution. Here is the output of my tomcat server when I start it with the appserver-rt.jar in the CATALINA_BASE/LIB foder: E:\dev\runtime\apache-tomcat-6.0.18\bin>catalina.bat run Using CATALINA_BASE: E:\dev\runtime\apache-tomcat-6.0.18 Using CATALINA_HOME: E:\dev\runtime\apache-tomcat-6.0.18 Using CATALINA_TMPDIR: E:\dev\runtime\apache-tomcat-6.0.18\temp Using JRE_HOME: E:\dev\lib\jdk1.6.0_13 Apr 24, 2009 12:04:12 PM org.apache.catalina.core.AprLifecycleListener init INFO: Cannot find message associated with key aprListener.aprInit Apr 24, 2009 12:04:12 PM org.apache.coyote.http11.Http11Protocol init INFO: PWC4652: Initializing null on port 8080 Apr 24, 2009 12:04:12 PM org.apache.catalina.startup.Catalina load INFO: Initialization processed in 1187 ms Apr 24, 2009 12:04:13 PM org.apache.catalina.mbeans.GlobalResourcesLifecycleListener createMBeans SEVERE: Exception processing Global JNDI Resources javax.naming.NamingException: Cannot create resource instance at org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:156) at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304) at org.apache.naming.NamingContext.lookup(NamingContext.java:814) at org.apache.naming.NamingContext.lookup(NamingContext.java:174) at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.createMBeans(GlobalResourcesLifecycleListener.java:179) at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.createMBeans(GlobalResourcesLifecycleListener.java:149) at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.lifecycleEvent(GlobalResourcesLifecycleListener.java:121) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:143) at org.apache.catalina.core.StandardServer.start(StandardServer.java:2310) at org.apache.catalina.startup.Catalina.start(Catalina.java:575) 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.start(Bootstrap.java:288) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413) Apr 24, 2009 12:04:13 PM org.apache.catalina.core.StandardService start INFO: PWC1377: Starting service Catalina javax.naming.NamingException: Cannot create resource instance at org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:156) at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304) at org.apache.naming.NamingContext.lookup(NamingContext.java:814) at org.apache.naming.NamingContext.lookup(NamingContext.java:174) at org.apache.catalina.realm.UserDatabaseRealm.start(UserDatabaseRealm.java:279) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1226) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:533) at org.apache.catalina.core.StandardService.start(StandardService.java:515) at org.apache.catalina.core.StandardServer.start(StandardServer.java:2317) at org.apache.catalina.startup.Catalina.start(Catalina.java:575) 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.start(Bootstrap.java:288) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413) UserDatabaseRealm[Catalina]: PWC2101: Exception looking up UserDatabase under key UserDatabase javax.naming.NamingException: Cannot create resource instance at org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:156) at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304) at org.apache.naming.NamingContext.lookup(NamingContext.java:814) at org.apache.naming.NamingContext.lookup(NamingContext.java:174) at org.apache.catalina.realm.UserDatabaseRealm.start(UserDatabaseRealm.java:279) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1226) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:533) at org.apache.catalina.core.StandardService.start(StandardService.java:515) at org.apache.catalina.core.StandardServer.start(StandardServer.java:2317) at org.apache.catalina.startup.Catalina.start(Catalina.java:575) 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.start(Bootstrap.java:288) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413) Apr 24, 2009 12:04:13 PM org.apache.catalina.startup.Catalina start SEVERE: Catalina.start: LifecycleException: PWC2102: No UserDatabase component found under key UserDatabase at org.apache.catalina.realm.UserDatabaseRealm.start(UserDatabaseRealm.java:286) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1226) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:533) at org.apache.catalina.core.StandardService.start(StandardService.java:515) at org.apache.catalina.core.StandardServer.start(StandardServer.java:2317) at org.apache.catalina.startup.Catalina.start(Catalina.java:575) 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.start(Bootstrap.java:288) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413) Apr 24, 2009 12:04:13 PM org.apache.catalina.startup.Catalina start