Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Problems with JSP

Posted on 2004-11-10
10
Medium Priority
?
294 Views
Last Modified: 2010-04-01
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.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)

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...

;)
0
Comment
Question by:stefanaichholzer
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 13

Expert Comment

by:petmagdy
ID: 12545269
Yes make sure that u defined in ur Path Env. variable:

${Java_home}\bin

also that:
${Java_home}\lib\tools.jar

is in ur classpath
0
 
LVL 9

Author Comment

by:stefanaichholzer
ID: 12545462
How, where do I do that? I can't seem to find somthing to do that in Tomcat

Thanx
0
 
LVL 13

Expert Comment

by:petmagdy
ID: 12545512
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
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 8

Accepted Solution

by:
kiranhk earned 1500 total points
ID: 12545707
you need to add these in your startup.bat after this line -> rem Guess CATALINA_HOME if not defined

set JAVA_HOME=D:\jdk1.5.0 (Change to your java installation path)
set CATALINA_HOME=D:\jakarta-tomcat-5.5.2(Change to your tomcat installation path)

then as petmagdy suggests add tools.jar into classpath

0
 
LVL 7

Expert Comment

by:lhankins
ID: 12546447
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).

0
 
LVL 9

Author Comment

by:stefanaichholzer
ID: 12554772
kiranhk and friends,

OK, I added following lines to the startup.bat file:

  set JAVA_HOME=C:\Global\Java\jdk1.4\
  set CATALINA_HOME=C:\Global\Apache\Tomcat 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.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)
0
 
LVL 9

Author Comment

by:stefanaichholzer
ID: 12554794
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
0
 
LVL 8

Expert Comment

by:kiranhk
ID: 12555833
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\setclasspath.bat"

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
0
 
LVL 9

Author Comment

by:stefanaichholzer
ID: 12561826
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
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most folks would know the basics of how Dropbox works, so that’s not the purpose of this article. Security is what it’s all about, so here I’ll share how I choose to secure my Dropbox Account and the Data it contains.
Exchange administrators are always vigilant about Exchange crashes and disasters that are possible any time. It is quite essential to identify the symptoms of a possible Exchange issue and be prepared with a proper recovery plan. There are multiple…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question