permaculture playing cards*
The moose likes Struts and the fly likes ServletException in:/pages/logon.jsp] Cannot retrieve definition for form bean null' Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "ServletException in:/pages/logon.jsp] Cannot retrieve definition for form bean null Watch "ServletException in:/pages/logon.jsp] Cannot retrieve definition for form bean null New topic
Author

ServletException in:/pages/logon.jsp] Cannot retrieve definition for form bean null'

Steve Bills
Greenhorn

Joined: Feb 19, 2010
Posts: 6
Hello,

I am kind of new to Struts framework in Java.
I tried a sample application with a login page and an action class it worked out very well.

But when I try implementing the ActionForm, where we have all getter and setter methods for the form properties I had to do do a change in my login jsp as i needed property tags to pass my values to that Action form class but when i started using <html:text property=""> and <html:form> tags I am getting an error saying
ServletException in:/pages/logon.jsp] Cannot retrieve definition for form bean null'


this is the error stack trace:

avax.servlet.jsp.JspException: Cannot retrieve definition for form bean null
at org.apache.struts.taglib.html.FormTag.lookup(FormTag.java:831)
at org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:506)
at com.ibm._jsp._logon._jspx_meth_html_form_0(_logon.java:149)
at com.ibm._jsp._logon._jspService(_logon.java:70)
at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:85)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:989)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:501)
at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:464)
at com.ibm.wsspi.webcontainer.servlet.GenericServletWrapper.handleRequest(GenericServletWrapper.java:122)
at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.handleRequest(AbstractJSPExtensionServletWrapper.java:205)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.include(WebAppRequestDispatcher.java:639)
at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:1034)
at org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:484)
at org.apache.struts.tiles.TilesUtilImpl.doInclude(TilesUtilImpl.java:137)
at org.apache.struts.tiles.TilesUtil.doInclude(TilesUtil.java:177)
at org.apache.struts.taglib.tiles.InsertTag.doInclude(InsertTag.java:756)
at org.apache.struts.taglib.tiles.InsertTag$InsertHandler.doEndTag(InsertTag.java:881)
at org.apache.struts.taglib.tiles.InsertTag.doEndTag(InsertTag.java:473)
at com.ibm._jsp._template._jspx_meth_tiles_insert_2(_template.java:150)
at com.ibm._jsp._template._jspx_meth_html_html_0(_template.java:200)
at com.ibm._jsp._template._jspService(_template.java:74)
at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:85)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:989)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:501)
at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:464)
at com.ibm.wsspi.webcontainer.servlet.GenericServletWrapper.handleRequest(GenericServletWrapper.java:122)
at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.handleRequest(AbstractJSPExtensionServletWrapper.java:205)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:321)
at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:274)
at org.apache.struts.tiles.TilesRequestProcessor.processTilesDefinition(TilesRequestProcessor.java:254)
at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:309)
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.doGet(ActionServlet.java:507)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:989)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:501)
at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:464)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:321)
at org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:518)
at org.apache.struts.taglib.logic.ForwardTag.doEndTag(ForwardTag.java:170)
at com.ibm._jsp._index._jspx_meth_logic_forward_0(_index.java:92)
at com.ibm._jsp._index._jspService(_index.java:66)
at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:85)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:989)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:501)
at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:464)
at com.ibm.wsspi.webcontainer.servlet.GenericServletWrapper.handleRequest(GenericServletWrapper.java:122)
at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.handleRequest(AbstractJSPExtensionServletWrapper.java:205)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:321)
at com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.handleRequest(DefaultExtensionProcessor.java:555)
at com.ibm.ws.wswebcontainer.extension.DefaultExtensionProcessor.handleRequest(DefaultExtensionProcessor.java:113)
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3252)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:264)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:811)
at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1439)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:112)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:454)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:383)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:263)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:195)
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:743)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:873)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1469)


My JSP Page:


<html:form action="logon.do">
<table>
<tr>
<td>
<h3 >Sign in</h3>
</td>
<td>
</td>
<td></td>
</tr>
<tr>
<td></td>
<td>
<h3 >User ID:</h3>
</td>
<td>
<h3><html:text styleClass="text" property="name" /> </h3>
</td>
</tr>
<tr>
<td></td>
<td>
<h3 >Password:</h3>
</td>
<td>
<h3><html:text styleClass="password" property="password"/></h3>
</td>
</tr>
<br></br>
<tr>
<td></td>
<td></td>
<td ><div style="display:none" name="myspan"><font color="red">Please enter the valid username and password</font></div></td>
</tr>
<tr>
<td></td>
<td></td>
<td>
<h3><html:submit property="Submit" value="Submit" /></h3>
</td>
</tr>
</table>
</html:form>


My ActionForm class:


public class LoginForm extends ActionForm {
private String name=null;
private String password=null;

public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
password = password;
}
/**
* Reset all properties to their default values.
*
* @param mapping The mapping used to select this instance
* @param request The servlet request we are processing
*/
public void reset(ActionMapping mapping, HttpServletRequest request) {
this.name=null;
this.password=null;

}

