aspose file tools*
The moose likes Struts and the fly likes Exception creating bean of class... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Exception creating bean of class..." Watch "Exception creating bean of class..." New topic
Author

Exception creating bean of class...

Deb
Greenhorn

Joined: Jan 19, 2006
Posts: 2
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!


-Deb
Reid M. Pinchback
Ranch Hand

Joined: Jan 25, 2002
Posts: 775
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.


Reid - SCJP2 (April 2002)
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
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 ]

Merrill
Consultant, Sima Solutions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Exception creating bean of class...