0

I have a rest web service, that retrives data from my sql database using hibernate technology. While running, the web sevice throws error below

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)

I dont get why this problem is coming. Please help.

1 Answer 1

0

A java.lang.NoClassDefFoundError: Could not initialize class XXX means that the class is found, but its initialization failed. Possible cause include:

  • missing dependent classes.
  • an exception thrown during execution of a static initialization block in the class.

Don't you get more info in the server logs? Any Caused by?

Providing the code of com.sample.restlet.HibernateSessionFactory might help too?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.