[web] Deploying war's with JSP

Started by
9 comments, last by kula 19 years, 7 months ago
I have made a web module with my NetBeans IDE. It contains a simple hello - world index.jsp file that works perfectly when I execute it from NetBeans. But when I compress it into a war file and put it in my real tomcat/webapps directory it stops working. The file is unpacked correctly, but when I visit the http://localhost:8080/HelloWorld/ directory I get this error message: HTTP Status 500 - type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception org.apache.jasper.JasperException: Unable to compile class for JSP org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:97) org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:346) org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:414) org.apache.jasper.compiler.Compiler.compile(Compiler.java:472) org.apache.jasper.compiler.Compiler.compile(Compiler.java:451) org.apache.jasper.compiler.Compiler.compile(Compiler.java:439) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) root cause Unable to find a javac compiler; com.sun.tools.javac.Main is not on the classpath. Perhaps JAVA_HOME does not point to the JDK org.apache.tools.ant.taskdefs.compilers.CompilerAdapterFactory.getCompiler(CompilerAdapterFactory.java:106) org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:935) org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:764) org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:382) org.apache.jasper.compiler.Compiler.compile(Compiler.java:472) org.apache.jasper.compiler.Compiler.compile(Compiler.java:451) org.apache.jasper.compiler.Compiler.compile(Compiler.java:439) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) note The full stack trace of the root cause is available in the Apache Tomcat/5.0.27 logs. And, YES! JAVA_HOME IS pointing to my JDK installation.
Advertisement
Is JAVA_HOME set globally? It is possible that it is set per user, in which case it may be correctly set for your normal user but the user account tomcat runs on may not have it.
There is an installation problem with your JSP container. It should be set up so that your JDK's tools.jar is in its classpath. A sensible container will already set itself up to do this automatically. At least Tomcat would.

It's an installation problem.

Unless you decided to install a JRE rather than a JDK, in which case tools.jar does not exist, you must get a JDK.

Mark
I have a JDK. It is installed in the C:\j2sdk1.4.2_04 directory and JAVA_HOME is set to this path. The environment variable is a global or "system" variable as windows calls it (set for all users).

Another strange thing I noticed is that I can run Servlets but not JSP.

Hi,

Quote:Original post by markr
It's an installation problem.


Not necessarily. The message quoted above is all older versions of Tomcat will give you when the JSP file cannot compile. I had that exact problem myself for some time - whenever there is a compilation error - no matter what, like a missing semicolon or import - the above message would pop up. Then I got myself the new Tomcat (that is, not the one that the JWSD installer offers for download, but the real, honest-to-goodness, latest version from the Jakarta web-site), and now the messages actually tell me what the compilation error is. [smile]

Back to the matter at hand, though, qwert, I suppose it shouldn't be a problem for you, since you say it works under NetBeans, but could you just post the contents of the JSP file any way? Also, you can test the WAR file creation with a simple html file inside it, and try to access that, though that also shouldn't be it...

Vovan
Vovan
It works with an index.html file but when I link it to my jsp script I get the same error.

Here is my script:

<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<html>
<head><title>JSP Page</title></head>
<body>

<%-- <jsp:useBean id="beanInstanceName" scope="session" class="beanPackage.BeanClassName" /> --%>
<%-- <jsp:getProperty name="beanInstanceName" property="propertyName" /> --%>

<%
out.println("Hello World");
%>

</body>
</html>

Hi,

Say, actually, try this: try one of Tomcat's own examples. One the default main page, there should be a link to "JSP Examples", which links to the jsp-examples webapp (like http://localhost:8080/jsp-examples/ ). So, try to go there, and see if those examples work. If they don't, then surely markr is right, and you should probably uninstall Tomcat, go over here, get Tomcat 5.latest.version, and install that.

If they do work, then... I don't know. [smile]

Vovan
Vovan
The examples work and I already have the latest version.

I think the problem is windows related. I tried the web-mods on the Linux server where they will be running. And they worked! I suspect that there may be some kind of conflict between the real Tomcat server and the one in NetBeans (but not the port since NetBeans uses 8084 and Tomcat: 8080).
Have you checked the logs?
-------------------------0 A.D.
I had the same problem on win2000 and of course my JAVA_HOME was correctly defined. To solve the problem, just copy the Tools.jar in the common/lib inside Tomcat.

Hope it helps...

This topic is closed to new replies.

Advertisement