stefanaichholzer
asked on
Problems with JSP
I'm running Tomcat 5.0 and it all works fine, I'm mostly doing servlets and it's all cool. Now I would like to move to .jsp pages but I can't get the damn thing to work and I don't know why...
Do I have to create a new webapp for my .jsp files or add some xml info or what?
I have a simple example:
<HTML>
<BODY>
Hello! The time is now <%= new java.util.Date() %>
</BODY>
</HTML>
When I call it from my browser I get errors like this:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperEx ception: Unable to compile class for JSP
org.apache.jasper.compiler .DefaultEr rorHandler .javacErro r(DefaultE rrorHandle r.java:97)
org.apache.jasper.compiler .ErrorDisp atcher.jav acError(Er rorDispatc her.java:3 46)
org.apache.jasper.compiler .Compiler. generateCl ass(Compil er.java:41 4)
org.apache.jasper.compiler .Compiler. compile(Co mpiler.jav a:472)
org.apache.jasper.compiler .Compiler. compile(Co mpiler.jav a:451)
org.apache.jasper.compiler .Compiler. compile(Co mpiler.jav a:439)
org.apache.jasper.JspCompi lationCont ext.compil e(JspCompi lationCont ext.java:5 11)
org.apache.jasper.servlet. JspServlet Wrapper.se rvice(JspS ervletWrap per.java:2 95)
org.apache.jasper.servlet. JspServlet .serviceJs pFile(JspS ervlet.jav a:292)
org.apache.jasper.servlet. JspServlet .service(J spServlet. java:236)
javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.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.taskd efs.compil ers.Compil erAdapterF actory.get Compiler(C ompilerAda pterFactor y.java:106 )
org.apache.tools.ant.taskd efs.Javac. compile(Ja vac.java:9 35)
org.apache.tools.ant.taskd efs.Javac. execute(Ja vac.java:7 64)
org.apache.jasper.compiler .Compiler. generateCl ass(Compil er.java:38 2)
org.apache.jasper.compiler .Compiler. compile(Co mpiler.jav a:472)
org.apache.jasper.compiler .Compiler. compile(Co mpiler.jav a:451)
org.apache.jasper.compiler .Compiler. compile(Co mpiler.jav a:439)
org.apache.jasper.JspCompi lationCont ext.compil e(JspCompi lationCont ext.java:5 11)
org.apache.jasper.servlet. JspServlet Wrapper.se rvice(JspS ervletWrap per.java:2 95)
org.apache.jasper.servlet. JspServlet .serviceJs pFile(JspS ervlet.jav a:292)
org.apache.jasper.servlet. JspServlet .service(J spServlet. java:236)
javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.java: 802)
Now, why am I getting this errors?, do I have to import something like a regular .java file or what?
Thank in advance and please provide some usefull tips...
;)
Do I have to create a new webapp for my .jsp files or add some xml info or what?
I have a simple example:
<HTML>
<BODY>
Hello! The time is now <%= new java.util.Date() %>
</BODY>
</HTML>
When I call it from my browser I get errors like this:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperEx
org.apache.jasper.compiler
org.apache.jasper.compiler
org.apache.jasper.compiler
org.apache.jasper.compiler
org.apache.jasper.compiler
org.apache.jasper.compiler
org.apache.jasper.JspCompi
org.apache.jasper.servlet.
org.apache.jasper.servlet.
org.apache.jasper.servlet.
javax.servlet.http.HttpSer
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.taskd
org.apache.tools.ant.taskd
org.apache.tools.ant.taskd
org.apache.jasper.compiler
org.apache.jasper.compiler
org.apache.jasper.compiler
org.apache.jasper.compiler
org.apache.jasper.JspCompi
org.apache.jasper.servlet.
org.apache.jasper.servlet.
org.apache.jasper.servlet.
javax.servlet.http.HttpSer
Now, why am I getting this errors?, do I have to import something like a regular .java file or what?
Thank in advance and please provide some usefull tips...
;)
ASKER
How, where do I do that? I can't seem to find somthing to do that in Tomcat
Thanx
Thanx
if ur JDK is installed for example at c:\jdk14.2 the
1- make sure that ur OS PATH enviroment variable part of it is ....;c:\jdk14\bin;.....
also open ur tomcat startup batch file and make sure that part of the classpath is c:\jdk14.2\lib\tools.jar
1- make sure that ur OS PATH enviroment variable part of it is ....;c:\jdk14\bin;.....
also open ur tomcat startup batch file and make sure that part of the classpath is c:\jdk14.2\lib\tools.jar
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You should be able to get by with <just> defining the JAVA_HOME environment variable to point to your local JDK installation. The tomcat startup scripts will implicitly add %JAVA_HOME%/bin to the path where neccessary.
One easy way to do this is to open up startup.bat and define JAVA_HOME at the top of it (other apps may need different versions of the JDK).
One easy way to do this is to open up startup.bat and define JAVA_HOME at the top of it (other apps may need different versions of the JDK).
ASKER
kiranhk and friends,
OK, I added following lines to the startup.bat file:
set JAVA_HOME=C:\Global\Java\j dk1.4\
set CATALINA_HOME=C:\Global\Ap ache\Tomca t 5.0\
Reloaded the server and still the same errores, and I don't know how to add the tools.jar into the classpath.
Errors I get:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperEx ception: Unable to compile class for JSP
org.apache.jasper.compiler .DefaultEr rorHandler .javacErro r(DefaultE rrorHandle r.java:97)
org.apache.jasper.compiler .ErrorDisp atcher.jav acError(Er rorDispatc her.java:3 46)
org.apache.jasper.compiler .Compiler. generateCl ass(Compil er.java:41 4)
org.apache.jasper.compiler .Compiler. compile(Co mpiler.jav a:472)
org.apache.jasper.compiler .Compiler. compile(Co mpiler.jav a:451)
org.apache.jasper.compiler .Compiler. compile(Co mpiler.jav a:439)
org.apache.jasper.JspCompi lationCont ext.compil e(JspCompi lationCont ext.java:5 11)
org.apache.jasper.servlet. JspServlet Wrapper.se rvice(JspS ervletWrap per.java:2 95)
org.apache.jasper.servlet. JspServlet .serviceJs pFile(JspS ervlet.jav a:292)
org.apache.jasper.servlet. JspServlet .service(J spServlet. java:236)
javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.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.taskd efs.compil ers.Compil erAdapterF actory.get Compiler(C ompilerAda pterFactor y.java:106 )
org.apache.tools.ant.taskd efs.Javac. compile(Ja vac.java:9 35)
org.apache.tools.ant.taskd efs.Javac. execute(Ja vac.java:7 64)
org.apache.jasper.compiler .Compiler. generateCl ass(Compil er.java:38 2)
org.apache.jasper.compiler .Compiler. compile(Co mpiler.jav a:472)
org.apache.jasper.compiler .Compiler. compile(Co mpiler.jav a:451)
org.apache.jasper.compiler .Compiler. compile(Co mpiler.jav a:439)
org.apache.jasper.JspCompi lationCont ext.compil e(JspCompi lationCont ext.java:5 11)
org.apache.jasper.servlet. JspServlet Wrapper.se rvice(JspS ervletWrap per.java:2 95)
org.apache.jasper.servlet. JspServlet .serviceJs pFile(JspS ervlet.jav a:292)
org.apache.jasper.servlet. JspServlet .service(J spServlet. java:236)
javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.java: 802)
OK, I added following lines to the startup.bat file:
set JAVA_HOME=C:\Global\Java\j
set CATALINA_HOME=C:\Global\Ap
Reloaded the server and still the same errores, and I don't know how to add the tools.jar into the classpath.
Errors I get:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperEx
org.apache.jasper.compiler
org.apache.jasper.compiler
org.apache.jasper.compiler
org.apache.jasper.compiler
org.apache.jasper.compiler
org.apache.jasper.compiler
org.apache.jasper.JspCompi
org.apache.jasper.servlet.
org.apache.jasper.servlet.
org.apache.jasper.servlet.
javax.servlet.http.HttpSer
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.taskd
org.apache.tools.ant.taskd
org.apache.tools.ant.taskd
org.apache.jasper.compiler
org.apache.jasper.compiler
org.apache.jasper.compiler
org.apache.jasper.compiler
org.apache.jasper.JspCompi
org.apache.jasper.servlet.
org.apache.jasper.servlet.
org.apache.jasper.servlet.
javax.servlet.http.HttpSer
ASKER
How does the /jsp-examples/ folder run the .jsp files?, I went through the folder and there is some .xml defining all the .jsp files that are in the folder, do I have to do something like that?, because if I have to I give up JSP :(
Thanx
Thanx
No you dont have to put any xml file.
Maybe there is problem with the JAVA_HOME you would have set.
can you check out catalina.bat and see if this line exists
call "%CATALINA_HOME%\bin\setcl asspath.ba t"
and if it is there can you also check out in setclasspath.bat whether it is having this line
set CLASSPATH=%JAVA_HOME%\lib\ tools.jar
Then make sure your your Java installation is correct.
If any of those line are not there can you add them and check
Maybe there is problem with the JAVA_HOME you would have set.
can you check out catalina.bat and see if this line exists
call "%CATALINA_HOME%\bin\setcl
and if it is there can you also check out in setclasspath.bat whether it is having this line
set CLASSPATH=%JAVA_HOME%\lib\
Then make sure your your Java installation is correct.
If any of those line are not there can you add them and check
also go thro' these and check if u have done the same thing
https://www.experts-exchange.com/questions/21183190/Tomcat-does-not-start.html
https://www.experts-exchange.com/questions/21177398/Tomcat-Problem.html
https://www.experts-exchange.com/questions/21183190/Tomcat-does-not-start.html
https://www.experts-exchange.com/questions/21177398/Tomcat-Problem.html
ASKER
Ok, I guess that's it, I added the lines kirank gave me, but still the damn thing wasn't working. I was using the Tomcat monitor to restart the server and that was not doing it, then I started the server from the DOS prompt, using the startup.bat and then it worked just fine. I can now run all my .jsp files.
Still I would like to know why did I have to restart the server using the startup.bat and why wouldn't it work using the Tomcat monitor??
Thanx to all you guys...
--> http://stefan.cuencaweb.com/thanx.htm
Still I would like to know why did I have to restart the server using the startup.bat and why wouldn't it work using the Tomcat monitor??
Thanx to all you guys...
--> http://stefan.cuencaweb.com/thanx.htm
${Java_home}\bin
also that:
${Java_home}\lib\tools.jar
is in ur classpath