RE: Problems running pre-compiled JSP classes when in subdirector ies
Show us the exception how it appears to you. -- De: Jay Glanville[SMTP:[EMAIL PROTECTED] Responder:Tomcat Users List Enviada: quarta-feira, 7 de janeiro de 2004 10:20 Para: 'Tomcat Users List' Assunto: Problems running pre-compiled JSP classes when in subdirectories I originally posted this question back in mid-December, but without any responses. In the hopes that someone will have a hit or a solution, I'm reposting the question again. I'm having a problem when I try to use my pre-compiled JSP files: I receive a NoClassDefFoundError exception. Here's what I'm doing ... I have pre-compiled my JSP classes using the JspC plugin from ant. My files compile without complaint. However, when I try to access the files through tomcat, I receive some NoClassDefFoundError exceptions. But these exceptions only occur when I'm accessing JSPs in the subdirectories off of the web root. Here's my application's background. I have two files: WEBROOT/index.jsp WEBROOT/dir/index.jsp The contents of the two files are just simple HTML. I precompiled the JSP using the JspC ant target, then compiled using javac. Finally, I created a context pointing the work directory to the location of my java and class files. When I tried to access the first file (http://localhost/context/index.jsp) everything went fine. However, when I tried to access the second file (http://localhost/context/dir/index.jsp), I received the NoClassDefFoundError. The log file looks like this: 2003-12-15 20:11:25 StandardWrapperValve[jsp]: Servlet.service() for servlet jsp threw exception javax.servlet.ServletException: org/apache/jsp/index_jsp (wrong name: org/apache/jsp/dir/index_jsp) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:249) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) [deleted ...] - Root Cause - java.lang.NoClassDefFoundError: org/apache/jsp/index_jsp (wrong name: org/apache/jsp/dir/index_jsp) at java.lang.ClassLoader.defineClass0(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:537) at java.lang.ClassLoader.defineClass(ClassLoader.java:448) at org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:215) [deleted] Now, according to my research on this mailing list, the most frequent reason for a NoClassDef error is capitalization. However, this isn't the case in my situation as the two package names are completely different: org/apache/jsp/index_jsp vs. org/apache/jsp/dir/index_jsp. I'm using Tomcat 4.1.29. Any suggestions on how to alleviate this situation would be greatly appreciated. Thanks JDG PS: I should also point out that I have tried the recommended way of precompiling my JSP by converting to servlets (http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jasper-howto.html#Web%2 0Application%20Compilation). However, I have a problem with this method: it makes it that much harder to patch my application. With the non-servlet approach, I just simply deliver the modified JSP files. With the servlet approach, I need to deliver the classes, plus ensure that the web.xml is correct (add new entries, remove old ones, modify where needed), plus restart the context. -- Jay Glanville - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Problems running pre-compiled JSP classes when in subdirector ies
That´s the answer, you need to specify org.apache as your JSP package. Here´s a example from my build.xml how to use jspc jspc srcdir =${webapp}/jsp//Place where JSPC can find web.xml destdir =${webapp}//place where jsp files will be created verbose =9 package=org.apache//root package uriroot =jsp // alias that you would use for JSP pages webxml =${webapp}/WEB-INF/jsp.xml// file to manage JSP files classpathref=base-path webapp basedir=${webapp}/ /jspc -- De: Antony Paul[SMTP:[EMAIL PROTECTED] Responder:Tomcat Users List Enviada: quarta-feira, 7 de janeiro de 2004 11:13 Para: Tomcat Users List Assunto: Re: Problems running pre-compiled JSP classes when in subdirectories I think the problem is the compiled source file is not in the org.apache.jsp package. How to set this in jspc task. Antony Paul - Original Message - From: Antony Paul [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Sent: Wednesday, January 07, 2004 7:41 PM Subject: Re: Problems running pre-compiled JSP classes when in subdirectories exception javax.servlet.ServletException: org/apache/jsp/index_jsp (wrong name: index_jsp) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:249) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) java.lang.NoClassDefFoundError: org/apache/jsp/index_jsp (wrong name: index_jsp) at java.lang.ClassLoader.defineClass0(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:502) at java.lang.ClassLoader.defineClass(ClassLoader.java:431) at org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:215) at org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:131) Interestingly if the jsp is comiled to servlet using jspc ant task and page is requested through browser then everything goes fine. If the generated source file is compiled using javac target of it is showing this error. Antony Paul - Original Message - From: Edson Alves Pereira [EMAIL PROTECTED] To: 'Tomcat Users List' [EMAIL PROTECTED] Sent: Wednesday, January 07, 2004 8:12 PM Subject: RE: Problems running pre-compiled JSP classes when in subdirectories Show us the exception how it appears to you. -- De: Jay Glanville[SMTP:[EMAIL PROTECTED] Responder: Tomcat Users List Enviada: quarta-feira, 7 de janeiro de 2004 10:20 Para: 'Tomcat Users List' Assunto: Problems running pre-compiled JSP classes when in subdirectories I originally posted this question back in mid-December, but without any responses. In the hopes that someone will have a hit or a solution, I'm reposting the question again. I'm having a problem when I try to use my pre-compiled JSP files: I receive a NoClassDefFoundError exception. Here's what I'm doing ... I have pre-compiled my JSP classes using the JspC plugin from ant. My files compile without complaint. However, when I try to access the files through tomcat, I receive some NoClassDefFoundError exceptions. But these exceptions only occur when I'm accessing JSPs in the subdirectories off of the web root. Here's my application's background. I have two files: WEBROOT/index.jsp WEBROOT/dir/index.jsp The contents of the two files are just simple HTML. I precompiled the JSP using the JspC ant target, then compiled using javac. Finally, I created a context pointing the work directory to the location of my java and class files. When I tried to access the first file (http://localhost/context/index.jsp) everything went fine. However, when I tried to access the second file (http://localhost/context/dir/index.jsp), I received the NoClassDefFoundError. The log file looks like this: 2003-12-15 20:11:25 StandardWrapperValve[jsp]: Servlet.service() for servlet jsp threw exception javax.servlet.ServletException: org/apache/jsp/index_jsp (wrong name: org/apache/jsp/dir/index_jsp) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:249) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) [deleted ...] - Root Cause - java.lang.NoClassDefFoundError: org/apache/jsp/index_jsp (wrong name: org/apache/jsp/dir/index_jsp) at java.lang.ClassLoader.defineClass0(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:537) at java.lang.ClassLoader.defineClass(ClassLoader.java:448) at org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:215) [deleted] Now, according to my research on this mailing list, the most frequent reason for a NoClassDef