File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other Application Frameworks and the fly likes java. lang. IllegalStateException: Neither Binding Result nor plain target object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "java. lang. IllegalStateException: Neither Binding Result nor plain target object" Watch "java. lang. IllegalStateException: Neither Binding Result nor plain target object" New topic
Author

java. lang. IllegalStateException: Neither Binding Result nor plain target object

Yuva Latha Jatti
Greenhorn

Joined: Dec 07, 2008
Posts: 2
Hi

I am new to Spring Application .
Facing problem when trying to show the result in same input page

input page Userinput.jsp is

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Enter Userid</title>
</head>
<body>
<form:form method="post" commandName="cdi" name="userid">
<table border="10" width="95%" border="0" cellspacing="0"
cellpadding="5">
<caption><h2>Enter Userid</h2></caption>

<tr>
<td align="left" width="30%">userid </td><td> <form:input
path="userid" /></td>
</tr>
<tr>
<td align="left" width="30%">First Name </td><td> <form:input
path="fname" /></td>
</tr>

</table>
<br>
<input type="submit" align="center" value="Enter">
</form:form>
<br>
<br>
<c:if test="!((${users}).isEmpty)">
<form:form commandName="gcid">
<c ut value="${users}"></c ut>
<table align="center" name="transaction" style="background-color:#F2FAFD;border:1px solid #cfe9f6; width:96%;">
<tr class="tablebgcolorTagLib"><th class="tablecontent"><b><font color="#004F9A">Select</font></b></th>
<th class="tablecontent"><b><font color="#004F9A">GCID</font></b></th>
<th class="tablecontent"><b><font color="#004F9A">First Name</font></b></th>
<th class="tablecontent"><b><font color="#004F9A">Last Name</font></b></th>
<th class="tablecontent"><b><font color="#004F9A">Mobile No.</font></b></th>
<th class="tablecontent"><b><font color="#004F9A">Date Of Birth</font></b></th>
<th class="tablecontent"><b><font color="#004F9A">PAN #</font></b></th>
<th class="tablecontent"><b><font color="#004F9A">Address</font></b></th>
</tr>
<c:forEach items="${users}" var="user">
<tr>
<td> <c ut value="${user.Userid}"></c ut></td>
<td> <c ut value="${user.Fname}"></c ut></td>
<td> <c ut value="${user.Lname}"></c ut></td>
<td> <c ut value="${user.Dob}"></c ut></td>
<td> <c ut value="${user.Panno}"></c ut></td>
<td> <c ut value="${user.Address.Address1}"></c ut></td>
</tr>

</c:forEach>
</table>
</form:form>

</c:if>
<h5>* :- Mandatory Fields </h5>


</body>
</html>

and in Controller class defined as

public class UserDetailController extends SimpleFormController {



private UserServices userservices;

public ModelAndView onSubmit(Object command)
throws ServletException {
ApplicationContext context = new ClassPathXmlApplicationContext("application-context.xml");
//FileSystemXmlApplicationContext("application-context.xml");
userservices=(UserServices) context.getBean("userservices");
int userid= ((User) command).getUserid();
String fname=((User) command).getFname();
User user=new User();
List<User> users;
if (userid != 0)
{
System.out.println("In Userid");
user=userservices.userDetails(userid);
Map<String, Object> model = new HashMap<String, Object>();
model.put("user", user);
return new ModelAndView("userdetails","model",model);
}else
{
System.out.println("In Fname");
users=(List<User> userservices.indDetails(fname);
System.out.println("The result is*********************"+users);
return new ModelAndView(getSuccessView(),"users",users);
}

}

and in xml defined as :

<bean name="/detail.htm" class="com.spring.controller.UserDetailController">
<property name="sessionForm" value="true"/>
<property name="commandName" value="cdi"/>
<property name="commandClass" value="com.spring.domain.User"/>
<property name="formView" value="userinput"/>
<property name="successView" value="userinput"/>
<property name="userservices" ref="userservices"/>
</bean>

got an error as

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'cdi' available as request attribute
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:583)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:511)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'cdi' available as request attribute
org.springframework.web.servlet.support.BindStatus.<init>(BindStatus.java:141)
org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getBindStatus(AbstractDataBoundFormElementTag.java:172)
org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getPropertyPath(AbstractDataBoundFormElementTag.java:192)
org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getName(AbstractDataBoundFormElementTag.java:158)
org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.autogenerateId(AbstractDataBoundFormElementTag.java:145)
org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.resolveId(AbstractDataBoundFormElementTag.java:136)
org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.writeDefaultAttributes(AbstractDataBoundFormElementTag.java:120)
org.springframework.web.servlet.tags.form.AbstractHtmlElementTag.writeDefaultAttributes(AbstractHtmlElementTag.java:379)
org.springframework.web.servlet.tags.form.InputTag.writeTagContent(InputTag.java:139)
org.springframework.web.servlet.tags.form.AbstractFormTag.doStartTagInternal(AbstractFormTag.java:90)
org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:77)
org.apache.jsp.WEB_002dINF.jsp.userinput_jsp._jspx_meth_form_input_0(userinput_jsp.java:170)
org.apache.jsp.WEB_002dINF.jsp.userinput_jsp._jspx_meth_form_form_0(userinput_jsp.java:126)
org.apache.jsp.WEB_002dINF.jsp.userinput_jsp._jspService(userinput_jsp.java:77)
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.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:240)
org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:258)
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1174)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:901)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:809)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:511)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


note The full stack trace of the root cause is available in the Apache Tomcat/5.0.27 logs.

Thanks & Regards,
Yuva
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17256
    
    6

Can you repost your code with the CODE tags, so I can read it?

There are buttons under the Add Reply button, one is called CODE and will add the code tags so that any code you post will keep its indentation and format for easier reading.

It looks basically like you aren't putting "cdi" into your ModelAndView because it looks like the page can't find it.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Yuva Latha Jatti
Greenhorn

Joined: Dec 07, 2008
Posts: 2
My Controller is


and the xml contains like this

<bean name="/detail.htm" class="com.tcl.cdisvc.admin.web.controller.GcidSearchController">
<property name="sessionForm" value="true"/>
<property name="commandName" value="cdisvc"/>
<property name="commandClass" value="com.tcl.cdisvc.admin.web.forms.Gcid"/>
<property name="formView" value="Search"/>
<property name="successView" value="Search"/>
<property name="gcidSearchBO" ref="gcidSearchBO"/>

</bean>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java. lang. IllegalStateException: Neither Binding Result nor plain target object