New to JSP, and this is probable a stupid question

My PC is currently running W2K with IIS. This is because most of the consultancy work I do is with NT and Visual Studio.

Anyway for reasons too complicated to go into I need to implement a website using JSP and HTML.

Now I've downloaded Tomcat got that working with IIS and I've downloaded the Forte Jave Development Suite.

I know that Tomcat is working because I can see the examples page with the following URL http://localhost:8080/index.html

I've set the Path to point to the bin directory for the Java SDK and created a java application in a different path. Also If I use the Servlet applications everything works fine.

However if I use the JSP examples then all I get is the following;

--

javax.servlet.ServletException: sun/tools/javac/Main

at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:508)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)

at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)

at org.apache.tomcat.core.Handler.service(Handler.java:287)

at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)

at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:812)

at org.apache.tomcat.core.ContextManager.service(ContextManager.java:758)

at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:213)

at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)

at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)

at java.lang.Thread.run(Thread.java:484)

Root cause:

java.lang.NoClassDefFoundError: sun/tools/javac/Main

at org.apache.jasper.compiler.SunJavaCompiler.compile(SunJavaCompiler.java:136)

at org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)

at org.apache.jasper.servlet.JspServlet.doLoadJSP(JspServlet.java:612)

at org.apache.jasper.servlet.JasperLoader12.loadJSP(JasperLoader12.java:146)

at org.apache.jasper.servlet.JspServlet.loadJSP(JspServlet.java:542)

at org.apache.jasper.servlet.JspServlet$JspServletWrapper.loadIfNecessary(JspServlet.java:258)

at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:268)

at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:429)

at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:500)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)

at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)

at org.apache.tomcat.core.Handler.service(Handler.java:287)

at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)

at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:812)

at org.apache.tomcat.core.ContextManager.service(ContextManager.java:758)

at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:213)

at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)

at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)

at java.lang.Thread.run(Thread.java:484)

--

Now I'm assuming that I've missed out something in the setup but can I figure out what. Any help gratefully recieved. Thanks in advance

[3456 byte] By [PAULSC] at [2007-9-26 3:32:30]
# 1

Your problem is that tomcat can't find a java compiler to turn your jsp's into java bytecode.

Short background (which you may already know):

1. Tomcat, like all other jsp engines, takes a jsp source file and creates a java source file from it. (With tomcat, you'll find these files under tomcat's work directory)

2. The .java file is compiled into a .class file (bytecode),

3. The .class file is executed by the servlet engine.

Your problem is that you can't get from step 1 to step 2, because tomcat can't find a java compiler. In your stack trace, tomcat says it's looking for a class called sun.tools.javac.Main. This class comes with the jdk in the file tools.jar. Including this jar file in your classpath should solve the problem.

Hope this helps,

Pat Reaney

preaney at 2007-6-29 12:00:10 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Thanks for that Pat I thought it might be something like that however;

I've set the classpath environment variable to the following;

C:\JDK_Forte\jdk1.3.1\bin;c:\JDK_Forte\jdk1.3.1\lib

I've checked it has this value from the DOS prompt

This means that it contains a pointer to both the bin and lib directories of Forte. The lib directory is the only one which contains a tools.jar file that was mentioned in you answer. Thing is I still get the same error so is there some other environment variable that needs setting. I just get the feeling I'm missing something really obvious but for the life of me I can't figure out what it is.

PAULSC at 2007-6-29 12:00:10 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
Got it working. for those who are new to this and want to know the solution you set CLASSPATH to c:\JDK_Forte\jdk1.3.1\lib\tools.jar
PAULSC at 2007-6-29 12:00:10 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...