Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Exception creating bean

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!!!
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Drove my Chevy to the levee but the levee was dry. A wrung this tiny ad and it was still dry.
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic