Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java Open Source > Apache Tomcat
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Apache Tomcat General discussion of the Apache Tomcat servlet container. For discussions specific to the Professional Apache Tomcat book, please see the book discussion forum for that book.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Apache Tomcat section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 17th, 2004, 08:59 AM
Registered User
 
Join Date: Apr 2004
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default URGENT - Unable to compile class for jsp

I'm running Tomcat 5.0.19, under webapps I've a folder called MyApp containing my jsp files and beans.

location of my files:
%CATALINA_HOME%\webapps\MyApp\clock.jsp
%CATALINA_HOME%\webapps\MyApp\Web-inf\classes\TheBean\ClockBean.java

my setting:
set JAVA_HOME=C:\j2sdk1.4.2_04
set CATALINA_HOME=C:\jakarta-tomcat-5.0.19
set PATH=%PATH%;C:\jdk1.4.2_04\bin;

I try to use the ClockBean in my clock.jsp but i got the error from tomcat, what's the problem? btw, my OS is windows 98, would that be the cause of the problem?



<<<<<<<<<<<<<<<<<<< ERROR REPORT FROM TOMCAT >>>>>>>>>>>>>>>>>>>>>>

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

An error occurred at line: 2 in the jsp file: /clock.jsp

Generated servlet error:
[javac] Compiling 1 source file

C:\jakarta-tomcat-5.0.19\work\Catalina\localhost\MyApp\org\apache\js p\clock_jsp.java:6: package TheBean does not exist
import TheBean.ClockBean;
^
C:\jakarta-tomcat-5.0.19\work\Catalina\localhost\MyApp\org\apache\js p\clock_jsp.java:45: package TheBean does not exist
TheBean.ClockBean clock = null;
^



An error occurred at line: 2 in the jsp file: /clock.jsp

Generated servlet error:
C:\jakarta-tomcat-5.0.19\work\Catalina\localhost\MyApp\org\apache\js p\clock_jsp.java:47: package TheBean does not exist
clock = (TheBean.ClockBean) _jspx_page_context.getAttribute("clock", PageContext.SESSION_SCOPE);
^



An error occurred at line: 2 in the jsp file: /clock.jsp

Generated servlet error:
C:\jakarta-tomcat-5.0.19\work\Catalina\localhost\MyApp\org\apache\js p\clock_jsp.java:49: package TheBean does not exist
clock = new TheBean.ClockBean();
^
4 errors


org.apache.jasper.compiler.DefaultErrorHandler.jav acError(DefaultErrorHandler.java:127)
org.apache.jasper.compiler.ErrorDispatcher.javacEr ror(ErrorDispatcher.java:351)
org.apache.jasper.compiler.Compiler.generateClass( Compiler.java:415)
org.apache.jasper.compiler.Compiler.compile(Compil er.java:458)
org.apache.jasper.compiler.Compiler.compile(Compil er.java:439)
org.apache.jasper.JspCompilationContext.compile(Js pCompilationContext.java:553)
org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:291)
org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet .java:856)


note The full stack trace of the root cause is available in the Tomcat logs.

<<<<<<<<<<<<<<<<<<< END OF ERROR REPORT FROM TOMCAT >>>>>>>>>>>>>>>>>>>>>>
Reply With Quote
  #2 (permalink)  
Old April 18th, 2004, 05:24 AM
Registered User
 
Join Date: Jun 2003
Location: , , Ireland.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The problem is that Tomcat's compiler needs the TheBean package available in the classpath to successfully compile the JSP. This is the problem.

You need to place your TheBean package in the WEB-INF/classes/ directory so its in Tomcat's classpath. So your Clockbean class will be located:
Code:
(TOMCAT)/WEB-INF/classes/TheBean/ClockBean.class
Reply With Quote
  #3 (permalink)  
Old April 19th, 2004, 07:15 AM
Registered User
 
Join Date: Apr 2004
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I tried possible solution posted above, but i still got the same error report from tomcat.
But I noticed something when I startup Tomcat, a message:

INFO: Installing web application at context path /MyApp from URL file:C:\jakarta-tomcat-5.0.19\webapps\MyApp
Apr 19, 2004 7:54:54 PM org.apache.catalina.startup.ContextConfig applicationConfig
INFO: Missing application web.xml, using defaults only StandardEngine[Catalina].StandardHost[localhost].StandardContext[/MyApp]

I have the web.xml file under %CATALINA_HOME%\webapps\MyApp\Web-infHere I included the web.xml file

web.xml
====================================
<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>
  <display-name>Welcome to My App</display-name>
  <description>
     Welcome to My App
  </description>

</web-app>
===================================
END OF web.xml

What could be the problem?

Reply With Quote
  #4 (permalink)  
Old May 6th, 2004, 06:57 AM
Registered User
 
Join Date: May 2004
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

change the folder 'web-inf' to 'WEB-INF' within you application folder.
ie
CHANGE
%CATALINA_HOME%\webapps\MyApp\Web-inf\classesTO
%CATALINA_HOME%\webapps\MyApp\WEB-INF\classes
the damn thing is case-sensitive !!!

