2 wkittt wkittt 于 2015.07.09 11:12 提问

求助,这是什么问题?jar包问题吗?

严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'InterviewService' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: 'sessionFactory' or 'hibernateTemplate' is required
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4992)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5490)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:649)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1247)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1898)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.IllegalArgumentException: 'sessionFactory' or 'hibernateTemplate' is required
at org.springframework.orm.hibernate3.support.HibernateDaoSupport.checkDaoConfig(HibernateDaoSupport.java:118)
at org.springframework.dao.support.DaoSupport.afterPropertiesSet(DaoSupport.java:44)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
... 26 more
2015-7-9 10:52:27 org.apache.catalina.core.StandardContext startInternal
严重: Error listenerStart

application.xml代码如下
<?xml version="1.0" encoding="UTF-8"?>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.0.xsd">
context:annotation-config/
class="org.apache.commons.dbcp.BasicDataSource">
value="com.mysql.jdbc.Driver">




<bean id="sessionFactory"
    class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
    <property name="dataSource">
        <ref bean="dataSource" />
    </property>
    <property name="mappingResources">
        <list>
            <value>entity/Interview.hbm.xml</value>
            <value>entity/Employee.hbm.xml</value>
            <value>entity/Reply.hbm.xml</value>
            <value>entity/Job.hbm.xml</value>
            <value>entity/News.hbm.xml</value>
            <value>entity/Admin.hbm.xml</value>
        </list>
    </property>
    <!--  -->
    <property name="hibernateProperties">
        <props>
         <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
         <prop key="hibernate.hbm2ddl.auto">update</prop>
         <prop key="hibernate.show_sql">false</prop>
         <prop key="hibernate.format_sql">false</prop>
         <prop key="hibernate.cache.use_second_level_cache">true</prop>
         <prop key="hibernate.cache.use_query_cache">false</prop>
         <prop key="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</prop>
     </props>
    </property>
</bean>
<bean id="txManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory"/>
</bean>
<tx:annotation-driven transaction-manager="txManager"/>
<bean id="interviewDAO" class="dao.Impl.InterviewDaoImpl">
    <property name="sessionFactory">
        <ref bean="sessionFactory" />
    </property>
</bean>

<bean id="employeeDAO" class="dao.Impl.EmployeeDaoImpl">
    <property name="sessionFactory">
        <ref bean="sessionFactory" />
    </property>
</bean>

<bean id="replyDAO" class="dao.Impl.ReplyDaoImpl">
    <property name="sessionFactory">
        <ref bean="sessionFactory" />
    </property>
</bean>

<bean id="adminDAO" class="dao.Impl.AdminDaoImpl" >
    <property name="sessionFactory">
        <ref bean="sessionFactory" />
    </property>
</bean>

<bean id="jobDAO" class="dao.Impl.JobDaoImpl">
    <property name="sessionFactory">
        <ref bean="sessionFactory" />
    </property>
</bean>

<bean id="newsDAO" class="dao.Impl.NewsDaoImpl">
    <property name="sessionFactory">
        <ref bean="sessionFactory" />
    </property>
</bean>


 <!-- service配置 -->
 <bean id="InterviewService" class="service.Impl.InterviewServiceImpl">
    <!-- <property name="interviewDAO" ref="interviewDAO"/> -->
 </bean>
 <bean id="EmployeeService" class="service.Impl.EmployeeServiceImpl">
 <!--   <property name="employeeDAO" ref="employeeDAO"/>-->
 </bean>
 <bean id="AdminService" class="service.Impl.AdminServiceImpl">
    <!-- <property name="adminDAO" ref="adminDAO"/> -->
 </bean>
 <bean id="JobService" class="service.Impl.JobServiceImpl">
    <!-- <property name="jobDAO" ref="jobDAO"/> -->
 </bean>
 <bean id="NewsService" class="service.Impl.NewsServiceImpl">
    <!-- <property name="newsDAO" ref="newsDAO"/> -->
 </bean>
    <bean id="ReplyService" class="service.Impl.ReplyServiceImpl">
    <!--<property name="replyDAO" ref="replyDAO"/>-->
 </bean>

        <!--Action方法的配置  -->
<bean id="EmployeeAction" class="action.EmployeeAction" scope="prototype"/>
<bean id="AdminAction" class="action.AdminAction" scope="prototype"/>
<bean id="InterviewAction" class="action.InterviewAction" scope="prototype"/>
<bean id="ReplyAction" class="action.ReplyAction" scope="prototype"/>
<bean id="JobAction" class="action.JobAction" scope="prototype"/>
</beans>

我觉得是包的问题,我把所有的包都换了一遍,结果还是报这个错误。也不知道是缺了哪个包,大家帮帮忙吧!

6个回答

haonanzhuchegmingzhi
haonanzhuchegmingzhi   2015.07.09 11:25

有个Spring集成hibernate的JAR包,具体你找下,那个在初始化的时候需要找到相关配置,你在网上搜搜吧

