java.lang.NoClassDefFoundError: net/sf/hibernate/cfg/NamingStrategy

only發表於2006-01-18
spring1 + struts1 + hibernate2
我就用這兩句話來測試是否db連線成功.
ApplicationContext ctx = new FileSystemXmlApplicationContext("D:/eclipse/workspace/TestWeb/WebContent/WEB-INF/applicationContext.xml");
SessionFactory sf = (SessionFactory)ctx.getBean("sessionFactory");
出來這個錯誤, java.lang.NoClassDefFoundError: net/sf/hibernate/cfg/NamingStrategy不知道什麼原因??
?

log4j:WARN No appenders could be found for logger (org.springframework.beans.factory.xml.XmlBeanDefinitionReader).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in file [D:\eclipse\workspace\TestWeb\WebContent\WEB-INF\applicationContext.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: net/sf/hibernate/cfg/NamingStrategy
java.lang.NoClassDefFoundError: net/sf/hibernate/cfg/NamingStrategy
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2365)
at java.lang.Class.getDeclaredMethods(Class.java:1763)
at java.beans.Introspector$1.run(Introspector.java:1265)
at java.security.AccessController.doPrivileged(Native Method)
at java.beans.Introspector.getPublicDeclaredMethods(Introspector.java:1263)
at java.beans.Introspector.getTargetMethodInfo(Introspector.java:1129)
at java.beans.Introspector.getBeanInfo(Introspector.java:387)
at java.beans.Introspector.getBeanInfo(Introspector.java:159)
at org.springframework.beans.CachedIntrospectionResults.<init>(CachedIntrospectionResults.java:137)
at org.springframework.beans.CachedIntrospectionResults.forClass(CachedIntrospectionResults.java:79)
at org.springframework.beans.BeanWrapperImpl.setWrappedInstance(BeanWrapperImpl.java:226)
at org.springframework.beans.BeanWrapperImpl.setWrappedInstance(BeanWrapperImpl.java:208)
at org.springframework.beans.BeanWrapperImpl.<init>(BeanWrapperImpl.java:171)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:217)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:177)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:159)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:177)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:268)
at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:60)
at com.test1.TestMain.main(TestMain.java:24)

相關文章