• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Tomcat 3.2: Unable to load class ...

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good day!
I, honestly, have been searching the posts all day and digging through various reference material ...
I am trying to build the example JSP project (FAQ) provided in "Web Development with Java Server Pages" by Duane K. Fields and Mark A. Kolb. I am learning a GREAT deal from this book! And a lot more from this site!!
When launcing the URL:
http://localhost:8080/faqtool
I am presented with the directory listing rather than launching a servlet that should present me with a JSP page. I understand that the URL is not to change when navigating through this application???
Additionally, clicking on some of the JSP pages in the directory will result in the error:
2001-03-06 03:27:50 - Ctx( /faqtool ): JasperException: R( /faqtool + /all.jsp + null) Unable to load class FaqBean
I have ensured that my PATH, CLASSPATH, etc., variables are set correctly.
CLASSPATH = C:\jdk1.3.0_02\lib;C:\j2sdkee1.3\lib;C:\foo\tomcat;
C:\IBM Connectors\classes;C:\IBMCON~1\CICS\Classes\CTGCLI~1.JAR
J2EE_HOME = C:\j2sdkee1.3
JAVA_HOME = C:\jdk1.3.0_02
Path = C:\jdk1.3.0_02\bin;C:\j2sdkee1.3\bin;C:\IBMDebug\bin;
C:\IBM Connectors\Encina\bin;
C:\IBMCON~1\CICS\BIN;%SystemRoot%\system32;%SystemRoot%;
%SystemRoot%\System32\Wbem;C:\Program Files\Symantec\pcAnywhere;C:\IMNnq_NT;C:\foo;C:\IBM;
TOMCAT_HOME = C:\foo\tomcat
The actual Tomcat/FAQ app file path:
C:\foo\tomcat\webapps\faqtool\WEB-INF\classes\com\taglib\wdjsp\faqtool
"faqtool" contains all of my class files.
I have created the appropriate directories for the class files, configured the server.xml (for Tomcat) and the web.xml (for the FAQ app), but still can get this thing to work.
SERVER.XML (typical settings excluded):
.........................................................
<Context path="/faqtool"
docBase="webapps/faqtool"
isWARExpanded="true"
crossContext="false"
debug="0"
reloadable="true" >
</Context>
.........................................................
WEB.XML:
.........................................................
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
<web-app>
<display-name>Web Development with JSP</display-name>
<servlet>
<servlet-name>faqs</servlet-name>
<servlet-class>com.taglib.wdjsp.faqtool.FaqServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>faqtool</servlet-name>
<servlet-class>com.taglib.wdjsp.faqtool.FaqAdminServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>faqs</servlet-name>
<url-pattern>/faqs</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>faqtool</servlet-name>
<url-pattern>/faqtool</url-pattern>
</servlet-mapping>
</web-app>
.........................................................
Here is the FaqAdminServlet code:
.........................................................
package com.taglib.wdjsp.faqtool;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
public class FaqAdminServlet extends HttpServlet {
private HashMap commands;
private String error = "error.jsp";
private String jspdir = "/jsp/";

public void init(ServletConfig config) throws ServletException {
super.init(config);
initCommands();
}

public void service(HttpServletRequest req,
HttpServletResponse res)
throws ServletException, IOException {
String next;
try {
Command cmd = lookupCommand(req.getParameter("cmd"));
next = cmd.execute(req);
CommandToken.set(req);
}
catch (CommandException e) {
req.setAttribute("javax.servlet.jsp.jspException", e);
next = error;
}
RequestDispatcher rd;
rd = getServletContext().getRequestDispatcher(jspdir + next);
rd.forward(req, res);
}
private Command lookupCommand(String cmd)
throws CommandException {
if (cmd == null)
cmd = "main-menu";
if (commands.containsKey(cmd.toLowerCase()))
return (Command)commands.get(cmd.toLowerCase());
else
throw new CommandException("Invalid Command Identifier");
}
private void initCommands() {
commands = new HashMap();
commands.put("main-menu", new NullCommand("menu.jsp"));
commands.put("abort", new AbortCommand("menu.jsp"));
commands.put("add", new NullCommand("add.jsp"));
commands.put("do-add", new AddCommand("menu.jsp"));
commands.put("update-menu", new GetAllCommand("upd_menu.jsp"));
commands.put("update", new GetCommand("update.jsp"));
commands.put("do-update", new UpdateCommand("menu.jsp"));
commands.put("delete-menu", new GetAllCommand("del_menu.jsp"));
commands.put("delete", new GetCommand("delete.jsp"));
commands.put("do-delete", new DeleteCommand("menu.jsp"));
}
}
.........................................................
Here is the FaqBean code:
.........................................................
package com.taglib.wdjsp.faqtool;
import java.util.Date;
public class FaqBean {
private int id;
private String question;
private String answer;
private Date lastModified;
public FaqBean() {
this.id = 0;
this.question = "";
this.answer = "";
this.lastModified = new Date();
}
public void setQuestion(String question) {
this.question = question;
this.lastModified = new Date();
}
public String getQuestion() {
return this.question;
}
public void setAnswer(String answer) {
this.answer = answer;
this.lastModified = new Date();
}
public String getAnswer() {
return this.answer;
}
public void setID(int id) {
this.id = id;
}
public int getID() {
return this.id;
}
public Date getLastModified() {
return this.lastModified;
}
public void setLastModified(Date modified) {
this.lastModified = modified;
}
public String toString() {
return "[" + id + "] " + "Q: " + question + "; A: " +
answer + "\n";
}
}
.........................................................
This problem is particulary perplexing because I am able to compile and use other classes within the Tomcat environment.
I just can't seem to get this project off the ground.
I hope that all of this text didn't scare everyone away. This is my first posting. I just wanted to be sure to include as much pertinent info as possible. Thanks in advance!
Darrell
Future SCJP

