tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From MrVisser <mrvis...@gmail.com>
Subject Re: Instantiating a class in shared/lib
Date Mon, 14 Jul 2008 20:41:54 GMT

I just solved my problem. Unfortunately 4hrs after I encountered it :) It's
very silly.

For whoever may run into this:

I did not use "scope provided" in the Maven POM file in the servlet webapp,
therefore 'A.jar' in my example below was being deployed into the webapps
WEB-INF/lib and over-riding its duplicate in shared/lib.

I hate my life, but somewhat grateful. I'm pretty sure it's experiences like
these that accelerate people's understanding of the tomcat classloader :)

Thanks to anyone who read my problem.

PS: This is also the reason for my hair-pulling issue where my changes in
static.A were not persisting into tomcat when I deployed ;) Argh!

Regards,

Branden


MrVisser wrote:
> 
> Hello,
> 
> I'm using spring, and invoking the application context to load on a static
> method.
> 
> 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
> initialized.
> 
> 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
> shared/lib.
> 
> What am I missing? Please let me know if you need more information.
> 
> Thanks,
> 
> Branden
> 

-- 
View this message in context: http://www.nabble.com/Instantiating-a-class-in-shared-lib-tp18452107p18452310.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message