Java,Hibernate - 运行现有项目时发生运行时异常

时间:2014-05-11 06:09:49

标签: java spring hibernate

当我尝试运行现有项目时,会出现以下异常。任何指针都非常有用。

Exception in thread "Thread-5" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in ServletContext resource [/WEB-INF/app_config/applicationContext-dao.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.hibernate3.HibernateTransactionManager]: Constructor threw exception; nested exception is java.lang.NullPointerException
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.j
ava:965)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactor
y.java:898)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java
:485)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:4
56)
        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:194)
        at org.springframework.transaction.interceptor.TransactionAspectSupport.determineTransactionManager(TransactionAspectSupport.java:24
8)
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:100)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:621)
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.hibernate3.Hibern
ateTransactionManager]: Constructor threw exception; nested exception is java.lang.NullPointerException
        at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:74)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:958)                                                                                                                  48535,34      97%
Caused by: java.lang.NullPointerException
        at org.apache.commons.logging.LogFactory.getCachedFactory(LogFactory.java:979)
        at org.apache.commons.logging.LogFactory.getFactory(LogFactory.java:435)                                          48536,34      97%
        at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:685)
                                                                                                                          48573,27-34   97%

下面是bean的定义方式

<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory" />
    </bean>

2 个答案:

答案 0 :(得分:1)

http://commons.apache.org/proper/commons-logging/apidocs/org/apache/commons/logging/LogFactory.html#getFactory()

查看链接。它需要commons-logging.properties你在classpath中有这样的文件吗?

答案 1 :(得分:0)

找不到bean类并返回nullpointerexception。

检查所有类和包名是否为真,并检查您的app'sname.hbm.xml文件是否为true。你必须把你在app'sname区域运行的类名。

并检查您将app'sname.hbm.xml文件映射到hibernate.cfg.xml文件