Re: Classloading issue
Yu, John wrote: Wade, Thanks for sharing. When you say using package, you mean for resource files? One specific thing you didn't mention is where the calling class is located. In my case, it's a class from within a jar in "lib". That really made the difference. My conclusion so far is similar: when using "/", CL could make a big difference. Better stay away from it? Regards, John -Original Message- From: Wade Chandler [mailto:[EMAIL PROTECTED] Sent: Thursday, December 09, 2004 4:31 PM To: Tomcat Users List Subject: Re: Classloading issue Yu, John wrote: Hi, I'm using Struts plugin, however, I think the issue mostly related to Tomcat ClassLoading. I have a class (in a jar) under WEB-INF/lib, which loads properties from a file located under WEB-INF/classes. ClassLoader cl = getClass().getClassLoader(); InputStream stream = cl.getResourceAsStream("plugin.properties"); I have tried different versions of path, with the results I couldn't totally explain: 1. "plugin.properties": not work 2. "WEB-INF/classes/plugin.properties": work 3. "/WEB-INF/classes/plugin.properties": not work 4. "/plugin.properties": not work Also, I'm using Tomcat 4.0.6 (NB3.5.1). Does anyone have an answer for this? Is "/" bad? It may apply to Tomcat 5 as well, isn't it? Regards, John The contents of this e-mail are intended for the named addressee only. It contains information that may be confidential. Unless you are the named addressee or an authorized designee, you may not copy or use it, or disclose it to anyone else. If you received it in error please notify us immediately and then destroy it. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Me and another gentleman had this conversation just a little while ago...well one similar to it. I always have a package which I put my files in. I never have a problem doing that. I always use Class.class.getResourceAsStream and getResource (should be roughly the same...usage is a little different). I have a web app that has multiple installations on the same server and they always find their files. But, I always use a package so I can access the files that way. I quit using an empty package for everything when I started having goofy problems with different app servers. I run into the same thing on Oracle 9iAS once. "/plugin.properties" and "plugin.properties" Are very different when you are using ClassLoader.getResource(AsStream), and the same thing applies to Class.getResource(AsString)...see java docs. Again, I never have a problem, and I load property files from under the classes directory all the time. Wade - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] The contents of this e-mail are intended for the named addressee only. It contains information that may be confidential. Unless you are the named addressee or an authorized designee, you may not copy or use it, or disclose it to anyone else. If you received it in error please notify us immediately and then destroy it. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Using the / on the classloader call will be like trying to access a file on your root drive or your / directory on *nix. But yes, I usually put my properties files in a folder under classes and access them that way just like accessing a file on the classpath...even though they are files. Under classes I'll have a com/redesetgrow directory and I'll put config files in there. Yes I use a class from one of my packages that I know will only be with my webapp. I always use the full classpath path to the resource and use a class instead of a ClassLoader. I always do com.redesetgrow.util.io.IO.class.getResource("/com/redesetgrow/config.properties"); or com.redesetgrow.util.io.IO.class.getResourceAsStream("/com/redesetgrow/config.properties"); I always use that full path because a certain vm had a weird bug that bit me before (java 1.3 on IBM AIX using Oracle 9iAS got me like that one time). So I used the full path thing and the class call and that did the trick for me. Since then just out of habit I use that call, and the full path, and I never have problems. I figure it helps me not forget anything, plus I just use one method of getting resources on the classpath. To me it's more readable now. Using the / at the front tells that call to not replace the slashes with .'s when it goes to find my file. Not putting the / in the front would make the call replace all the / with .'s.
RE: Classloading issue
Wade, Thanks for sharing. When you say using package, you mean for resource files? One specific thing you didn't mention is where the calling class is located. In my case, it's a class from within a jar in "lib". That really made the difference. My conclusion so far is similar: when using "/", CL could make a big difference. Better stay away from it? Regards, John > -Original Message- > From: Wade Chandler [mailto:[EMAIL PROTECTED] > Sent: Thursday, December 09, 2004 4:31 PM > To: Tomcat Users List > Subject: Re: Classloading issue > > > Yu, John wrote: > > Hi, > > > > I'm using Struts plugin, however, I think the issue mostly > related to Tomcat > > > > ClassLoading. > > > > I have a class (in a jar) under WEB-INF/lib, which loads > properties from > > a file located under WEB-INF/classes. > > > > ClassLoader cl = getClass().getClassLoader(); > > InputStream stream = > cl.getResourceAsStream("plugin.properties"); > > > > I have tried different versions of path, with the results I > couldn't totally > > explain: > > 1. "plugin.properties": not work > > 2. "WEB-INF/classes/plugin.properties": work > > 3. "/WEB-INF/classes/plugin.properties": not work > > 4. "/plugin.properties": not work > > > > Also, I'm using Tomcat 4.0.6 (NB3.5.1). Does anyone have an answer > > for this? Is "/" bad? It may apply to Tomcat 5 as well, isn't it? > > > > Regards, > > John > > > > > > > > > > The contents of this e-mail are intended for the named > addressee only. It > > contains information that may be confidential. Unless you > are the named > > addressee or an authorized designee, you may not copy or > use it, or disclose > > it to anyone else. If you received it in error please > notify us immediately > > and then destroy it. > > > > > > > - > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > Me and another gentleman had this conversation just a little while > ago...well one similar to it. I always have a package which I put my > files in. I never have a problem doing that. I always use > Class.class.getResourceAsStream and getResource (should be > roughly the > same...usage is a little different). I have a web app that > has multiple > installations on the same server and they always find their > files. But, > I always use a package so I can access the files that way. I > quit using > an empty package for everything when I started having goofy problems > with different app servers. I run into the same thing on > Oracle 9iAS once. > > "/plugin.properties" > and > "plugin.properties" > > Are very different when you are using > ClassLoader.getResource(AsStream), > and the same thing applies to Class.getResource(AsString)...see java > docs. Again, I never have a problem, and I load property files from > under the classes directory all the time. > > Wade > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > The contents of this e-mail are intended for the named addressee only. It contains information that may be confidential. Unless you are the named addressee or an authorized designee, you may not copy or use it, or disclose it to anyone else. If you received it in error please notify us immediately and then destroy it. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Classloading issue
Yu, John wrote: Hi, I'm using Struts plugin, however, I think the issue mostly related to Tomcat ClassLoading. I have a class (in a jar) under WEB-INF/lib, which loads properties from a file located under WEB-INF/classes. ClassLoader cl = getClass().getClassLoader(); InputStream stream = cl.getResourceAsStream("plugin.properties"); I have tried different versions of path, with the results I couldn't totally explain: 1. "plugin.properties": not work 2. "WEB-INF/classes/plugin.properties": work 3. "/WEB-INF/classes/plugin.properties": not work 4. "/plugin.properties": not work Also, I'm using Tomcat 4.0.6 (NB3.5.1). Does anyone have an answer for this? Is "/" bad? It may apply to Tomcat 5 as well, isn't it? Regards, John The contents of this e-mail are intended for the named addressee only. It contains information that may be confidential. Unless you are the named addressee or an authorized designee, you may not copy or use it, or disclose it to anyone else. If you received it in error please notify us immediately and then destroy it. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Me and another gentleman had this conversation just a little while ago...well one similar to it. I always have a package which I put my files in. I never have a problem doing that. I always use Class.class.getResourceAsStream and getResource (should be roughly the same...usage is a little different). I have a web app that has multiple installations on the same server and they always find their files. But, I always use a package so I can access the files that way. I quit using an empty package for everything when I started having goofy problems with different app servers. I run into the same thing on Oracle 9iAS once. "/plugin.properties" and "plugin.properties" Are very different when you are using ClassLoader.getResource(AsStream), and the same thing applies to Class.getResource(AsString)...see java docs. Again, I never have a problem, and I load property files from under the classes directory all the time. Wade - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Classloading issue
Hi, I'm using Struts plugin, however, I think the issue mostly related to Tomcat ClassLoading. I have a class (in a jar) under WEB-INF/lib, which loads properties from a file located under WEB-INF/classes. ClassLoader cl = getClass().getClassLoader(); InputStream stream = cl.getResourceAsStream("plugin.properties"); I have tried different versions of path, with the results I couldn't totally explain: 1. "plugin.properties": not work 2. "WEB-INF/classes/plugin.properties": work 3. "/WEB-INF/classes/plugin.properties": not work 4. "/plugin.properties": not work Also, I'm using Tomcat 4.0.6 (NB3.5.1). Does anyone have an answer for this? Is "/" bad? It may apply to Tomcat 5 as well, isn't it? Regards, John The contents of this e-mail are intended for the named addressee only. It contains information that may be confidential. Unless you are the named addressee or an authorized designee, you may not copy or use it, or disclose it to anyone else. If you received it in error please notify us immediately and then destroy it. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Classloading issue on startup and catalina.properties
Hi tribe, I've set up a resource and realm in my server.xml and placed the mysql driver in ~DOMAIN_DOCROOT/WEB-INF/lib. I get an exception on Tomcat startup [1]. It seems that driver must be in shared/lib for my tomcat to start without errors, but due to the "shared" nature of my tomcat installation that is not an option. Indeed, the same setup works fine on a machine of my control when the driver is in the common library folder, but fails with the same error when i change the driver's position to app/WEB-INF/lib. So I mkdired a new directory for that purpose on my home folder and added that in my catalina.properties like: shared.loader=${catalina.base}/shared/classes,${catalina.base}/shared/lib/*.jar,/home/mbatsis/common/lib/*.jar but it doesn't work (also tried common.loader). My path is correct... Can this be a catalina.properties bug related to [2] and are there any workarounds? I'm using 5.0.19 on linux. [1] Stacktrace: 2004-04-21 02:35:22 JDBCRealm[]: Exception opening database connection java.sql.SQLException: com.mysql.jdbc.Driver at org.apache.catalina.realm.JDBCRealm.open(JDBCRealm.java:635) at org.apache.catalina.realm.JDBCRealm.start(JDBCRealm.java:709) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4190) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1126) at org.apache.catalina.core.StandardHost.start(StandardHost.java:832) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1126) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:521) at org.apache.catalina.core.StandardService.start(StandardService.java:519) at org.apache.catalina.core.StandardServer.start(StandardServer.java:2345) at org.apache.catalina.startup.Catalina.start(Catalina.java:594) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:297) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:398) 2004-04-21 02:35:41 StandardContext[]cgi: init: loglevel set to 6 [2] http://www.faqchest.com/prgm/tomcat-l/tmct-03/tmct-0309/tmct-030958/tmct03092302_04163.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Classloading issue: common/lib/servlet-api.jar
Guy Rouillier wrote: Jeanfrancois Arcand wrote: Can you post the entire stack trace? This exception usually occurs when a doPrivileged block is missing (when -security). I will try to reproduce the problem since it is a bug in Tomcat. Jeanfrancois, I'll include the entire stack trace at the bottom on this message. Before spending time on this, let me get ahold of the jars this page uses and recompile them with the Tomcat 5 servlet jars. Yoav gave me the impression that version differences between compile and run time can cause this error. If that doesn't make this go away, I'll report back again. Thanks for your offer. Do you have the same exception if you don't turn security on? What your servlet is trying to do? Yes, I see the same thing without -security. Not clear on why it would still be using a SecureClassloader if I'm not running with -security. OK, then Yoav's recommendation is the way to go since doPrivileged block is not required when there is no security manager. -- Jeanfrancois Thanks -- Jeanfrancois Guy Rouillier wrote: I found this message in the archives from Michael Duffy that is relevant to my question: When Tomcat starts, it assumes the CLASSPATH for your Web app consists of: (1) The rt.jar, of course, (2) All the JARs in TOMCAT_HOME/common/lib, which are visible to all apps, (3) All the JARs in the TOMCAT_HOME/server/lib, which are visible only to Tomcat, (4) All the JARs in your WEB-INF/lib, which are visible only to your app, (5) All the .class files in your WEB-INF/classes, which are visible only to your app. That's it. If your Web app needs a JAR, put it in the WEB-INF/lib and you should be all set. - MOD << My page (which is running with a security manager, i.e, -security) is getting the following error (partial stack trace): java.lang.NoClassDefFoundError: javax/servlet/http/HttpSessionBindingListener at java.lang.ClassLoader.defineClass0(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:537) at java.security.SecureClassLoader.defineClass(SecureClassLoader .java:123 ) I found that common/lib/servlet-api.jar contains this class, and if I manually add it to the classpath (by editing catalina.sh), my page will then work. According to the note above, all jars on common/lib should be automatically available to my pages. I haven't touched catalina.properties. Any idea why this jar is not being picked up automatically out of common/lib? Thanks. Stack trace java.lang.NoClassDefFoundError: javax/servlet/http/HttpSessionBindingListener at java.lang.ClassLoader.defineClass0(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:537) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123) at java.net.URLClassLoader.defineClass(URLClassLoader.java:251) at java.net.URLClassLoader.access$100(URLClassLoader.java:55) at java.net.URLClassLoader$1.run(URLClassLoader.java:194) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:187) at java.lang.ClassLoader.loadClass(ClassLoader.java:289) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274) at java.lang.ClassLoader.loadClass(ClassLoader.java:235) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader .java:1296) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader .java:1230) at org.apache.jasper.servlet.JasperLoader$1.run(JasperLoader.java:176) at java.security.AccessController.doPrivileged(Native Method) at org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:174) at org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:110) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302) at org.apache.jsp.scc.myservices.html.mpm_jsp._jspService(mpm_jsp.java:841) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.ja va:311) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav a:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor Impl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:284) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.Subject.doAsPrivileged(Subject.java:500) at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:306) at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.jav a:200) at org.apache.catalina.core.ApplicationFilterChain.internal
RE: Classloading issue: common/lib/servlet-api.jar
Jeanfrancois Arcand wrote: > Can you post the entire stack trace? This exception usually > occurs when > a doPrivileged block is missing (when -security). I will try to > reproduce the problem since it is a bug in Tomcat. Jeanfrancois, I'll include the entire stack trace at the bottom on this message. Before spending time on this, let me get ahold of the jars this page uses and recompile them with the Tomcat 5 servlet jars. Yoav gave me the impression that version differences between compile and run time can cause this error. If that doesn't make this go away, I'll report back again. Thanks for your offer. > > Do you have the same exception if you don't turn security on? > What your > servlet is trying to do? Yes, I see the same thing without -security. Not clear on why it would still be using a SecureClassloader if I'm not running with -security. > > Thanks > > -- Jeanfrancois > > Guy Rouillier wrote: > >> I found this message in the archives from Michael Duffy that is >> relevant to my question: >> >> >> >> When Tomcat starts, it assumes the CLASSPATH for your >> Web app consists of: >> >> (1) The rt.jar, of course, >> (2) All the JARs in TOMCAT_HOME/common/lib, which are >> visible to all apps, >> (3) All the JARs in the TOMCAT_HOME/server/lib, which >> are visible only to Tomcat, >> (4) All the JARs in your WEB-INF/lib, which are >> visible only to your app, >> (5) All the .class files in your WEB-INF/classes, >> which are visible only to your app. >> >> That's it. >> >> If your Web app needs a JAR, put it in the WEB-INF/lib >> and you should be all set. - MOD >> << >> >> My page (which is running with a security manager, i.e, -security) is >> getting the following error (partial stack trace): >> >> java.lang.NoClassDefFoundError: >> javax/servlet/http/HttpSessionBindingListener >>at java.lang.ClassLoader.defineClass0(Native Method) >>at java.lang.ClassLoader.defineClass(ClassLoader.java:537) >> at java.security.SecureClassLoader.defineClass(SecureClassLoader >> .java:123 ) >> >> I found that common/lib/servlet-api.jar contains this class, and if I >> manually add it to the classpath (by editing catalina.sh), my page >> will then work. According to the note above, all jars on common/lib >> should be automatically available to my pages. I haven't touched >> catalina.properties. >> >> Any idea why this jar is not being picked up automatically out of >> common/lib? Thanks. Stack trace java.lang.NoClassDefFoundError: javax/servlet/http/HttpSessionBindingListener at java.lang.ClassLoader.defineClass0(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:537) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123) at java.net.URLClassLoader.defineClass(URLClassLoader.java:251) at java.net.URLClassLoader.access$100(URLClassLoader.java:55) at java.net.URLClassLoader$1.run(URLClassLoader.java:194) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:187) at java.lang.ClassLoader.loadClass(ClassLoader.java:289) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274) at java.lang.ClassLoader.loadClass(ClassLoader.java:235) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader .java:1296) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader .java:1230) at org.apache.jasper.servlet.JasperLoader$1.run(JasperLoader.java:176) at java.security.AccessController.doPrivileged(Native Method) at org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:174) at org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:110) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302) at org.apache.jsp.scc.myservices.html.mpm_jsp._jspService(mpm_jsp.java:841) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.ja va:311) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav a:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor Impl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:284) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.Subject.doAsPrivileged(Subject.java:500) at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:306) at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.jav a:200) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica tionFilterChain.
RE: Classloading issue: common/lib/servlet-api.jar
Shapira, Yoav wrote: > Howdy, > >> ClassNotFoundException - class you explicitly asked for is not found >> NoClassDefFoundError - a class required by your class (through a new, >> e.g.) was available at compile time but cannot be found now. > > I know what the errors mean, thanks ;) The most common cause > for the latter is version skew: a class was found with the > same name but not the same interfaces as the class you had at > compile-time. For example, a version of > javax.servlet.http.HttpServletRequest from a servlet > specification 2.3 jar was found on a tomcat 5 classpath. The jars that this page uses were definitely compiled with an earlier version of servlet.jar than Tomcat 5 contains. That would produce NoClassDefFoundError? Why would the error go away if I explicitly include the subject jar in the classpath? Sorry, I have read all the JBoss classloading docs, but have not yet read the Tomcat classloader ref you supplied - I will. > >> I have no servlet jars other than the ones Tomcat 5.0.18 supplies. >> I do have jboss-j2ee.jar in my classpath, and the code will not >> compile without it: "javax\ejb\CreateException.class not found". I >> moved the > > Are you running tomcat standalone or JBoss with embedded > tomcat? Standalone, though JBoss is running on the same box in a different JVM. > Does the jboss-j2ee.jar have the servlet classes in it? No. Yoav, thanks for your time. I don't want to ask for any more of it until I can get the chance to recompile the jars with the same servlet jars Tomcat 5 is using (and I've read the classloader docs.) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Classloading issue: common/lib/servlet-api.jar
Can you post the entire stack trace? This exception usually occurs when a doPrivileged block is missing (when -security). I will try to reproduce the problem since it is a bug in Tomcat. Do you have the same exception if you don't turn security on? What your servlet is trying to do? Thanks -- Jeanfrancois Guy Rouillier wrote: I found this message in the archives from Michael Duffy that is relevant to my question: When Tomcat starts, it assumes the CLASSPATH for your Web app consists of: (1) The rt.jar, of course, (2) All the JARs in TOMCAT_HOME/common/lib, which are visible to all apps, (3) All the JARs in the TOMCAT_HOME/server/lib, which are visible only to Tomcat, (4) All the JARs in your WEB-INF/lib, which are visible only to your app, (5) All the .class files in your WEB-INF/classes, which are visible only to your app. That's it. If your Web app needs a JAR, put it in the WEB-INF/lib and you should be all set. - MOD << My page (which is running with a security manager, i.e, -security) is getting the following error (partial stack trace): java.lang.NoClassDefFoundError: javax/servlet/http/HttpSessionBindingListener at java.lang.ClassLoader.defineClass0(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:537) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123 ) I found that common/lib/servlet-api.jar contains this class, and if I manually add it to the classpath (by editing catalina.sh), my page will then work. According to the note above, all jars on common/lib should be automatically available to my pages. I haven't touched catalina.properties. Any idea why this jar is not being picked up automatically out of common/lib? Thanks. - 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: Classloading issue: common/lib/servlet-api.jar
Howdy, >ClassNotFoundException - class you explicitly asked for is not found >NoClassDefFoundError - a class required by your class (through a new, >e.g.) was available at compile time but cannot be found now. I know what the errors mean, thanks ;) The most common cause for the latter is version skew: a class was found with the same name but not the same interfaces as the class you had at compile-time. For example, a version of javax.servlet.http.HttpServletRequest from a servlet specification 2.3 jar was found on a tomcat 5 classpath. >I have no servlet jars other than the ones Tomcat 5.0.18 supplies. I do >have jboss-j2ee.jar in my classpath, and the code will not compile >without it: "javax\ejb\CreateException.class not found". I moved the Are you running tomcat standalone or JBoss with embedded tomcat? Does the jboss-j2ee.jar have the servlet classes in it? Yoav Shapira This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Classloading issue: common/lib/servlet-api.jar
Shapira, Yoav wrote: > Howdy, > - NoClassDefFoundError is different from > ClassNotFoundException. Make sure you understand the > difference. Then make sure you remove extra copies of the > servlet APIs from the classpath, specifically if you have > j2ee.jar or servlet.jar somewhere. Yoav, thanks for the reply. ClassNotFoundException - class you explicitly asked for is not found NoClassDefFoundError - a class required by your class (through a new, e.g.) was available at compile time but cannot be found now. I have no servlet jars other than the ones Tomcat 5.0.18 supplies. I do have jboss-j2ee.jar in my classpath, and the code will not compile without it: "javax\ejb\CreateException.class not found". I moved the JBoss jars I put in Tomcat's classpath to a directory outside the JBoss directory, just to make sure it wasn't picking up classes from that directory I didn't know about (turns out it was, the JBoss security classes.) I think the problem is probably in one of the classes that reside in jars we build and that are invoked on this page. At any rate, I can add the subject jar to the Tomcat classpath explicitly - that is a good-enough solution for now. > > - In addition to Senor Duffy's post, read the Classloader > How-To in the tomcat documentation. > > Yoav Shapira > Millennium ChemInformatics > > >> -Original Message- >> From: Guy Rouillier [mailto:[EMAIL PROTECTED] >> Sent: Monday, January 26, 2004 4:17 PM >> To: Tomcat Users List >> Subject: Classloading issue: common/lib/servlet-api.jar >> >> I found this message in the archives from Michael Duffy that is >> relevant to my question: >> >>>> >> When Tomcat starts, it assumes the CLASSPATH for your >> Web app consists of: >> >> (1) The rt.jar, of course, >> (2) All the JARs in TOMCAT_HOME/common/lib, which are >> visible to all apps, >> (3) All the JARs in the TOMCAT_HOME/server/lib, which >> are visible only to Tomcat, >> (4) All the JARs in your WEB-INF/lib, which are >> visible only to your app, >> (5) All the .class files in your WEB-INF/classes, >> which are visible only to your app. >> >> That's it. >> >> If your Web app needs a JAR, put it in the WEB-INF/lib >> and you should be all set. - MOD >> << >> >> My page (which is running with a security manager, i.e, -security) is >> getting the following error (partial stack trace): >> >> java.lang.NoClassDefFoundError: >> javax/servlet/http/HttpSessionBindingListener >>at java.lang.ClassLoader.defineClass0(Native Method) >>at java.lang.ClassLoader.defineClass(ClassLoader.java:537) >> at java.security.SecureClassLoader.defineClass(SecureClassLoader >> .java:123 ) >> >> I found that common/lib/servlet-api.jar contains this class, and if I >> manually add it to the classpath (by editing catalina.sh), my page >> will then work. According to the note above, all jars on common/lib >> should be automatically available to my pages. I haven't touched >> catalina.properties. >> >> Any idea why this jar is not being picked up automatically out of >> common/lib? Thanks. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Classloading issue: common/lib/servlet-api.jar
Howdy, - NoClassDefFoundError is different from ClassNotFoundException. Make sure you understand the difference. Then make sure you remove extra copies of the servlet APIs from the classpath, specifically if you have j2ee.jar or servlet.jar somewhere. - In addition to Senor Duffy's post, read the Classloader How-To in the tomcat documentation. Yoav Shapira Millennium ChemInformatics >-Original Message- >From: Guy Rouillier [mailto:[EMAIL PROTECTED] >Sent: Monday, January 26, 2004 4:17 PM >To: Tomcat Users List >Subject: Classloading issue: common/lib/servlet-api.jar > >I found this message in the archives from Michael Duffy that is relevant >to my question: > >>> >When Tomcat starts, it assumes the CLASSPATH for your >Web app consists of: > >(1) The rt.jar, of course, >(2) All the JARs in TOMCAT_HOME/common/lib, which are >visible to all apps, >(3) All the JARs in the TOMCAT_HOME/server/lib, which >are visible only to Tomcat, >(4) All the JARs in your WEB-INF/lib, which are >visible only to your app, >(5) All the .class files in your WEB-INF/classes, >which are visible only to your app. > >That's it. > >If your Web app needs a JAR, put it in the WEB-INF/lib >and you should be all set. - MOD ><< > >My page (which is running with a security manager, i.e, -security) is >getting the following error (partial stack trace): > >java.lang.NoClassDefFoundError: >javax/servlet/http/HttpSessionBindingListener >at java.lang.ClassLoader.defineClass0(Native Method) >at java.lang.ClassLoader.defineClass(ClassLoader.java:537) >at >java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123 >) > >I found that common/lib/servlet-api.jar contains this class, and if I >manually add it to the classpath (by editing catalina.sh), my page will >then work. According to the note above, all jars on common/lib should >be automatically available to my pages. I haven't touched >catalina.properties. > >Any idea why this jar is not being picked up automatically out of >common/lib? Thanks. > >- >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Classloading issue: common/lib/servlet-api.jar
I found this message in the archives from Michael Duffy that is relevant to my question: >> When Tomcat starts, it assumes the CLASSPATH for your Web app consists of: (1) The rt.jar, of course, (2) All the JARs in TOMCAT_HOME/common/lib, which are visible to all apps, (3) All the JARs in the TOMCAT_HOME/server/lib, which are visible only to Tomcat, (4) All the JARs in your WEB-INF/lib, which are visible only to your app, (5) All the .class files in your WEB-INF/classes, which are visible only to your app. That's it. If your Web app needs a JAR, put it in the WEB-INF/lib and you should be all set. - MOD << My page (which is running with a security manager, i.e, -security) is getting the following error (partial stack trace): java.lang.NoClassDefFoundError: javax/servlet/http/HttpSessionBindingListener at java.lang.ClassLoader.defineClass0(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:537) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123 ) I found that common/lib/servlet-api.jar contains this class, and if I manually add it to the classpath (by editing catalina.sh), my page will then work. According to the note above, all jars on common/lib should be automatically available to my pages. I haven't touched catalina.properties. Any idea why this jar is not being picked up automatically out of common/lib? Thanks. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]