This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exception creating bean of class...

 
Deb
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
New here. Just read through posts concerning Exceptions creating bean of class and couldn't find my answer.

I'm using a book, which is outdated but I didn't realize it. However, I thought I'd try to get through it anyways.

The exception is as follows:

javax.servlet.ServletException: Exception creating bean of class LookupForm: java.lang.ClassNotFoundException: LookupForm
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:495)
at org.apache.jsp.index_jsp._jspService(index_jsp.java:101)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:92)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:162)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:240)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:187)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)


I am using Tomcat 4.1.31 and j2sdk1.4.2.

The struts-config.xml file:

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

<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">

<struts-config>

<form-beans>
<form-bean name="lookupForm"
type="ch3.LookupForm"/>
</form-beans>

<action-mappings>
<action
path="/Lookup"
type="ch3.LookupAction"
name="lookupForm">
<forward name="success" path="/quote.jsp"/>
<forward name="failure" path="/index.jsp"/>
</action>
</action-mappings>

</struts-config>

The LookupForm.java file:

package ch3;

import javax.servlet.http.*;
import org.apache.struts.action.*;

public class LookupForm extends ActionForm
{
private String symbol = null;

public String getSymbol()
{
return symbol;
}

public void setSymbol(String symbol)
{
this.symbol = symbol;
}

public void reset(ActionMapping mapping,
HttpServletRequest request)
{
this.symbol = null;
}
}

The index.jsp file:

<%@ page language="java" %>
<%@ include file="/WEB-INF/jsp/TagLibraryHeader.jsp" %>

<html>
<head>
<title>Wrox Struts Application</title>
</head>

<body>
<table width="500" border="0" cellspacing="0" cellpadding="0">
<tr>
<td> </td>
</tr>
<tr>
<td height="68" width="48%">
<div align="left">
<img src="images/newwroxlogo.gif"
</div>
</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td> </td>
</tr>
</table>

<html:form action="Lookup">
<table width="45%" border="0">
<tr>
<td>Symbol:</td>
<td><html:text property="symbol" /></td>
</tr>
<tr>
<td colspan="2" align="center"><html:submit /></td>
</tr>
</table>
</html:form>
</body>
</html>

The original error I had the errors with the attributes for the <html:form> tag. I removed the attributes in the index.jsp file to be:

<html:form action="Lookup">

This solved one issue, however I get the following exception now. The LookupAction and LookupForm were both compiled and placed into the

...\webapps\ch03app\WEB-INF\classes\ch3


Any help would be appreciated. Thanks!
 
Reid M. Pinchback
Ranch Hand
Posts: 775
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem may be that you are missing a required library. ClassNotFoundException is definitely the least informative error that the JDK ever throws. Sometimes it means the class wasn't found. Sometimes it just means that loading failed because your class needed another class, and the second class was the one that wasn't found.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One thing I can discern from the message is that the class that can't be found is "LookupForm", which means that it doesn't realize that LookupForm is in the package ch3. Otherwise, it would say it couldn't find "ch3.LookupForm".

Since you define your form bean as type="ch3.LookupForm", though, I don't see why it's not picking up the correct class name.

The only thing I can think of to tell you is to re-deploy the application and re-start the application server. Maybe there's an old copy of struts-config.xml that's getting used instead of the one you showed us.
[ January 19, 2006: Message edited by: Merrill Higginson ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic