zoukankan      html  css  js  c++  java
  • HTTP Status 500

    使用struts2时碰到这样的错误

    HTTP Status 500 - Unable to instantiate Action, customerAction, defined for 'customer_toAddPage' in namespace '/'Error creating bean with name 'customerAction' defined in class path resource [customer.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'userService' of bean class [cn.itcast.action.CustomerAction]: Bean property 'userService' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
    type Exception report
    
    message Unable to instantiate Action, customerAction, defined for 'customer_toAddPage' in namespace '/'Error creating bean with name 'customerAction' defined in class path resource [customer.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'userService' of bean class [cn.itcast.action.CustomerAction]: Bean property 'userService' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
    
    description The server encountered an internal error that prevented it from fulfilling this request.
    
    exception
    
    Unable to instantiate Action, customerAction,  defined for 'customer_toAddPage' in namespace '/'Error creating bean with name 'customerAction' defined in class path resource [customer.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'userService' of bean class [cn.itcast.action.CustomerAction]: Bean property 'userService' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter? - action - file:/D:/install/myeclipse2017/workspace/.metadata/.me_tcat85/webapps/ssh_crm02/WEB-INF/classes/struts.xml:14:65
        com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:314)
        com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:395)
        com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:194)
        org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63)
        org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:37)
        com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
        org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:554)
        org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:81)
        org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)
    root cause
    
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customerAction' defined in class path resource [customer.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'userService' of bean class [cn.itcast.action.CustomerAction]: Bean property 'userService' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
        org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1518)
        org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1226)
        org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
        org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
        org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:325)
        org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
        org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1054)
        com.opensymphony.xwork2.spring.SpringObjectFactory.buildBean(SpringObjectFactory.java:161)
        com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:178)
        com.opensymphony.xwork2.factory.DefaultActionFactory.buildAction(DefaultActionFactory.java:22)
        com.opensymphony.xwork2.ObjectFactory.buildAction(ObjectFactory.java:148)
        com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:295)
        com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:395)
        com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:194)
        org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63)
        org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:37)
        com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
        org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:554)
        org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:81)
        org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)
    root cause
    
    org.springframework.beans.NotWritablePropertyException: Invalid property 'userService' of bean class [cn.itcast.action.CustomerAction]: Bean property 'userService' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
        org.springframework.beans.BeanWrapperImpl.createNotWritablePropertyException(BeanWrapperImpl.java:231)
        org.springframework.beans.AbstractNestablePropertyAccessor.setPropertyValue(AbstractNestablePropertyAccessor.java:423)
        org.springframework.beans.AbstractNestablePropertyAccessor.setPropertyValue(AbstractNestablePropertyAccessor.java:280)
        org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:95)
        org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:75)
        org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1514)
        org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1226)
        org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
        org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
        org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:325)
        org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
        org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1054)
        com.opensymphony.xwork2.spring.SpringObjectFactory.buildBean(SpringObjectFactory.java:161)
        com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:178)
        com.opensymphony.xwork2.factory.DefaultActionFactory.buildAction(DefaultActionFactory.java:22)
        com.opensymphony.xwork2.ObjectFactory.buildAction(ObjectFactory.java:148)
        com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:295)
        com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:395)
        com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:194)
        org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63)
        org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:37)
        com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
        org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:554)
        org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:81)
        org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)
    note The full stack trace of the root cause is available in the Apache Tomcat/8.5.9 logs.

    原因就是spring的配置文件中的bean写错了,经过了仔细检查发现是property和类中属性不一样的情况。

  • 相关阅读:
    F版本SpringCloud1—大白话为啥要有微服务?啥是微服务?SpringCloud为什么有那么多组件?
    Java已五年1—二本物理到前端实习生到Java程序员「回忆贴」
    SpringBoot图文教程17—上手就会 RestTemplate 使用指南「Get Post」「设置请求头」
    SpringBoot图文教程15—项目异常怎么办?「跳转404错误页面」「全局异常捕获」
    SpringBoot图文教程14—SpringBoot集成EasyExcel「上」
    SpringBoot图文教程12—SpringData Jpa的基本使用
    SpringBoot图文教程11—从此不写mapper文件「SpringBoot集成MybatisPlus」
    SpringBoot图文教程10—模板导出|百万数据Excel导出|图片导出「easypoi」
    SpringBoot图文教程9—SpringBoot 导入导出 Excel 「Apache Poi」
    SpringBoot图文教程8 — SpringBoot集成MBG「代码生成器」
  • 原文地址:https://www.cnblogs.com/liaoxiaolao/p/9945843.html
Copyright © 2011-2022 走看看