I edited the classpath to keep this from pushing off the side of the page. The classpath is still complet but, appears on multiple lines ---Carl
[This message has been edited by Carl Trusiak (edited March 07, 2001).]
 
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I did find this note in the Tomcat readme
As of Tomcat 3.2, URL's are case sensitive for all operating systems,
including operating systems which have case insensitive file systems, such as
Windows. This represents a change from Tomcat 3.1, where URL's were case
insensitive on case insensitive OS's. This was done for a number of reasons,
security and portability among them.
A "non-portable" web application, i.e. one with case mismatches, which worked
on a case insensitive OS under Tomcat 3.1 will show its non-portability when
run under Tomcat 3.2.
This can also cause URL's that look correct to actually be incorrect. In
Windows Explorer, a directory whose name fits within the MS-DOS 8.3 format
may be displayed using a "formated" name. For example, a directory named
"MYDIR" may display as "Mydir". A URL like "http://localhost/mysite/Mydir/
index.jsp" would return "File Not Found" because the correct URL would be
"http://localhost/mysite/MYDIR/index.jsp". If you find URL's being
mysteriously "not found", check for case mismatch. Use the Windows Explorer
Properties dialog or an MS-DOS window to check the actual case of the file
and directory names.
 
Darrell Henry
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the tip. I'll keep digging ...
- Darrell
 
Darrell Henry
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No success on this one. Letter case is consistent throughout.
If any one else would like to try this project, you can get the source at:
http://www.manning.com/Fields/Source.html
Again, its the "faqtool" example application.
take care,
Darrell
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
WOW,
I can't really beleive thats an example for a book
Errors I found in the quick over view of all the faqtool jsp pages that reference:
1) The class FaqBean is being referenced by just class="FaqBean" instead of class="com.taglib.wdjsp.faqtool.FaqBean"
That's what is causing the Class not found error.
When you correct that, you always get thrown onto the error page. This is caused by
2) all pages get an array of FaqBeans from the request object
FaqBean[] faqs = (FaqBean[])request.getAttribute("faqs");
and then increments through them without checking to see if it's null.
for (int i=0; i < faqs.length; i++) {
The first time you hit the page, "faqs" has never been set to the session so, in the for loop the A null pointer exception is thrown.
I'd take a look at some of their other examples, the quick glance I made of these indicate that they may be a bit better.
------------------
Hope This Helps:)
Carl Trusiak
 
reply
    Bookmark Topic Watch Topic
  • New Topic