Re: Non-servlet class cannot access jar file in ./WEB-INF/lib when a Servlet does
Hi, all classes of a webapp which do not come from tomcat server itself do share a common classloader which is an aggregation of the various classes in all WEB-INF/lib/*.jar and in WEB-INF/classes/**/*.class If you get a NoClassDefFoundException, that probably mean you asked some class in server classloader to load some other class (probably by reflection) which is located in WEB-INF/lib. That simply impossible to do because classloaders use a child to parent classloading delegation model, not a parent (server) to child (webapp). Regards David Delbecq Jose Maria Ramirez Martinez a écrit : >Hi, everybody > >I have the next problem: >A servlet calls a non-servlet class, and this non-servlet class imports >classes from a jar file, >but the classloader does not find the class from the jar file >(so when I call the servlet from an internet browser, I get a >NoClassDefFoundException) > >But if a servlet class imports the same classes from the jar, the class loader >does find them... >I've tried some ways to solve this problem, like: > a) unpacking the classes from the jar (this works, but I had the problem > that 2 different jars contained >a file with the same name stored in the same directory, so one would replace >the other, and the class fails) > b) I thought it would be a security problem so I ran tomcat with a > SecurityManager, but it didn't solve the >problem.. > >does somebody has any idea why this is happening??? >can somebody help me to solve this... thanks in advance > >Jose Maria > > >___ >$0 Web Hosting with up to 200MB web space, 1000 MB Transfer >10 Personalized POP and Web E-mail Accounts, and much more. >Signup at www.doteasy.com > > >- >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] > > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Non-servlet class cannot access jar file in ./WEB-INF/lib when a Servlet does
Jose, I have a similar servlet which initializes a singleton class to load the Tomcat resources for AXIS web service. The servlet is loaded at startup. This singleton class uses classes from a jar file located in WEB-INF/lib. MY servlet and singleton and other classes are in WEB-INF/classes. In production environment, servlet and all other classes are in jar under WEB-INF/lib and these classes use other classes in another jar in WEB-INF/lib. It works fine. Probably having two classes with same name is the problem, but how is that possible to have two classes with same name in the same package? If they are in two different packages, you need to refer that class with complete package structure, eg : package.className = new package.className(); -Sabitha Jose Maria Ramirez Martinez a écrit : >Hi, everybody > >I have the next problem: >A servlet calls a non-servlet class, and this non-servlet class imports classes from a jar file, >but the classloader does not find the class from the jar file >(so when I call the servlet from an internet browser, I get a NoClassDefFoundException) > >But if a servlet class imports the same classes from the jar, the class loader does find them... >I've tried some ways to solve this problem, like: > a) unpacking the classes from the jar (this works, but I had the problem that 2 different jars contained >a file with the same name stored in the same directory, so one would replace the other, and the class fails) > b) I thought it would be a security problem so I ran tomcat with a SecurityManager, but it didn't solve the >problem.. > >does somebody has any idea why this is happening??? >can somebody help me to solve this... thanks in advance > >Jose Maria > > >___ >$0 Web Hosting with up to 200MB web space, 1000 MB Transfer >10 Personalized POP and Web E-mail Accounts, and much more. >Signup at www.doteasy.com > > >- >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] > > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Non-servlet class cannot access jar file in ./WEB-INF/lib when a Servlet does
Hi, thanks a lot for your comments about the files with the same name... they are not classes ok, let me explain... I'm using the javax.mail package, which is in a jar, called mailapi.jar, and in order to use this package we also need the JavaBeans activation framework, packed in a jar, called activation.jar, so each one of this jars contain a file called SUN_MICR.RSA and SUN_MICR.SF (I don't know what they are for, but the files in one jar have different content than the files in the other jar) in the META-INF subdirectory, so when I unpack this jars, this files are replaced by the ones of the jar I unpack last, so when I run the servlet, the class that sends the email does not work, but when I call this email sender class from a servlet, there is no problem, this is the whole detailed situation, and I'm a bit confused... Thanks a lot for your time Jose Maria -- Original Message -- From: "Sabitha" <[EMAIL PROTECTED]> Reply-To: "Tomcat Users List" Date: Thu, 6 Oct 2005 10:54:30 -0400 >Jose, > >I have a similar servlet which initializes a singleton class to load the >Tomcat resources for AXIS web service. The servlet is loaded at startup. >This singleton class uses classes from a jar file located in WEB-INF/lib. MY >servlet and singleton and other classes are in WEB-INF/classes. > >In production environment, servlet and all other classes are in jar under >WEB-INF/lib and these classes use other classes in another jar in >WEB-INF/lib. It works fine. > >Probably having two classes with same name is the problem, but how is that >possible to have two classes with same name in the same package? If they >are in two different packages, you need to refer that class with complete >package structure, eg : package.className = new package.className(); > > >-Sabitha > > > >Jose Maria Ramirez Martinez a écrit : > >>Hi, everybody >> >>I have the next problem: >>A servlet calls a non-servlet class, and this non-servlet class imports >classes from a jar file, >>but the classloader does not find the class from the jar file >>(so when I call the servlet from an internet browser, I get a >NoClassDefFoundException) >> >>But if a servlet class imports the same classes from the jar, the class >loader does find them... >>I've tried some ways to solve this problem, like: >> a) unpacking the classes from the jar (this works, but I had the problem >that 2 different jars contained >>a file with the same name stored in the same directory, so one would >replace the other, and the class fails) >> b) I thought it would be a security problem so I ran tomcat with a >SecurityManager, but it didn't solve the >>problem.. >> >>does somebody has any idea why this is happening??? >>can somebody help me to solve this... thanks in advance >> >>Jose Maria >> >> >>___ >>$0 Web Hosting with up to 200MB web space, 1000 MB Transfer >>10 Personalized POP and Web E-mail Accounts, and much more. >>Signup at www.doteasy.com >> >> >>- >>To unsubscribe, e-mail: [EMAIL PROTECTED] >>For additional commands, e-mail: [EMAIL PROTECTED] >> >> >> > > >- >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] > > > >- >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] > > ___ $0 Web Hosting with up to 200MB web space, 1000 MB Transfer 10 Personalized POP and Web E-mail Accounts, and much more. Signup at www.doteasy.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]