tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From MrVisser <>
Subject Instantiating a class in shared/lib
Date Mon, 14 Jul 2008 20:23:59 GMT


I'm using spring, and invoking the application context to load on a static

I am triggering this static method in the init() method of a servlet.

I have the following 3 classes:

public interface api.A
public class static.A  //which has static method load(String implClass)
public class spring.B implements A //which contains all spring dependencies

to keep my API from having spring dependencies, I do something like
following method inside my servlet:

A a = static.A.load("spring.B"); //actually, the impl string is in a
properties file

Now, if api.A and static.A are in A.jar, and spring.B is in spring.jar,
Class.forName("example.spring.B") does not work (the thread just dies with
no exception thrown or anything). However,
Thread.currentThread().getContextClassLoader().loadClass("spring.B") will
successfully get a reference to the Class object. It just cannot be

If I move spring.B into A.jar with the rest, everything works fine. This
holds true with any combination of these JAR files being in common/lib or

What am I missing? Please let me know if you need more information.


View this message in context:
Sent from the Tomcat - User mailing list archive at

To start a new topic, e-mail:
To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message