Bhushan
Bhushan

Reputation: 287

java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer

when i am trying to request to Rest service at time of response it getting exception..

Feb 21, 2013 2:34:49 PM com.sun.jersey.spi.container.ContainerResponse mapMappableContainerException
SEVERE: The exception contained within MappableContainerException could not be mapped to a response, re-throwing to the HTTP container
java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer
    at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:117)
    at org.hibernate.proxy.pojo.cglib.CGLIBProxyFactory.postInstantiate(CGLIBProxyFactory.java:43)
    at org.hibernate.tuple.entity.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:162)
    at org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:135)
    at org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:55)
    at org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.<init>(EntityEntityModeToTuplizerMapping.java:56)
    at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:302)
    at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:434)
    at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:109)
    at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
    at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:226)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1300)
    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:713)
    at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:121)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:52)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:34)
    at de.vogella.jpa.simple.main.Main.getObj(Main.java:18)
    at com.poshs.webapp.MyResource.setIt(MyResource.java:43)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)

this result i get after run mvn dependency:tree

[INFO] +- com.sun.jersey:jersey-server:jar:1.8:compile 
[INFO] |  +- asm:asm:jar:3.1:compile
[INFO] |  \- com.sun.jersey:jersey-core:jar:1.8:compile
[INFO] +- com.sun.jersey:jersey-json:jar:1.8:compile
[INFO] |  +- org.codehaus.jettison:jettison:jar:1.1:compile
[INFO] |  |  \- stax:stax-api:jar:1.0.1:compile
[INFO] |  +- com.sun.xml.bind:jaxb-impl:jar:2.2.3-1:compile
[INFO] |  |  \- javax.xml.bind:jaxb-api:jar:2.2.2:compile
[INFO] |  |     +- javax.xml.stream:stax-api:jar:1.0-2:compile
[INFO] |  |     \- javax.activation:activation:jar:1.1:compile
[INFO] |  +- org.codehaus.jackson:jackson-core-asl:jar:1.7.1:compile
[INFO] |  +- org.codehaus.jackson:jackson-mapper-asl:jar:1.7.1:compile
[INFO] |  +- org.codehaus.jackson:jackson-jaxrs:jar:1.7.1:compile
[INFO] |  \- org.codehaus.jackson:jackson-xc:jar:1.7.1:compile
[INFO] +- junit:junit:jar:4.8.2:test
[INFO] +- com.sun.jersey:jersey-client:jar:1.8:test
[INFO] +- org.glassfish.distributions:web-all:jar:10.0-build-20080430:test
[INFO] +- org.glassfish.embedded:gf-embedded-api:jar:1.0-alpha-4:test
[INFO] |  +- org.glassfish.api:dtds:jar:resources:9.0.2:test
[INFO] |  \- org.glassfish.api:schemas:jar:resources:9.0.2:test
[INFO] +- org.apache.httpcomponents:httpclient:jar:4.0-alpha4:compile
[INFO] |  +- org.apache.httpcomponents:httpcore:jar:4.0-beta1:compile
[INFO] |  \- commons-codec:commons-codec:jar:1.3:compile
[INFO] +- com.google.code.gson:gson:jar:2.2.2:compile
[INFO] +- org.apache.openejb:commons-dbcp-all:jar:1.3-r699049:compile
[INFO] +- org.apache.directory.studio:org.apache.commons.pool:jar:1.6:compile
[INFO] |  \- commons-pool:commons-pool:jar:1.6:compile
[INFO] +- org.nuiton.thirdparty:asm-attrs:jar:1.5.4-snapshot:compile
[INFO] +- org.sonatype.sisu.inject:cglib:jar:2.2.2:compile
[INFO] +- org.jvnet.hudson.dom4j:dom4j:jar:1.6.1-hudson-3:compile
[INFO] +- org.hibernate:ejb3-persistence:pom:3.3.2.Beta1:compile
[INFO] +- org.hibernate:hibernate:jar:3.2.6.ga:compile
[INFO] |  +- net.sf.ehcache:ehcache:jar:1.2.3:compile
[INFO] |  +- javax.transaction:jta:jar:1.0.1B:compile
[INFO] |  +- asm:asm-attrs:jar:1.5.3:compile
[INFO] |  +- dom4j:dom4j:jar:1.6.1:compile
[INFO] |  +- antlr:antlr:jar:2.7.6:compile
[INFO] |  \- cglib:cglib:jar:2.1_3:compile
[INFO] +- org.hibernate:hibernate-annotations:jar:3.2.1.ga:compile
[INFO] |  \- javax.persistence:persistence-api:jar:1.0:compile
[INFO] +- org.hibernate:hibernate-commons-annotations:jar:3.0.0.ga:compile
[INFO] +- org.hibernate:hibernate-entitymanager:jar:3.2.1.ga:compile
[INFO] |  +- jboss:javassist:jar:3.3.ga:compile
[INFO] |  \- jboss:jboss-archive-browsing:jar:5.0.0alpha-200607201-119:compile
[INFO] +- org.hibernate:hibernate-validator-annotation-processor:jar:5.0.0.Beta1:compile
[INFO] +- commons-beanutils:commons-beanutils-bean-collections:jar:1.8.3:compile
[INFO] +- jboss:jboss-common:jar:4.2.2.GA:compile
[INFO] +- javassist:javassist:jar:3.12.1.GA:compile
[INFO] +- hibernate:hibernate-entitymanager:pom:3.4.0.GA:compile
[INFO] |  +- org.hibernate:ejb3-persistence:jar:1.0.2.GA:compile
[INFO] |  \- org.hibernate:hibernate-core:jar:3.3.0.SP1:compile
[INFO] +- org.hibernate:hibernate-validator:jar:5.0.0.Beta1:compile
[INFO] |  +- javax.validation:validation-api:jar:1.1.0.Beta3:compile
[INFO] |  +- org.jboss.logging:jboss-logging:jar:3.1.1.GA:compile
[INFO] |  +- com.fasterxml:classmate:jar:0.8.0:compile
[INFO] |  +- de.odysseus.juel:juel-spi:jar:2.2.5:compile
[INFO] |  +- de.odysseus.juel:juel-api:jar:2.2.5:compile
[INFO] |  \- de.odysseus.juel:juel-impl:jar:2.2.5:compile
[INFO] +- commons-collections:commons-collections:jar:3.1:compile
[INFO] +- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] +- org.slf4j:slf4j-api:jar:1.7.2:compile
[INFO] +- org.slf4j:slf4j-simple:jar:1.7.2:compile
[INFO] +- com.google.sitebricks:slf4j:jar:0.8.3:compile
[INFO] |  \- com.google.inject:guice:jar:2.0:compile
[INFO] |     \- aopalliance:aopalliance:jar:1.0:compile
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.7.2:compile
[INFO] |  \- log4j:log4j:jar:1.2.17:compile
[INFO] +- postgresql:postgresql:jar:9.1-901.jdbc4:compile
[INFO] +- com.tunnelvisionlabs:antlr4:jar:4.0:compile
[INFO] |  +- com.tunnelvisionlabs:antlr4-runtime:jar:4.0:compile
[INFO] |  |  \- org.abego.treelayout:org.abego.treelayout.core:jar:1.0.1:compile
[INFO] |  +- org.antlr:antlr-runtime:jar:3.5:compile
[INFO] |  |  \- org.antlr:stringtemplate:jar:3.2.1:compile
[INFO] |  \- org.antlr:ST4:jar:4.0.7:compile
[INFO] +- cglib:cglib-nodep:jar:2.2.2:compile
[INFO] +- org.ow2.asm:asm:jar:4.1:compile
[INFO] \- org.ow2.asm:asm-util:jar:4.1:compile
[INFO]    \- org.ow2.asm:asm-tree:jar:4.1:compile