public ActionErrors validate(
ActionMapping mapping, HttpServletRequest request ) {
ActionErrors errors = new ActionErrors();

if( getName() == null || getName().length() < 1 ) {
errors.add("name",new ActionMessage("error.name.required"));
}
if( getPassword() == null || getPassword().length() < 1 ) {
errors.add("address",new ActionMessage("error.address.required"));
}


return errors;
}



}




Your help will be really appreciated






Ninad Kulkarni
Ranch Hand

Joined: Aug 31, 2007
Posts: 784

UseCodeTags

I think this is not a java beginners question.
See this

You didn't provide uri of http://struts.apache.org/tags-html in jsp page using taglib directive
See this


SCJP 5.0 - JavaRanch FAQ - Java Beginners FAQ - SCJP FAQ - SCJP Mock Tests - Tutorial - JavaSE7 - JavaEE6 -Generics FAQ - JLS - JVM Spec - Java FAQs - Smart Questions
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60053
    
  65

Please be sure to ask Struts questions in the Struts forum. I have moved this post there for you.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Subhadip Pal
Greenhorn

Joined: Feb 17, 2010
Posts: 4
Hi Steve,
can you please post the Struts-config.xml and Action class as well...
Steve Bills
Greenhorn

Joined: Feb 19, 2010
Posts: 6
Please find my struts-config.xml file below

<?xml version="1.0" encoding="UTF-8"?>
<!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>

<!-- Data Sources -->
<data-sources>
</data-sources>

<!-- Form Beans -->
<form-beans>
<form-bean name="myForm" type="com.fms.clientweb.resources.LoginForm"/>
</form-beans>

<!-- Global Exceptions -->
<global-exceptions>
</global-exceptions>

<!-- Global Forwards -->
<global-forwards>
<forward name="homePage" path="/homePage.do" />
</global-forwards>

<!-- Action Mappings -->
<action-mappings>
<action path="/homePage" name="myForm" type="org.apache.struts.actions.ForwardAction" parameter=".logon" />
<action path="/logon" type="com.fms.clientweb.actions.LogonAction">
<forward name="success" path=".logonSuccess"></forward>
<forward name="failure" path=".logon"></forward>
</action>
</action-mappings>

<!-- Message Resources -->
<controller processorClass="org.apache.struts.tiles.TilesRequestProcessor"></controller>
<message-resources parameter="com.fms.clientweb.resources.ApplicationResources"/>
<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" />
</plug-in>

</struts-config>


My Action Class:

package com.fms.clientweb.actions;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.fms.clientweb.forms.LoginForm;

import bd.FMSBusinessDelegate;

/**
* @version 1.0
* @author
*/
public class LogonAction extends Action {

/**
* Constructor
*/
public LogonAction() {
super();
}

public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
throws Exception {
System.out.println("Entered the Execute menthod in logon action" );

ActionErrors errors = new ActionErrors();
ActionForward forward = new ActionForward();

try {
LoginForm loginForm = (LoginForm) form;
String name = loginForm.getName();
String pass= loginForm.getPassword();

/* String name = request.getParameter("uname");
String pass = request.getParameter("pwd");*/
System.out.println("the value of the userid is" +name);
System.out.println("the value of the password is" +pass);
// test call to the database
FMSBusinessDelegate bd = new FMSBusinessDelegate();
bd.testDb();
//LDAP Authentication
if ( bd.ldapAuthentication(name,pass)) {
forward = mapping.findForward("success");
} else {
forward = mapping.findForward("failure");

}
} catch (Exception e) {
// Report the error using the appropriate name and ID.
errors.add("name", new ActionError("id"));
forward = mapping.findForward("failure");
}

// If a message is required, save the specified key(s)
// into the request for use by the <struts:errors> tag.

if (!errors.isEmpty()) {
saveErrors(request, errors);
}
System.out.println("end of execute method in actionform class" );
return (forward);

}
}


My Jsp:

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

<h1 class="page_title">File Management System</h1>
<html:form action="logon.do">
<table>
<tr>
<td>
<h3 >Sign in</h3>
</td>
<td>
</td>
<td></td>
</tr>
<tr>
<td></td>
<td>
<h3 >User ID:</h3>
</td>
<td>
<h3><html:text styleClass="text" property="name" /> </h3>
</td>
</tr>
<tr>
<td></td>
<td>
<h3 >Password:</h3>
</td>
<td>
<h3><html:text styleClass="password" property="password"/></h3>
</td>
</tr>
<br></br>
<tr>
<td></td>
<td></td>
<td ><div style="display:none" name="myspan"><font color="red">Please enter the valid username and password</font></div></td>
</tr>
<tr>
<td></td>
<td></td>
<td>
<h3><html:submit property="Submit" value="Submit" /></h3>
</td>
</tr>
</table>
</html:form>
Ninad Kulkarni
Ranch Hand

Joined: Aug 31, 2007
Posts: 784

@ Steve
Please UseCodeTags
It will be easier to read your code for you and other people.

Would you give details of web.xml and LoginForm class
You are importing
in LogonAction class and you defined different LoginForm in form-beans tag of struts-config.xml

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ServletException in:/pages/logon.jsp] Cannot retrieve definition for form bean null'
 
Similar Threads
Not able to publish my JSF project in websphere 6.0
issing message for key
Output Stream already obtained Exception in Websphere
to Inclue jsp page in another using jsf
Problem JSP / EL / Tags With WebSphere WHY?!