File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Exception creating bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Exception creating bean" Watch "Exception creating bean" New topic
Author

Exception creating bean

Santiago Tim�n
Greenhorn

Joined: Aug 09, 2006
Posts: 1
Hi!

I'm getting a problem in one of my jsp pages. I'm designing a virtual shop for a college signature and whenI try to show a product information tomcat crashes in an internal exception.
The code and stacktrace:

The JSP:

<%@ page language="java" pageEncoding="UTF-8"%>

<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-template" prefix="template" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-nested" prefix="nested" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html locale="true">
<head>
<html:base />

<title>mostrarResultado.jsp</title>


</head>

<body>  <br>Resultado de la Busqueda<HR>
Criterio de la Busqueda:
<bean:write name="consultarCatalogoForm" property="criterioBusqueda"/><BR>
<!-- here I show the products contained in ArrayList listaProductos from DynaActionForm "consultarCatalogoForm" which fits the search criteria -->
<logic:iterate name="consultarCatalogoForm" property="listaProductos" id="product">
<td>
<TABLE border="1" width="200px">
<TR>


<html:form action="/detalles">
<td width="250px"><bean:write name="producto" property="productoId" />
<td width="50%" bgcolor="#ff0000" rowspan="100"><bean:write name="producto" property="categoriaId"/>
<td><bean:write name="producto" property="nombre"/>
<td><bean:write name="producto" property="detalleMayor"/>
<td><html:submit>

<!-- what I'm trying is to save the selected product into the DynaActionForm bean "detallesForm" but it doesn't work -->
<jsp:setProperty name="detallesForm"
property="producto"
param="producto" />



</html:submit>
</html:form>
</TR>
</TABLE>
</logic:iterate>
</body>
</html:html>

The Form-beans:

<form-bean name="consultarCatalogoForm" type="org.apache.struts.action.DynaActionForm">

<form-property name="criterioBusqueda" type="java.lang.String"></form-property>

<form-property name="listaProductos" type="java.util.ArrayList"></form-property>

</form-bean>
<form-bean name="detallesForm" type="org.apache.struts.action.DynaActionForm">

<form-property name="producto" type="com.santi.action.Producto"/>

</form-bean>

The StackTraces From Struts:

javax.servlet.ServletException: Exception creating bean of class org.apache.struts.action.DynaActionForm: {1}
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
org.apache.jsp.mostrarResultado_jsp._jspService(mostrarResultado_jsp.java:168)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

causa ra�z

javax.servlet.jsp.JspException: Exception creating bean of class org.apache.struts.action.DynaActionForm: {1}
org.apache.struts.taglib.html.FormTag.initFormBean(FormTag.java:563)
org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:520)
org.apache.jsp.mostrarResultado_jsp._jspx_meth_html_form_0(mostrarResultado_jsp.java:217)
org.apache.jsp.mostrarResultado_jsp._jspService(mostrarResultado_jsp.java:134)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

The StackTraces From MyEclipse console:

09-ago-2006 11:24:09 org.apache.struts.util.RequestUtils createActionForm
GRAVE: Error creating form bean of class org.apache.struts.action.DynaActionForm
java.lang.NullPointerException: The type for property producto is invalid
at org.apache.struts.action.DynaActionForm.set(DynaActionForm.java:414)
at org.apache.struts.action.DynaActionFormClass.newInstance(DynaActionFormClass.java:243)
at org.apache.struts.util.RequestUtils.createActionForm(RequestUtils.java:821)
at org.apache.struts.taglib.html.FormTag.initFormBean(FormTag.java:552)
at org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:520)
at org.apache.jsp.mostrarResultado_jsp._jspx_meth_html_form_0(mostrarResultado_jsp.java:217)
at org.apache.jsp.mostrarResultado_jsp._jspService(mostrarResultado_jsp.java:134)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:704)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:474)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:409)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:312)
at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:595)


I think it's all. If you need anything else just say it.

Thanks for your time!!!
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
First of all, I'd suggest you move the tag:

<html:form action="/detalles">

so that it is immediately after the <body> tag.

This tag causes the instantiation of the form bean if it doesn't already exist. Any references you make to the form bean before this tag will fail if the form bean wasn't already created before the page is displayed.

Secondly, I'd suggest enclosing the whole "Resultado de la Busqueda" section in this tag set:

<logic:notEmpty name="consultarCatalogoForm" property="listaProductos">
</logic:notEmpty>

This will allow for the fact that the first time you display the query page there are no results to display.


Merrill
Consultant, Sima Solutions
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Exception creating bean