首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

用AnnotationSessionFactoryBean生成sessionFactory时报错不能创设sessionFactoyBean(转)

2013-09-11 
用AnnotationSessionFactoryBean生成sessionFactory时报错不能创建sessionFactoyBean(转)报错信息:[junit]

用AnnotationSessionFactoryBean生成sessionFactory时报错不能创建sessionFactoyBean(转)

报错信息:

[junit] Testcase: testCreateFileInfo(springmp3.service.FileDaoImplTests):Caused an ERROR
??? [junit] Error creating bean with name 'sessionFactory' defined in URL [applicationContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/dom4j/DocumentException
??? [junit] org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in URL [applicationContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/dom4j/DocumentException
??? [junit] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:813)
??? [junit] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:769)
??? [junit] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:412)
??? [junit] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:383)
??? [junit] at java.security.AccessController.doPrivileged(Native Method)

spring配置信息:

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="annotatedClasses">
<list>
<value>domain.FileInfo</value>
</list>
</property>

DAO方法:

public class FileDaoImplTests extends AbstractTransactionalDataSourceSpringContextTests {


?? public void testCreateFileInfo() throws Exception{
???????
?? FileInfo inf = new FileInfo();
?? // Arbitrary test information for this "file"
?? inf.setFilename("FILE NAME");
?? inf.setTitle("TITLE");
?? inf.setComment("TEST COMMENT");
??
?? assertNull("ID shall not be zero",inf.getId());
??
??
?? FileDaoImpl dao = new FileDaoImpl();
?? // making the fileinfo persistent in database:
?? Integer res = dao.SaveFileInfo(inf);
?? assertTrue("wrong result by FileDaoImpl",res.intValue()>0);
?? assertNotNull("ID must be non-zero",inf.getId());
?? }
??
??? @Override
??? protected String[] getConfigLocations() {
??????? return new String[]{"applicationContext.xml"};
??? }
}

原因是我没有导入spring_home\lib\dom4j\下的dom4j.jar和jta.jar,导入即可!


我的异常网推荐解决方案:org.springframework.beans.factory.BeanCreationException:,http://www.myexception.cn/j2ee/10759.html

热点排行