我有一个休息的Web服务,它使用hibernate技术从我的sql数据库中恢复数据。在运行时,Web服务会抛出错误
java.lang.NoClassDefFoundError: Could not initialize class com.sample.restlet.HibernateSessionFactory com.sample.restlet.EmployeeResource.(EmployeeResource.java:22) sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) java.lang.reflect.Constructor.newInstance(Unknown Source) java.lang.Class.newInstance0(Unknown Source) java.lang.Class.newInstance(Unknown Source) com.sun.jersey.server.spi.component.ResourceComponentConstructor._construct(ResourceComponentConstructor.java:158) com.sun.jersey.server.spi.component.ResourceComponentConstructor.construct(ResourceComponentConstructor.java:148) com.sun.jersey.server.impl.resource.PerRequestFactory$PerRequest._getInstance(PerRequestFactory.java:175) com.sun.jersey.server.impl.resource.PerRequestFactory$AbstractPerRequest.getInstance(PerRequestFactory.java:132) com.sun.jersey.server.impl.application.WebApplicationContext.getResource(WebApplicationContext.java:160) com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:64) com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:111) com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:63) com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:543) com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:502) com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:493) com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:308) com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:314) com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:239)
我不明白为什么会出现这个问题。请帮忙。
答案 0 :(得分:0)
java.lang.NoClassDefFoundError: Could not initialize class XXX
表示找到了类,但初始化失败。可能的原因包括:
您是否在服务器日志中获得更多信息?任何Caused by
?
提供com.sample.restlet.HibernateSessionFactory
的代码也可能会有所帮助吗?