| Author |
Unable to compile class for JSP:
|
Ajay Kumar bathula
Greenhorn
Joined: Jul 13, 2004
Posts: 9
|
|
Hi I have Simple jsp pagewhich reads a parameter and returns an xml string.When i try to call this page i get the following error on the page 09-May-2008 11:34:50 org.apache.catalina.core.StandardWrapperValve invoke SEVERE: Servlet.service() for servlet jsp threw exception org.apache.jasper.JasperException: Unable to compile class for JSP: Stacktrace: at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85) at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330) at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:415) at org.apache.jasper.compiler.Compiler.compile(Compiler.java:308) at org.apache.jasper.compiler.Compiler.compile(Compiler.java:286) at org.apache.jasper.compiler.Compiler.compile(Compiler.java:273) at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:308) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:228) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445) at java.lang.Thread.run(Thread.java:595) Here is my Jsp Page ------------------- <%! String str=null; %> <% String searchCode = request.getParameter("sinput"); System.out.println("searchCode = " + searchCode); if (searchCode.equals("cars")) { str = "<search-results>" + "<total>2</total>" + "<result>" + "<code>1</code>" + "<name>Ford Focus</name>" + "<price>10000.00</price>" + "</result>" + "<result>" + "<code>2</code>" + "<name>Audi A4</name>" + "<price>20000.00</price>" + "</result>" + "</search-results>"; } else if(searchCode.equals("computers")) { str = "<search-results>" + "<total>2</total>" + "<result>" + "<code>3</code>" + "<name>Dell Inspiron</name>" + "<price>500.00</price>" + "</result>" + "<result>" + "<code>4</code>" + "<name>IBM</name>" + "<price>800.00</price>" + "</result>" + "</search-results>"; } %> <%= str %>
|
 |
Ajay Kumar bathula
Greenhorn
Joined: Jul 13, 2004
Posts: 9
|
|
|
I use "apache-tomcat-6.0.10" and JDK 1.5
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
In the Tomcat logs, is there a "Root cause" section right after that stack trace? This usually points to the problem in the JSP. Also, once you get this to compile, you might want to change your JSP so it doesn't use an instance variable that gets changed from the service method. The way it is written now is not thread safe.
|
Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
|
 |
Ajay Kumar bathula
Greenhorn
Joined: Jul 13, 2004
Posts: 9
|
|
Hi Ben Thanks for your Reply. The stack trace i have given abouve is from the log file lacated at C:\apache-tomcat-6.0.10\logs\localhost.2008-05-12 file. For the suggestion you gave to remove the instance variable, I have done that but of no use, I still get the same compilation error. There is no root cause section in the Logs I will give the complete stack trace once again for your reference from the logs. 12-May-2008 05:51:36 org.apache.catalina.core.ApplicationContext log INFO: default: init 12-May-2008 05:51:36 org.apache.catalina.core.ApplicationContext log INFO: jsp: init 12-May-2008 05:51:36 org.apache.catalina.core.ApplicationContext log INFO: default: init 12-May-2008 05:51:36 org.apache.catalina.core.ApplicationContext log INFO: jsp: init 12-May-2008 05:51:37 org.apache.catalina.core.ApplicationContext log INFO: ContextListener: contextInitialized() 12-May-2008 05:51:37 org.apache.catalina.core.ApplicationContext log INFO: SessionListener: contextInitialized() 12-May-2008 05:51:37 org.apache.catalina.core.ApplicationContext log INFO: default: init 12-May-2008 05:51:37 org.apache.catalina.core.ApplicationContext log INFO: jsp: init 12-May-2008 05:51:37 org.apache.catalina.core.ApplicationContext log INFO: default: init 12-May-2008 05:51:37 org.apache.catalina.core.ApplicationContext log INFO: jsp: init 12-May-2008 05:52:16 org.apache.catalina.core.StandardWrapperValve invoke SEVERE: Servlet.service() for servlet jsp threw exception org.apache.jasper.JasperException: Unable to compile class for JSP: Stacktrace: at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85) at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330) at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:415) at org.apache.jasper.compiler.Compiler.compile(Compiler.java:308) at org.apache.jasper.compiler.Compiler.compile(Compiler.java:286) at org.apache.jasper.compiler.Compiler.compile(Compiler.java:273) at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:308) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:228) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445) at java.lang.Thread.run(Thread.java:595)
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
|
Does the user under which Tomcat is running have sufficient permissions to write to the $CATALINA_HOME/work directory?
|
 |
Ajay Kumar bathula
Greenhorn
Joined: Jul 13, 2004
Posts: 9
|
|
Hi Ben I am not sure what you are talking about? I just have a simple jsp page which should return a string thats it. I deploy my web application through ant and call my page from the browser. I dont have any other servlet or any other configuration details in my web.xml file. This was working fine previously i don't know why this is happenning Now? Here is the snippet of my web.xml file.
|
 |
Ajay Kumar bathula
Greenhorn
Joined: Jul 13, 2004
Posts: 9
|
|
Hi Ben Here is the Code of the Servlet that is generated after my jsp is converted to servlet. I only have the tomcat jars in my project library and there are no compilation error that i could see in intellij for the generated Servlet. Then why the server is complaining about compilation errors. The jars that i have in my projectlibrary arejasper-el.jarservlet-apijsp-apijasper-eljaspercatalina-ant Here is the servlet code
|
 |
 |
|
|
subject: Unable to compile class for JSP:
|
|
|