See here:
http://wikis.sun.com/display/Jersey/Resolving+ASM+dependency+issues+with+Jersey+and+Hibernate
It is a problem with asm version incompatibilities.
Paul.
On Sep 9, 2008, at 4:12 PM, glassfish_at_javadesktop.org wrote:
> Hi, i'm new on Java, i was working in a small application using
> RESTful web services (using annotations) and doing all the
> persistence stuff by myself, now the application has grown and i
> want to use JPA (Hibernate) but i can not get it to work...
>
> I'm using NetBeans IDE 6.1 and deploying on Tomcat 6.0. I first
> tried the simple way, just by creating the Entity Classes with the
> wizard and then creating the RESTful web services based on those
> entities also using the wizards, ...but when i run the services i
> have the following error:
>
> javax.servlet.ServletException:
> com.sun.jersey.api.container.ContainerException:
> java.lang.NoClassDefFoundError: Could not initialize class
> org.hibernate.ejb.Ejb3Configuration
> org
> .hibernate
> .ejb
> .HibernatePersistence
> .createEntityManagerFactory(HibernatePersistence.java:124)
>
> javax
> .persistence.Persistence.createEntityManagerFactory(Persistence.java:
> 52)
>
> javax
> .persistence.Persistence.createEntityManagerFactory(Persistence.java:
> 34)
> service.PersistenceService.<init>(PersistenceService.java:37)
> service.PersistenceService.<init>(PersistenceService.java:23)
> service.PersistenceService$1.initialValue(PersistenceService.java:28)
> service.PersistenceService$1.initialValue(PersistenceService.java:26)
> java.lang.ThreadLocal.setInitialValue(Unknown Source)
> java.lang.ThreadLocal.get(Unknown Source)
> service.PersistenceService.getInstance(PersistenceService.java:54)
> service.UserResource.get(UserResource.java:62)
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> java.lang.reflect.Method.invoke(Unknown Source)
>
> com.sun.jersey.impl.model.method.dispatch.EntityParamDispatchProvider
> $TypeOutInvoker._dispatch(EntityParamDispatchProvider.java:131)
>
> com
> .sun
> .jersey
> .impl
> .model
> .method
> .dispatch
> .ResourceJavaMethodDispatcher
> .dispatch(ResourceJavaMethodDispatcher.java:81)
>
> com
> .sun.jersey.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:
> 133)
>
> com
> .sun.jersey.impl.uri.rules.SubLocatorRule.accept(SubLocatorRule.java:
> 87)
>
> com
> .sun
> .jersey
> .impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:111)
>
> com
> .sun
> .jersey
> .impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:71)
>
> com
> .sun
> .jersey
> .impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:111)
>
> com
> .sun
> .jersey
> .impl
> .uri
> .rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:64)
>
> com
> .sun
> .jersey
> .impl
> .application
> .WebApplicationImpl.handleRequest(WebApplicationImpl.java:669)
>
> com
> .sun
> .jersey
> .impl
> .application
> .WebApplicationImpl.handleRequest(WebApplicationImpl.java:631)
>
> com
> .sun
> .jersey
> .spi
> .container.servlet.ServletContainer.service(ServletContainer.java:291)
> javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>
> Then i tried to use Hibernate without annotations (mapping with hbm
> files) and the test works but when i put the same code inside a Web
> Service and i call it from the browser i have this error:
>
> java.lang.NoClassDefFoundError: Could not initialize class
> de.javalog.beans.HibernateUtil
> services.TestService.get(TestService.java:36)
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> java.lang.reflect.Method.invoke(Unknown Source)
> com.sun.jersey.impl.model.method.dispatch.EntityParamDispatchProvider
> $TypeOutInvoker._dispatch(EntityParamDispatchProvider.java:131)
> com
> .sun
> .jersey
> .impl
> .model
> .method
> .dispatch
> .ResourceJavaMethodDispatcher
> .dispatch(ResourceJavaMethodDispatcher.java:81)
> com
> .sun.jersey.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:
> 133)
> com
> .sun
> .jersey
> .impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:71)
> com
> .sun
> .jersey
> .impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:111)
> com
> .sun
> .jersey
> .impl
> .uri
> .rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:64)
> com
> .sun
> .jersey
> .impl
> .application
> .WebApplicationImpl.handleRequest(WebApplicationImpl.java:669)
> com
> .sun
> .jersey
> .impl
> .application
> .WebApplicationImpl.handleRequest(WebApplicationImpl.java:631)
> com
> .sun
> .jersey
> .spi
> .container.servlet.ServletContainer.service(ServletContainer.java:291)
> javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>
> More details:
>
> java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.<init>(Z)V
> net
> .sf.cglib.core.DebuggingClassWriter.<init>(DebuggingClassWriter.java:
> 47)
> net
> .sf
> .cglib
> .core
> .DefaultGeneratorStrategy
> .getClassWriter(DefaultGeneratorStrategy.java:30)
> net
> .sf
> .cglib
> .core
> .DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:24)
> net
> .sf
> .cglib
> .core.AbstractClassGenerator.create(AbstractClassGenerator.java:216)
> net.sf.cglib.core.KeyFactory$Generator.create(KeyFactory.java:145)
> net.sf.cglib.core.KeyFactory.create(KeyFactory.java:117)
> net.sf.cglib.core.KeyFactory.create(KeyFactory.java:108)
> net.sf.cglib.core.KeyFactory.create(KeyFactory.java:104)
> net.sf.cglib.proxy.Enhancer.<clinit>(Enhancer.java:69)
> org
> .hibernate
> .proxy
> .pojo
> .cglib
> .CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:117)
> org
> .hibernate
> .proxy
> .pojo.cglib.CGLIBProxyFactory.postInstantiate(CGLIBProxyFactory.java:
> 43)
> org
> .hibernate
> .tuple
> .entity.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:
> 162)
> org
> .hibernate
> .tuple
> .entity.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:135)
> org
> .hibernate
> .tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:55)
> org
> .hibernate
> .tuple
> .entity
> .EntityEntityModeToTuplizerMapping
> .<init>(EntityEntityModeToTuplizerMapping.java:56)
> org
> .hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:
> 295)
> org
> .hibernate
> .persister
> .entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:
> 434)
> org
> .hibernate
> .persister
> .entity
> .SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:
> 109)
> org
> .hibernate
> .persister
> .PersisterFactory.createClassPersister(PersisterFactory.java:55)
> org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:
> 226)
> org
> .hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:
> 1294)
> de.javalog.beans.HibernateUtil.<clinit>(HibernateUtil.java:24)
> services.TestService.get(TestService.java:36)
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> java.lang.reflect.Method.invoke(Unknown Source)
> com.sun.jersey.impl.model.method.dispatch.EntityParamDispatchProvider
> $TypeOutInvoker._dispatch(EntityParamDispatchProvider.java:131)
> com
> .sun
> .jersey
> .impl
> .model
> .method
> .dispatch
> .ResourceJavaMethodDispatcher
> .dispatch(ResourceJavaMethodDispatcher.java:81)
> com
> .sun.jersey.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:
> 133)
> com
> .sun
> .jersey
> .impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:71)
> com
> .sun
> .jersey
> .impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:111)
> com
> .sun
> .jersey
> .impl
> .uri
> .rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:64)
> com
> .sun
> .jersey
> .impl
> .application
> .WebApplicationImpl.handleRequest(WebApplicationImpl.java:669)
> com
> .sun
> .jersey
> .impl
> .application
> .WebApplicationImpl.handleRequest(WebApplicationImpl.java:631)
> com
> .sun
> .jersey
> .spi
> .container.servlet.ServletContainer.service(ServletContainer.java:291)
> javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>
> This is the source code of my HibernateUtil class:
>
> import org.hibernate.cfg.Configuration;
> import org.hibernate.SessionFactory;
>
> public class HibernateUtil {
> private static final SessionFactory sessionFactory;
>
> static {
> try {
> sessionFactory = new
> Configuration().configure("hibernate.cfg.xml").buildSessionFactory();
> } catch (Throwable ex) {
> // Log the exception.
> System.err.println("Initial SessionFactory creation failed." + ex);
> throw new ExceptionInInitializerError(ex);
> }
> }
>
> public static SessionFactory getSessionFactory() {
> return sessionFactory;
> }
> }
>
> What i'm doing wrong?
> Any suggestion?
> [Message sent by forum member 'zeven' (zeven)]
>
> http://forums.java.net/jive/thread.jspa?messageID=298063
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>