commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Essl Christian <ju...@esslchristian.de>
Subject [HiveMind] Having problem with tomcat.
Date Wed, 10 Sep 2003 13:13:19 GMT
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?




Mime
View raw message