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

SSH整合出错 Struts Problem Report?该如何处理

2013-09-11 
SSH整合出错 Struts Problem Report?Struts Problem ReportStruts has detected an unhandled exception:M

SSH整合出错 Struts Problem Report?
Struts Problem Report

Struts has detected an unhandled exception:

Messages:
class org.hibernate.cfg.ExtendedMappings has interface org.hibernate.cfg.Mappings as super class
Error creating bean with name 'mySessionFactory' defined in class path resource [beans.xml]: Invocation of init method failed; nested exception is java.lang.IncompatibleClassChangeError: class org.hibernate.cfg.ExtendedMappings has interface org.hibernate.cfg.Mappings as super class
Error creating bean with name 'hibernateTemplate' defined in class path resource [beans.xml]: Cannot resolve reference to bean 'mySessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mySessionFactory' defined in class path resource [beans.xml]: Invocation of init method failed; nested exception is java.lang.IncompatibleClassChangeError: class org.hibernate.cfg.ExtendedMappings has interface org.hibernate.cfg.Mappings as super class
Error creating bean with name 'userDaoImple': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateTemplate' defined in class path resource [beans.xml]: Cannot resolve reference to bean 'mySessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mySessionFactory' defined in class path resource [beans.xml]: Invocation of init method failed; nested exception is java.lang.IncompatibleClassChangeError: class org.hibernate.cfg.ExtendedMappings has interface org.hibernate.cfg.Mappings as super class








beans.xml 

XML code
<?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:context="http://www.springframework.org/schema/context"    xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"    xsi:schemaLocation="http://www.springframework.org/schema/beans           http://www.springframework.org/schema/beans/spring-beans-2.5.xsd           http://www.springframework.org/schema/context           http://www.springframework.org/schema/context/spring-context-2.5.xsd           http://www.springframework.org/schema/aop           http://www.springframework.org/schema/aop/spring-aop-2.5.xsd           http://www.springframework.org/schema/tx            http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">    <context:annotation-config />    <context:component-scan base-package="*" />    <context:property-placeholder location="classpath:jdbc.properties" />    <bean name="myDataSource" class="org.apache.commons.dbcp.BasicDataSource"        destroy-method="close">        <property name="driverClassName" value="${jdbc.driverClassName}" />        <property name="url" value="${jdbc.url}" />        <property name="username" value="${jdbc.username}" />        <property name="password" value="${jdbc.password}" />    </bean>    <bean id="mySessionFactory"        class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">        <property name="dataSource" ref="myDataSource" />        <property name="annotatedClasses">            <list>                <value>model.User</value>            </list>        </property>        <property name="hibernateProperties">            <props>                <prop key="hibernate.dialect">                    org.hibernate.dialect.MySQLDialect                </prop>                <prop key="hibernate.show_sql">true</prop>                <prop key="hibernate.format_sql">true</prop>                <prop key="hibernate.hbm2ddl.auto"> update</prop>            </props>        </property>    </bean>        <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">        <property name="sessionFactory" ref="mySessionFactory"></property>    </bean>        </beans> 




UserDaoImple.java
Java code
@Component(value="userDaoImple")public class UserDaoImple  implements UserDao {    private HibernateTemplate hibernateTemplate;    public void add(User user) {        // TODO Auto-generated method stub        hibernateTemplate.save(user);    }    @Resource(name="hibernateTemplate")    public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {        this.hibernateTemplate = hibernateTemplate;    }    public HibernateTemplate getHibernateTemplate() {        return hibernateTemplate;    }}



UserAction.java
Java code
public class UserAction extends ActionSupport {    private User user;        public User getUser() {        return user;    }    public void setUser(User user) {        this.user = user;    }    @Override    public String execute() throws Exception {        // TODO Auto-generated method stub        ApplicationContext ctx = new ClassPathXmlApplicationContext(                "beans.xml");        UserDaoImple userS = (UserDaoImple) ctx.getBean("userDaoImple");        user.setDate(new Date());        userS.add(user);        return super.execute();    }}



那里错啦





[解决办法]
有可能是包兼容性的问题
[解决办法]
额,版本问题么
[解决办法]
貌似Jar包有冲突吧,http://hi.baidu.com/hxzon/blog/item/7bd4cc80e9d119d99023d9c6.html

热点排行