写JSP的大作业,用了hibernate和struts,但是在最后一部分功能的时候出现了问题

javax.servlet.ServletException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.hibernate.cfg.annotations.reflection.XMLContext$Default.getDelimitedIdentifier()Ljava/lang/Boolean;
org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:535)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:433)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
com.jwy.tools.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:59)

root cause

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.hibernate.cfg.annotations.reflection.XMLContext$Default.getDelimitedIdentifier()Ljava/lang/Boolean;
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
java.security.AccessController.doPrivileged(Native Method)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:423)
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
org.springframework.web.context.ContextLoaderServlet.init(ContextLoaderServlet.java:81)
javax.servlet.GenericServlet.init(GenericServlet.java:212)
org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920)
org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883)
org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
org.apache.catalina.startup.Catalina.start(Catalina.java:566)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)

root cause

java.lang.NoSuchMethodError: org.hibernate.cfg.annotations.reflection.XMLContext$Default.getDelimitedIdentifier()Ljava/lang/Boolean;
org.hibernate.cfg.annotations.reflection.JPAMetadataProvider.getDefaults(JPAMetadataProvider.java:87)
org.hibernate.annotations.common.reflection.java.JavaReflectionManager.getDefaults(JavaReflectionManager.java:226)
org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1317)
org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1307)
org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:673)
org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
java.security.AccessController.doPrivileged(Native Method)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:423)
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
org.springframework.web.context.ContextLoaderServlet.init(ContextLoaderServlet.java:81)
javax.servlet.GenericServlet.init(GenericServlet.java:212)
org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920)
org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883)
org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
org.apache.catalina.startup.Catalina.start(Catalina.java:566)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
在下已经束手无策,本来就只是只菜鸟,又遇到这样的问题,我已经把百度词条都翻了个遍,还是没找着解决办法,求各位大神各显神通,指点一二,谢谢啦

2个回答

很毛线啊,你的sessionFactory配置有问题,贴配置文件吧

yjpilfsxjecav295
yjpilfsxjecav295 配置文件
4 年多之前 回复

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

<!-- 配置数据源,这里为DBCP数据库连接池 -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
    <property name="driverClassName" value="com.mysql.jdbc.Driver" />
    <property name="url" value="jdbc:mysql://localhost:3306/db_database26?character Encoding = UTF-8" />
    <property name="username" value="root" />
    <property name="password" value="123456" />
</bean>
<!-- 配置session工场 -->
<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.MySQLDialect
            </prop>
            <!-- 在控制台输出SQL语句 -->
            <prop key="hibernate.show_sql">true</prop>
        </props>
    </property>
    <!-- 配置映射文件 -->
    <property name="mappingResources">
        <list>
            <value>com\jwy\dto\UserLogin.hbm.xml
            </value>
            <value>com\jwy\dto\Specialty.hbm.xml
            </value>
            <value>com\jwy\dto\Course.hbm.xml
            </value>
            <value>com\jwy\dto\StuUser.hbm.xml
            </value>
            <value>com\jwy\dto\TechUser.hbm.xml
            </value>
            <value>com\jwy\dto\StuCourse.hbm.xml
            </value>
            <value>com\jwy\dto\CourseType.hbm.xml
            </value>
        </list>
    </property>
</bean>
<!-- 定义事务管理器 -->
<!---->
<bean id="transactionManager"
    class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory" />
</bean>

<!--定义注释驱动-->
<tx:annotation-driven transaction-manager="transactionManager" />

<!-- -->
<bean id="userLoginDao" class="com.jwy.dao.UserLoginDao">
    <property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean id="specialtyDao" class="com.jwy.dao.SpecialtyDao">
    <property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean id="courseDao" class="com.jwy.dao.CourseDao">
    <property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean id="stuUserDao" class="com.jwy.dao.StuUserDao">
    <property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean id="techUserDao" class="com.jwy.dao.TechUserDao">
    <property name="sessionFactory" ref="sessionFactory" />
</bean>
    <bean id="courseTypeDao" class="com.jwy.dao.CourseTypeDao">
    <property name="sessionFactory" ref="sessionFactory" />
</bean>
<!-- -->
<bean name="/userLogin" class="com.jwy.action.UserLoginAction">
    <property name="userLoginDao" ref="userLoginDao" />
    <property name="stuUserDao" ref="stuUserDao" />
    <property name="specialtyDao" ref="specialtyDao" />
</bean>
<bean name="/reg" class="com.jwy.action.RegAction">
    <property name="userLoginDao" ref="userLoginDao" />
    <property name="specialtyDao" ref="specialtyDao" />
</bean>
<bean name="/stuUser" class="com.jwy.action.StuUserAction">
    <property name="stuUserDao" ref="stuUserDao" />
    <property name="courseDao" ref="courseDao" />
    <property name="specialtyDao" ref="specialtyDao" />
</bean>
<bean name="/techUser" class="com.jwy.action.TechUserAction">
    <property name="techUserDao" ref="techUserDao" />
    <property name="courseDao" ref="courseDao" />
    <property name="specialtyDao" ref="specialtyDao" />
</bean>
<bean name="/updatePwd" class="com.jwy.action.UpdatePwdAction">
    <property name="userLoginDao" ref="userLoginDao" />
</bean>
<bean name="/specialty" class="com.jwy.action.SpecialtyAction">
    <property name="specialtyDao" ref="specialtyDao" />
</bean>
<bean name="/course" class="com.jwy.action.CourseAction">
    <property name="specialtyDao" ref="specialtyDao" />
    <property name="courseDao" ref="courseDao" />
</bean>
<bean name="/statInfo" class="com.jwy.action.StatInfoAction">
    <property name="specialtyDao" ref="specialtyDao" />
    <property name="courseDao" ref="courseDao" />
    <property name="stuUserDao" ref="stuUserDao" />
</bean>
    <bean name="/courseType" class="com.jwy.action.CourseTypeAction">
    <property name="specialtyDao" ref="specialtyDao" />
    <property name="courseTypeDao" ref="courseTypeDao" />

</bean>

这是配置文件,可是之前就能好好的运行啊,只有有一个功能不能实现,结果现在除了首页都跳不出来了,我搜了好多,虽然知道应该是配置文件的问题,可是看了好久,觉得我的配置文件没错啊,总之在这里费心看我问题的朋友都谢谢啦

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