File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Error in creation of bean 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 "Error in creation of bean" Watch "Error in creation of bean" New topic

Error in creation of bean

Vijay Bhore

Joined: May 15, 2006
Posts: 12
Hi friends I am consistently getting this error

javax.servlet.ServletException: Exception creating bean of class JavaSource.forms.registerform:

I have created a jsp file register.jsp as follow,

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="form" %>

<form:form action="/">
User Name:<form:text property="username"/><br>
Enter Password:<form assword property="password1"/><br>
Re-Enter Password:<form assword property="password2"/><br>
<form:submit value="Register"/>

I am using Eclipse to create Dynamic web project.
For the above created register.jsp I have created a bean
in forms folder under Javasource folder as..

package forms;

import org.apache.struts.action.*;
import org.apache.struts.action.ActionForm;

public class registerform extends ActionForm {
public String username=null;
public String password1=null;
public String password2=null;

public void setUsername(String aUsername)
public String getUsername()

public void setPassword1(String aPassword1)
public String getPassword1()

public void setPassword2(String apassword2)
public String getPassword2()

My struts-config.xml is as follows..

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-Apache Softaware Foundation 1.0//EN"

<form-bean name="registerForm" type="JavaSource.forms.registerform"/>

<action path="/register"
input="/register.jsp" >
<forward name="success" path="/success.html"/>
<forward name="failure" path="/failure.html"/>


Why the error javax.servlet.ServletException: Exception creating bean of class JavaSource.forms.registerform is coming ?
Can anybody help immediately..?
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864

<form-bean name="registerForm" type="JavaSource.forms.registerform"/>


<form-bean name="registerForm" type="forms.registerform"/>

The source code you provoded indicates that the registerForm class is in package forms, not JavaSource.forms.

Also, just a note on style: Standard Java naming conventions dictate that a class name should start with an upper-case letter. You will want to change registerForm to RegisterForm.

Consultant, Sima Solutions
I agree. Here's the link:
subject: Error in creation of bean