This is get after run the mvn dependency:tree , i have checked my dependency for cglib but i not sure for version compatible, kindly check let me know which are compatible for my project.

Thanks

Upvotes: 0

Views: 12298

Answers (4)

Mithun
Mithun

Reputation: 1

I fixed this issue by removing the glib dependency from pom as some other libraries have it internally, so if you see the dependencies or library jars, you will find more than one cglib jar.

Upvotes: 0

Samuel EUSTACHI
Samuel EUSTACHI

Reputation: 3156

You probably miss a jar, for cglib.

When does this happen (unitTest, deployed)? How do you build your project (Maven, ant ) ? Which version of Hibernate ? Hard to help you without some info.

EDIT : try to run mvn dependency:tree and post the result here, we should see what's wrong

EDIT : you have 2 versions of cglib. You should not manually include cglib as it is already included by hibernate as a transitive dependency.

Upvotes: 1

Adalarasan_Serangulam
Adalarasan_Serangulam

Reputation: 728

You something missed on the class path. So that is why it showing "MappableContainerException" . This exception is related to the DB manager. So could you please stop your server,clean and redeploy it. Thanks.

Upvotes: 0

Romin
Romin

Reputation: 8816

Just check how many cglib JARs you have in your project. Try to ensure that for your project + framework versions, you have the required cglib JAR and not some extra ones floating around.

Upvotes: 0

Related Questions