Hi Martin,

> 3)webapp (everything found in WEB-INF/lib and WEB-INF/classes)
>
> you are using system classloader to loaf WEB-INF/lib jar
> use the webapp classloader

So according to this, the servlet as well as the classes from
WEB-INF/lib are loaded with the same classloader?
What I did in the servlet was basically: this.getClass().forName("Notepad");

I've now changed the code to (where this refers to the Servlet):
ClassLoader loader = this.getClass().getClassLoader();
Class cls = loader.loadClass(className);

However loader in this case is null, any idea what is going on?

Thank you in advance, Clemens



>
> ClassLoader webinf_loader=AClassInWebINFLib.getClass().getClassLoader();
> boolean initialize=true;
> static Class<?> clazz= java.lang.Class.forName(YourClassName,
> initialize,
> webinf_loader)
>
>
> Martin
> ______________________________________________
> Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
>
> Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene
> Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte
> Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht
> dient lediglich dem Austausch von Informationen und entfaltet keine
> rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von
> E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
>
> Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le
> destinataire prévu, nous te demandons avec bonté que pour satisfaire
> informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie
> de ceci est interdite. Ce message sert à l'information seulement et n'aura
> pas n'importe quel effet légalement obligatoire. Étant donné que les email
> peuvent facilement être sujets à la manipulation, nous ne pouvons accepter
> aucune responsabilité pour le contenu fourni.
>
>
>
>
>> Date: Mon, 6 Jun 2011 23:47:25 +0200
>> Subject: Class.forName doesn't find classes located in WEB-INF/lib
>> From: linuxhi...@gmail.com
>> To: users@tomcat.apache.org
>>
>> Hi,
>>
>> I have a servlet which dynamically loads classes from jar-files
>> located in WEB-INF/lib/,
>> however tomcat somehow seems to ignore those jar-files.
>>
>> in WEB-INF/lib/Notepad.jar there is a class Notepad.class (without any
>> package),
>> however loading that class yields:
>>
>> Loading Application Class: Notepad
>> java.lang.ClassNotFoundException: Notepad
>> at java.lang.Class.forName0(Native Method)
>> at java.lang.Class.forName(Class.java:186)
>> at net.java.openjdk.cacio.servlet.AppStarter.doGet(Unknown Source)
>>
>>
>> Any idea what could be the problem here?
>> Does tomcat use some kind of security manager which is blocking
>> class-loading?
>>
>> Thank you in advance, Clemens
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
>> For additional commands, e-mail: users-h...@tomcat.apache.org
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to