You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by fo...@cmm.canon.com.my on 2004/01/05 11:23:17 UTC

javax.servlet.ServletException: Exception creating bean of class

i have this error, i don't know where goes wrong.. please help..

javax.servlet.ServletException: Exception creating bean of class 
net.foong.newitemForm: {1}
 
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:867)
 
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:800)
 org.apache.jsp.pages.newitemForm_jsp._jspService(newitemForm_jsp.java:80)
 org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

this is my struts-config.xml

Struts-config.xml
============
<!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 Bean Definitions -->
    <form-beans>
    <form-bean name="newitemForm" type="net.foong.newitemForm">
    </form-bean>
  </form-beans>
<!-- ================================= Global Exception Definitions -->
    <global-exceptions>
    </global-exceptions>
<!-- =================================== Global Forward Definitions -->
    <global-forwards>
        <forward name="welcome" path="/do/Welcome" />
    </global-forwards>

<!-- =================================== Action Mapping Definitions -->
    <action-mappings>
            <!-- Default "Welcome" action -->
            <!-- Forwards to Welcome.jsp -->
                <action path="/newitemForm" 
forward="/pages/newitemForm.jsp" />
 
                        <action path="/Welcome" 
type="org.apache.struts.actions.ForwardAction" 
parameter="/pages/Welcome.jsp" />
 
                        <action path="/newitem"
                        type="net.foong.newitemAction" 
                        name="newitemForm"
                        scope="request"
                        validate="false" 
                        >
                        <forward name="success" 
path="/pages/cofirmation.jsp" />
                </action> 
    </action-mappings>

<!-- ===================================== Controller Configuration -->

    <controller 
processorClass="org.apache.struts.tiles.TilesRequestProcessor" />

<!-- ================================ Message Resources Definitions -->

    <message-resources parameter="resources.application" />

<!-- ======================================= Plug Ins Configuration -->

  <!-- comment following if struts1.0.x -->
  <plug-in className="org.apache.struts.tiles.TilesPlugin">
    <set-property property="definitions-config" 
value="/WEB-INF/tiles-defs.xml" />
    <set-property property="moduleAware" value="true" />
    <set-property property="definitions-parser-validate" value="true" />
  </plug-in>

  <!-- end comment if struts1.0.x -->

  <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
    <set-property property="pathnames" 
value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml" />
  </plug-in>
</struts-config>

This is my web.xml
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>Struts Blank Application</display-name>
 
  <!-- Standard Action Servlet Configuration (with debugging) -->
  <servlet>
    <servlet-name>action</servlet-name>
    <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
    <init-param>
      <param-name>config</param-name>
      <param-value>/WEB-INF/struts-config.xml</param-value>
    </init-param>
    <init-param>
      <param-name>debug</param-name>
      <param-value>2</param-value>
    </init-param>
    <init-param>
      <param-name>detail</param-name>
      <param-value>2</param-value>
    </init-param>
    <load-on-startup>2</load-on-startup>
  </servlet>


  <!-- Standard Action Servlet Mapping -->
  <servlet-mapping>
    <servlet-name>action</servlet-name>
    <url-pattern>/do/*</url-pattern>
  </servlet-mapping>


  <!-- The Usual Welcome File List -->
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>


  <!-- Struts Tag Library Descriptors -->
  <taglib>
    <taglib-uri>/tags/struts-bean</taglib-uri>
    <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
  </taglib>

  <taglib>
    <taglib-uri>/tags/struts-html</taglib-uri>
    <taglib-location>/WEB-INF/struts-html.tld</taglib-location>
  </taglib>

  <taglib>
    <taglib-uri>/tags/struts-logic</taglib-uri>
    <taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
  </taglib>

  <taglib>
    <taglib-uri>/tags/struts-nested</taglib-uri>
    <taglib-location>/WEB-INF/struts-nested.tld</taglib-location>
  </taglib>

  <taglib>
    <taglib-uri>/tags/struts-tiles</taglib-uri>
    <taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
  </taglib>

</web-app>

this is my newitemForm.jsp
newitemForm.jsp
============
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<html>
<html:html locale="true">
<head>
<link href="<html:rewrite page="/pages/rr.css" />" rel="stylesheet" 
type="text/css">
<title><bean:message key="welcome.title"/></title>
<body>
<html:form action="newitem" focus="itemName" >
<table>
        <tr>
                <td>Item Name : </td>
                <td><html:text property="itemName" /></td>
        </tr>
        <tr>
                <td>Quantity</td>
                <td><html:text property="quantity" /></td>
        </tr>
</table>
<html:submit><bean:message key="button.submit" /></html:submit>
</html:form>
</html:html>
</body>
</html>

this is my newitemForm.java
newitemForm.java
=============
package net.foong;

import javax.servlet.http.HttpServletRequest;

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

public class newitemForm extends ActionForm {
        private String itemName;
        private int quantity;
 
        public void setItemName(String itemName) { this.itemName=itemName; 
}
        public void setQuantity(int quantity) { this.quantity=quantity; }

        public String getItemName() { return itemName; }
        public int getQuantity() { return quantity; }
        public void reset(ActionMapping mapping, HttpServletRequest 
request) {
                 this.itemName = null;
                 this.quantity = 0;
         }
}
This is my newitemAction.java
newitemAction.java
==============
package net.foong;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionForm;
//import org.apache.commons.beanutils.BeanUtils;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public final class newitemAction extends Action {
        public ActionForward execute(ActionMapping mapping,
 ActionForm form,
 HttpServletRequest request,
 HttpServletResponse response
                                                                  ) {
 
                newitemForm nif = new newitemForm();
                request.setAttribute("newitem", nif);
 
                return (mapping.findForward("success")); 
        }
 
}


But when i call the program, which provide me a link, in the index.page,
..
<p><bean:message key="welcome.msg"/></p>
<html:link page="/do/newitemForm">Create New Item</html:link>
</body>
...

it's prompt me that error...

can you tell me where goes wrong... 

Thank you.