首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

SHH框架,bean报错有关问题

2013-09-11 
SHH框架,bean报错问题HTTP Status 500 ---------------------------------------------type Exception rep

SHH框架,bean报错问题
HTTP Status 500 - 

--------------------------------------------

type Exception report

message 

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

exception 

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userService' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type [com.shh.dao.impl.UserTestDAO] to required type [com.shh.dao.IUserDAO] for property 'userDAO'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [com.shh.dao.impl.UserTestDAO] to required type [com.shh.dao.IUserDAO] for property 'userDAO': no matching editors or conversion strategy found

.......

applicationContext.xml代码:[color=#FF0000][/color]

<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">


<bean name="userService" class="com.shh.service.impl.UserService">
<property name="userDAO">
<ref bean="UserTestDAO"/>
</property>
</bean>
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"
value="oracle.jdbc.driver.OracleDriver">
</property>
<property name="url"
value="jdbc:oracle:thin:@localhost:1521:moon">
</property>
<property name="username" value="scott"></property>
<property name="password" value="tiger"></property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.Oracle9Dialect
</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/shh/user/UserTest.hbm.xml</value></list>
</property></bean>
<bean id="UserTestDAO" class="com.shh.dao.impl.UserTestDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean></beans>

web.xml代码:[color=#FF0000][/color]

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
  <servlet>
  <servlet-name>action</servlet-name>
  <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
  <init-param>
  <param-name>config</param-name>
  <param-value>/WEB-INF/struts-config.xml</param-value>


  </init-param>
  <init-param>
  <param-name>debug</param-name>
  <param-value>3</param-value>
  </init-param>
  <init-param>
  <param-name>detail</param-name>
  <param-value>3</param-value>
  </init-param>
  <load-on-startup>0</load-on-startup>
  </servlet>
  <servlet-mapping>
  <servlet-name>action</servlet-name>
  <url-pattern>*.do</url-pattern>
  </servlet-mapping>
  
  <context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>/WEB-INF/applicationContext.xml</param-value>
  </context-param>
  <servlet>
  <servlet-name>SpringContextServlet</servlet-name>
  <servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>
  <load-on-startup>1</load-on-startup>
  </servlet>
  
  
  <welcome-file-list>
  <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
</web-app>


struts-config.xml代码:[color=#FF0000][/color]

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd">

<struts-config>
<data-sources />
<form-beans>
<form-bean name="loginForm" type="com.shh.struts.form.LoginForm" />

</form-beans>

<global-exceptions />
<global-forwards />
<action-mappings>

<action path="/login" type="com.shh.struts.action.LoginAction"
name="loginForm" attribute="loginForm" input="/login.jsp" scope="request">
<forward name="suc" path="/index.jsp" />
</action>



</action-mappings>

<message-resources parameter="com.shh.struts.ApplicationResources" />
</struts-config>



[解决办法]
类型不匹配
检查注入类型
[解决办法]
类型不匹配
检查注入类型
[解决办法]
Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type [com.shh.dao.impl.UserTestDAO] to required type [com.shh.dao.IUserDAO] for property 'userDAO';

报类型不匹配 你好好查查 类型问题
[解决办法]


spring配置事务出现错误了吧,
应该错在spring配置
[解决办法]
<bean name="userService" class="com.ssh.service.impl.UserService">
<property name="userDAO">
<ref bean="UserDAO"/>
</property>
</bean>


userService里 userDAO 大小写没写错把?
[解决办法]
类型不对,UserTestDAO没有实现IUserDAO
[解决办法]
类型不对。
com.ssh.service.impl.UserService


类中属性userDAO
类型是不是com.shh.dao.impl.UserTestDAO?

我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.myexception.cn/java-web/317.html

热点排行