Return-Path: Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 14086 invoked from network); 10 Sep 2003 13:12:40 -0000 Received: from unknown (HELO server22.mirsky.biz) (213.131.236.71) by daedalus.apache.org with SMTP; 10 Sep 2003 13:12:40 -0000 Received: from MEDION1 (simmu3-81-130.utaonline.at [62.218.81.130]) by server22.mirsky.biz (8.11.6/8.11.6/SuSE Linux 0.5) with ESMTP id h8ADCc631608 for ; Wed, 10 Sep 2003 15:12:39 +0200 Content-Type: text/plain; charset=iso-8859-15; format=flowed To: "commons-dev@jakarta.apache.org" Subject: [HiveMind] Having problem with tomcat. From: Essl Christian MIME-Version: 1.0 Date: Wed, 10 Sep 2003 15:13:19 +0200 Message-ID: User-Agent: Opera7.11/Win32 M2 build 2887 X-Spam-Status: No, hits=0.0 required=10.0 tests=USER_AGENT version=2.55 X-Spam-Checker-Version: SpamAssassin 2.55 (1.174.2.19-2003-05-19-exp) X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Tomcat throws an Exception when I try to get during Servlet init a simple Service implemented in the web-app. I have written a simple web-app, which consits of a TestServlet that loads in the init a simple TestService: public void init(ServletConfig arg0) throws ServletException { super.init(arg0); ClassResolver resolver = new DefaultClassResolver(); //alternatively //ClassResolver resolver = new DefaultClassResolver(this.getClass() .getClassLoader()); RegistryBuilder builder = new RegistryBuilder(); builder.processModules(resolver); Registry registry = builder.constructRegistry(Locale.getDefault()); service = (TestService) registry.getService("org.test.TestService", TestService.class); } The TestService has just one method public String getTestString() and the implementation just returns a static String. The Web-app is build with maven war. The servlet, the ServiceInterface (TestService) and the ServiceImplementation (TestServiceImpl) are are all in /WEB-INF/classes. (Alternatively I have also jared them up and put them in the lib dir). The hivemind.jar and all the runtime dependencies except of ant, xerces (which I see are only used for the ant tasks) and oro, saxon and log4j (which I read are only used for testing) are in the WEB-INF/lib dir. Now when the servlet is initialized throgh Tomcat (both 4.0.2 and 4.1.27) tomcat shows the following Exception: javax.servlet.ServletException: Servlet.init() for servlet test threw exception ..... (only catalina trace) Root-Cause: java.lang.NoClassDefFoundError: org/test/TestService at java.lang.ClassLoader.defineClass0(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:502) at java.lang.ClassLoader.defineClass(ClassLoader.java:431) at javassist.ClassPool$LocalClassLoader.loadClass(ClassPool.java:365) at javassist.ClassPool.writeAsClass(ClassPool.java:427) at org.apache.commons.hivemind.service.impl.ClassFabImpl.createClass(ClassFabImpl.java:217) at org.apache.commons.hivemind.impl.DeferredServiceExtensionPointImpl.createDeferredProxyClass(DeferredServiceExtensionPointImpl.java:190) at org.apache.commons.hivemind.impl.DeferredServiceExtensionPointImpl.createServiceProxyClass(DeferredServiceExtensionPointImpl.java:146) at org.apache.commons.hivemind.impl.DeferredServiceExtensionPointImpl.getServiceProxy(DeferredServiceExtensionPointImpl.java:130) at org.apache.commons.hivemind.impl.DeferredServiceExtensionPointImpl.getService(DeferredServiceExtensionPointImpl.java:117) at org.apache.commons.hivemind.impl.ServiceExtensionPointImpl.getService(ServiceExtensionPointImpl.java:317) at org.apache.commons.hivemind.impl.ModuleImpl.getService(ModuleImpl.java:158) at org.apache.commons.hivemind.impl.RegistryImpl.getService(RegistryImpl.java:125) at org.test.TestServlet.init(TestServlet.java:59) (... only catalina trace) To run the Servlet I've used the lates CVS build with maven. Originally I encountered the same problem in my Web-App. However the problem does not occur when I use jetty in my eclipse-project and run jetty (directly) within the same project as the web-app. A similar problem also occured when maven did the unit-tests on my project. In the unit tests everything (ServletContext, ServletRequest etc) where Mocks. Again the problem did not occur when I did the unit tests in Eclipse. This is obviously a ClassLoader thing. However I don't know do I have to change something in the init code or is there a bug in HiveMind or JavaAssist?