haonanzhuchegmingzhi
haonanzhuchegmingzhi   2015.07.09 11:26

有个Spring集成hibernate的JAR包,具体你找下,那个在初始化的时候需要找到相关配置,你在网上搜搜吧

wkittt
wkittt 你好,不行,还是报那个错
大约 3 年之前 回复
bulusli3
bulusli3   Ds   Rxr 2015.07.09 11:49

InterviewService这个bean初始化的时候报错了。这个类里面应该有个方法需要一个参数为'sessionFactory' or 'hibernateTemplate'。

bulusli3
bulusli3 回复wkittt:继承了hibernatedaosupport的类需要注入一个sessionFactory。 <bean id="InterviewService" class="service.Impl.InterviewServiceImpl"><property name="sessionFactory"> <ref bean="sessionFactory"/></property></bean>
大约 3 年之前 回复
wkittt
wkittt 这个方法是继承了hibernatedaosupport的,然后用@Transactional事务管理注解事务。
大约 3 年之前 回复
wkittt
wkittt   2015.07.09 12:10

package service.Impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.transaction.annotation.Transactional;

import dao.InterviewDAO;

import entity.Interview;

import service.InterviewService;
@Transactional(readOnly=false)
public class InterviewServiceImpl extends HibernateDaoSupport implements
InterviewService {

@Resource InterviewDAO interviewDAO;

public void saveInterview(Interview interview) {
    this.interviewDAO.saveInterview(interview);
}

public void updateInterview(Interview interview) {
    this.interviewDAO.updateInterview(interview);
}

public void deleteInterview(Interview interview) {
    this.interviewDAO.deleteInterview(interview);
}

public Interview findInterviewById(int id) {
    return this.interviewDAO.findInterviewById(id);
}

public List<Interview> findById(int id) {
    return this.interviewDAO.findById(id);
}

}


这个是serviceimpl,发现好像它有时候会报其它service的错误,因为我还有几个service业务。用的都是@Transactional

yuke198907
yuke198907   2015.07.09 14:11

spring的配置不对,看看xml文件的配置

wkittt
wkittt 可以详细说一下吗?
大约 3 年之前 回复
frank_20080215
frank_20080215   2015.07.09 15:55

hibernate的jar包没有配置全而已

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!
其他相关推荐
这是什么问题
!SESSION 2017-12-24 10:24:55.149 ----------------------------------------------- eclipse.buildId=4.7.0.I20170612-0950 java.version=1.8.0_144 java.vendor=Oracle Corporation BootLoader constants: OS
SSH整合时jar包冲突解决的注意事项
在SSH项目整合的时候,要注意jar包冲突.     这里的原则是:     1,无依赖关系的舍低取高.     2.有依赖关系的取高。 怎么排查是否有冲突,在服务器项目的lib下查看是否有重名的。     注意:每次重新导入包以后要把服务器中的项目删掉再发布。
求解这几个问题,几个递归算法中的问题,挺有意思的。
初学者,求助这几个问题,用递归解决,这是算法中的几个递归问题,不是特别会写,求助
psql的简单题目答案
create table tb_student( id number primary key , name varchar2(18) not null, sex char(2) not null check(sex=’男’ or sex=’女’), age number not null check(age >=18 and age <=50), address varchar2(100)
这是什么问题 ?? RAD Studio
-
这是VC++.NET2005的问题吗?
 看一个程序:  class B{private:     virtual void f1(){};}; class D:public B{private:     void f1(){};     virtual void f2(){};}; void main(){  D d;} 通过Watch窗口查看
团体程序设计天梯赛L2-004 这是二叉搜索树吗?(数据结构)
思路:对于一颗合法的二叉搜索树,那么即满足对于区间[l,r],存在一个点i,a[l] #include #include #include using namespace std; const int maxn = 1005; int a[maxn]; int check1(int l,int r) { if(l>=r) return 1; int key = r; for(
这是个什么问题
哪位大神看到后给指点一下
求职被问“你还有什么问题要问吗?”该怎么办?
首先,你需要了解招聘公司的情况。弄清楚该公司现在在做什么事情,公司的利润如何,如此等等。此外,还要搞清楚面试人是谁,然后查查他们的资料。如果他们在网站上有自己的主页,你就能获得大量有关他们的信息,等到面试的时候就可以提出一些能给自己加分的问题。也许,你们就读的是同一所学校,也许那个人因工作搬迁了。这些因素都可能会帮到你。不过,切勿越过雷池,问面试考官很多私人方面的问题。   我对帕蒂的建议是
jeesite本地maven版缺少jar包解决方案
一些新用户通过maven下载jeesite依赖包时出错,缺少依赖的jar包,其实这些依赖的java包已经放到jeesite目录的Lib包下面了。大家只需要将pom.xml缺少的依赖包改成如下的方式就可以。 >${project.basedir}/lib/analyzer-2012_u6.jar                                         org.wlt