org.springframework.beans.NullValueInNestedPathException

报错代码:

HTTP Status 500 - An exception occurred processing JSP page /WEB-INF/views/input.jsp at line 29



type Exception report

message An exception occurred processing JSP page /WEB-INF/views/input.jsp at line 29

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

exception

org.apache.jasper.JasperException: An exception occurred processing JSP page /WEB-INF/views/input.jsp at line 29

26: 		LastName:<form:input path="lastName"/> <br>
27: 		Email:<form:input path="email"/> <br>
28: 		Gender:<form:radiobuttons path="gender" items="${genders}"/> <br>
29: 		Department:<form:select path="department.id" items="${dapartments}" itemLabel="departmentName" itemValue="id"></form:select><br>
30: 		<input type="submit" value="Submit">
31: 	</form:form>
32: </body>

Stacktrace:
	org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:568)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:470)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
	org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:168)
	org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:303)
	org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1244)
	org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1027)
	org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:971)
	org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)
	org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
	org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
	org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
	org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)

root cause

org.springframework.beans.NullValueInNestedPathException: Invalid property ‘department‘ of bean class [com.cqvie.model.Employee]: Could not instantiate property type [com.cqvie.model.Department] to auto-grow nested property path: java.lang.InstantiationException: com.cqvie.model.Department
	org.springframework.beans.BeanWrapperImpl.newValue(BeanWrapperImpl.java:657)
	org.springframework.beans.BeanWrapperImpl.createDefaultPropertyValue(BeanWrapperImpl.java:623)
	org.springframework.beans.BeanWrapperImpl.setDefaultValue(BeanWrapperImpl.java:611)
	org.springframework.beans.BeanWrapperImpl.getNestedBeanWrapper(BeanWrapperImpl.java:575)
	org.springframework.beans.BeanWrapperImpl.getBeanWrapperForPropertyPath(BeanWrapperImpl.java:549)
	org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:720)
	org.springframework.validation.AbstractPropertyBindingResult.getActualFieldValue(AbstractPropertyBindingResult.java:99)
	org.springframework.validation.AbstractBindingResult.getFieldValue(AbstractBindingResult.java:229)
	org.springframework.web.servlet.support.BindStatus.<init>(BindStatus.java:120)
	org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getBindStatus(AbstractDataBoundFormElementTag.java:168)
	org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getPropertyPath(AbstractDataBoundFormElementTag.java:188)
	org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getName(AbstractDataBoundFormElementTag.java:154)
	org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.autogenerateId(AbstractDataBoundFormElementTag.java:141)
	org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.resolveId(AbstractDataBoundFormElementTag.java:132)
	org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.writeDefaultAttributes(AbstractDataBoundFormElementTag.java:116)
	org.springframework.web.servlet.tags.form.AbstractHtmlElementTag.writeDefaultAttributes(AbstractHtmlElementTag.java:422)
	org.springframework.web.servlet.tags.form.SelectTag.writeTagContent(SelectTag.java:194)
	org.springframework.web.servlet.tags.form.AbstractFormTag.doStartTagInternal(AbstractFormTag.java:84)
	org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:80)
	org.apache.jsp.WEB_002dINF.views.input_jsp._jspx_meth_form_005fselect_005f0(input_jsp.java:278)
	org.apache.jsp.WEB_002dINF.views.input_jsp._jspx_meth_form_005fform_005f0(input_jsp.java:153)
	org.apache.jsp.WEB_002dINF.views.input_jsp._jspService(input_jsp.java:101)
	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
	org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:168)
	org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:303)
	org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1244)
	org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1027)
	org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:971)
	org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)
	org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
	org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
	org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
	org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)

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


Apache Tomcat/7.0.47

解决办法:

  这种问题是因为 你这个类中没有默认的空的构造函数,导致不能自动注入 autowired ,所以无法找到该类。

时间: 2024-10-09 04:27:42

org.springframework.beans.NullValueInNestedPathException的相关文章

springsecurity启动出现org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: You must use a 3.0 schema with Spring Security 3.0.

在换了spring-security的jar包以后启动出现org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: You must use a 3.0 schema with Spring Security 3.0.Please update your schema declarations to the 3.0.3 schema (spring-securi

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named &#39;App&#39; is defined

工具:Eclipse mars 环境:jdk1.8 说明:这是在学习Spring Task时遇到的一个bug,代码如下: 定时任务类: package com.task.test; import java.util.Date; import org.springframework.stereotype.Component; @Component public class App { public void execute1(){ System.out.printf("Task: %s, Curr

异常:Struts:org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find BasicDataSource

org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.apache.commons.dbcp.BasicDataSource] for bean with name 'dataSource' defined in class path resource [beans.xml]; nested exception is java.lang.ClassNotFoundExcepti

Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanCreationException:

严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListenerorg.springframework.beans.factory.BeanCreationException: Error creating bean with name 'daoSupport': Injection of resou

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException

1.错误描写叙述 usage: java org.apache.catalina.startup.Catalina [ -config {pathname} ] [ -nonaming ] { -help | start | stop } 2014-7-13 18:02:58 org.apache.catalina.core.AprLifecycleListener init 信息: Loaded APR based Apache Tomcat Native library 1.1.29 usi

?--Porg.springframework.beans.MethodInvocationException: Property &#39;username&#39; threw exception; nested exception is java.lang.NullPointerException

使用BoneCP作为连接池,在启动Tomcat报出以下异常: 一月 02, 2016 2:12:17 下午 org.apache.tomcat.util.digester.SetPropertiesRule begin警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:mynewdpi' did not find a

org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [/Users/lonecloud/tomcat/apache-tomcat-7.0.70 2/webapps/myproject/WEB-INF/classes/cn/lone

解决这个报错的解决办法: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [/Users/lonecloud/tomcat/apache-tomcat-7.0.70 2/webapps/myproject/WEB-INF/classes/cn/lonecloud/dao/Impl/UserDaoImpl.class]; ne

nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException

You should autowire interface AbstractManager instead of class MailManager. If you have different implemetations of AbstractManager you can write @Component("mailService") and then @Autowired @Qualifier("mailService") combination to au

org.springframework.beans.factory.config.PropertyPlaceholderConfigurer

可以将上下文(配置文件)中的属性值放在另一个单独的标准java Properties文件中去.在XML文件中用${key}替换指定的properties文件中的值.这样的话,只需要对properties文件进行修改,而不用对xml配置文件进行修改. 从上图中,我们看到PropertyPlaceholderConfigurer实现了三个bean生命周期的接口:BeanFactoryAware & BeanNameAware & BeanFactoryPostProcessor.关于sprin