even i had a hard time finding out this one ;-(

happy deploying.


Reply With Quote
  #5 (permalink)  
Old May 18th, 2004, 10:22 AM
Registered User
 
Join Date: May 2004
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Also, if you bean is part of a package the .class file I believe should be place in the last directory for name of your package
.


Quote:
quote:Originally posted by Black Balloon
 I'm running Tomcat 5.0.19, under webapps I've a folder called MyApp containing my jsp files and beans.

location of my files:
%CATALINA_HOME%\webapps\MyApp\clock.jsp
%CATALINA_HOME%\webapps\MyApp\Web-inf\classes\TheBean\ClockBean.java

my setting:
set JAVA_HOME=C:\j2sdk1.4.2_04
set CATALINA_HOME=C:\jakarta-tomcat-5.0.19
set PATH=%PATH%;C:\jdk1.4.2_04\bin;

I try to use the ClockBean in my clock.jsp but i got the error from tomcat, what's the problem? btw, my OS is windows 98, would that be the cause of the problem?



<<<<<<<<<<<<<<<<<<< ERROR REPORT FROM TOMCAT >>>>>>>>>>>>>>>>>>>>>>

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

An error occurred at line: 2 in the jsp file: /clock.jsp

Generated servlet error:
[javac] Compiling 1 source file

C:\jakarta-tomcat-5.0.19\work\Catalina\localhost\MyApp\org\apache\js p\clock_jsp.java:6: package TheBean does not exist
import TheBean.ClockBean;
^
C:\jakarta-tomcat-5.0.19\work\Catalina\localhost\MyApp\org\apache\js p\clock_jsp.java:45: package TheBean does not exist
TheBean.ClockBean clock = null;
^



An error occurred at line: 2 in the jsp file: /clock.jsp

Generated servlet error:
C:\jakarta-tomcat-5.0.19\work\Catalina\localhost\MyApp\org\apache\js p\clock_jsp.java:47: package TheBean does not exist
clock = (TheBean.ClockBean) _jspx_page_context.getAttribute("clock", PageContext.SESSION_SCOPE);
^



An error occurred at line: 2 in the jsp file: /clock.jsp

Generated servlet error:
C:\jakarta-tomcat-5.0.19\work\Catalina\localhost\MyApp\org\apache\js p\clock_jsp.java:49: package TheBean does not exist
clock = new TheBean.ClockBean();
^
4 errors


org.apache.jasper.compiler.DefaultErrorHandler.jav acError(DefaultErrorHandler.java:127)
org.apache.jasper.compiler.ErrorDispatcher.javacEr ror(ErrorDispatcher.java:351)
org.apache.jasper.compiler.Compiler.generateClass( Compiler.java:415)
org.apache.jasper.compiler.Compiler.compile(Compil er.java:458)
org.apache.jasper.compiler.Compiler.compile(Compil er.java:439)
org.apache.jasper.JspCompilationContext.compile(Js pCompilationContext.java:553)
org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:291)
org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet .java:856)


note The full stack trace of the root cause is available in the Tomcat logs.

<<<<<<<<<<<<<<<<<<< END OF ERROR REPORT FROM TOMCAT >>>>>>>>>>>>>>>>>>>>>>
Reply With Quote
  #6 (permalink)  
Old July 5th, 2004, 10:51 PM
Registered User
 
Join Date: Jul 2004
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi i am also havign ghe same problem and all the things i ahve tired does nt work....canybody can help

Reply With Quote
  #7 (permalink)  
Old August 27th, 2004, 06:38 PM
Friend of Wrox
 
Join Date: Jul 2004
Location: , , .
Posts: 204
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello, I had a similar problem, in my case it was caused my an error with the package, I had to create the folder for the package within a compiler so that package files were created. The directory structure I used was the same as that of the original poster of this thread:

\webapps\DBTest\WEB-INF\classes\params\validateUser.java

Where params is the package.

Other problems I had were within the jsp itself, the tag below is working:

<jsp:useBean id="valUser" scope="page" class="params.validateUser" />
<jsp:setProperty name="valUser" property="*" />

And to use the bean later on:

if (valUser.getValidation(userName[0], passWord[0]).equals("false"))

Im pretty new to this so Im not sure how much help this will be.

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
unable to compile class file derricktancf JSP Basics 0 November 1st, 2006 04:42 AM
jsp compile error shakmoh BOOK: Beginning JavaServer Pages 1 October 31st, 2006 12:57 PM
I am not able to compile my Action class vivekkumar_23 Struts 2 May 4th, 2006 09:09 AM
Compile method (Compiler class) stalker C# 2 November 11th, 2004 01:19 PM
Unable to Compile - page 17 JDGuardia BOOK: Beginning Java 2 1 July 13th, 2003 08:30 AM



All times are GMT -4. The time now is 03:00 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.