From: Steve L. (JIRA) <no...@at...> - 2006-01-16 09:00:38
|
NPE AbstractEntityTuplizer.createProxy(AbstractEntityTuplizer.java:372) when trying to load a class defined in a signed/sealed JAR ---------------------------------------------------------------------------------------------------------------------------------- Key: HHH-1365 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1365 Project: Hibernate3 Type: Bug Versions: 3.1 Environment: Java1.5.06 Ant1.7alpha, hibernate 3.1 Reporter: Steve Loughran Priority: Minor I'm testing what happens to hibernate when running against a signed JAR. The answer is: most tests pass. What fails is this test (Apache 2.0 license, BTW) public void testDetachedObject() throws Exception { Event event = createTestEvent(); session.save(event); session.flush(); closeSession(); //here the event is detached. //we change it outside an operation. String text = "modified"; event.setText(text); session = getSessionFactory().openSession(); Event merged=(Event) session.merge(event); assertEquals(event, merged); session.flush(); closeSession(); session = getSessionFactory().openSession(); Event loaded = (Event) session.load(Event.class, event.getKey()); assertEquals(text, loaded.getText()); assertEquals(event, loaded); } the session.load operation is failing, with the short stack trace of: java.lang.NullPointerException at org.hibernate.tuple.AbstractEntityTuplizer.createProxy(AbstractEntityTuplizer.java:372) at org.hibernate.persister.entity.AbstractEntityPersister.createProxy(AbstractEntityPersister.java:3121) at org.hibernate.event.def.DefaultLoadEventListener.createProxyIfNecessary(DefaultLoadEventListener.java:232) at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:173) at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:87) at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:869) at org.hibernate.impl.SessionImpl.load(SessionImpl.java:788) at org.hibernate.impl.SessionImpl.load(SessionImpl.java:781) at d1.persist.test.SessionTest.testDetachedObject(SessionTest.java:155) The root cause is probably contained in the info that gets printed when the session starts up, complaining that things cant be added to sealed classes [junit] 2261 ERROR org.hibernate.proxy.BasicLazyInitializer - CGLIB Enhancement failed: d1.persist.Event [junit] net.sf.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null [junit] at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:237) [junit] at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:377) [junit] at net.sf.cglib.proxy.Enhancer.createClass(Enhancer.java:317) [junit] at org.hibernate.proxy.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:126) [junit] at org.hibernate.proxy.CGLIBProxyFactory.postInstantiate(CGLIBProxyFactory.java:41) [junit] at org.hibernate.tuple.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:161) [junit] at org.hibernate.tuple.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:131) [junit] at org.hibernate.tuple.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:55) [junit] at org.hibernate.tuple.TuplizerLookup.create(TuplizerLookup.java:64) [junit] at org.hibernate.tuple.EntityMetamodel.<init>(EntityMetamodel.java:257) [junit] at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:412) [junit] at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:108) [junit] at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55) [junit] at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:215) [junit] at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1154) [junit] at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:375) [junit] at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:533) [junit] at org.hibernate.ejb.Ejb3Configuration.createFactory(Ejb3Configuration.java:109) [junit] at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:155) [junit] at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:82) [junit] at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:37) [junit] at d1.persist.PersistTools.createManagerFactory(PersistTools.java:82) [junit] at d1.persist.PersistTools.createDefaultManagerFactory(PersistTools.java:76) [junit] at d1.persist.test.Ejb3TestBase.setUp(Ejb3TestBase.java:27) [junit] at junit.framework.TestCase.runBare(TestCase.java:125) [junit] at junit.framework.TestResult$1.protect(TestResult.java:106) [junit] at junit.framework.TestResult.runProtected(TestResult.java:124) [junit] at junit.framework.TestResult.run(TestResult.java:109) [junit] at junit.framework.TestCase.run(TestCase.java:118) [junit] at junit.framework.TestSuite.runTest(TestSuite.java:208) [junit] at junit.framework.TestSuite.run(TestSuite.java:203) [junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:328) [junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:736) [junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:605) [junit] Caused by: java.lang.reflect.InvocationTargetException [junit] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [junit] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [junit] at java.lang.reflect.Method.invoke(Method.java:585) [junit] at net.sf.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:384) [junit] at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:219) [junit] ... 33 more [junit] Caused by: java.lang.SecurityException: class "d1.persist.Event$$EnhancerByCGLIB$$55c8eae8_2"'s signer information does not match signer information of other classes in the same package [junit] at java.lang.ClassLoader.checkCerts(ClassLoader.java:775) [junit] at java.lang.ClassLoader.preDefineClass(ClassLoader.java:487) [junit] at java.lang.ClassLoader.defineClass(ClassLoader.java:614) [junit] ... 39 more [junit] 2262 WARN org.hibernate.tuple.PojoEntityTuplizer - could not create proxy factory for:d1.persist.Event [junit] org.hibernate.HibernateException: CGLIB Enhancement failed: d1.persist.Event [junit] at org.hibernate.proxy.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:132) [junit] at org.hibernate.proxy.CGLIBProxyFactory.postInstantiate(CGLIBProxyFactory.java:41) [junit] at org.hibernate.tuple.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:161) [junit] at org.hibernate.tuple.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:131) [junit] at org.hibernate.tuple.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:55) [junit] at org.hibernate.tuple.TuplizerLookup.create(TuplizerLookup.java:64) [junit] at org.hibernate.tuple.EntityMetamodel.<init>(EntityMetamodel.java:257) [junit] at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:412) [junit] at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:108) [junit] at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55) [junit] at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:215) [junit] at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1154) [junit] at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:375) [junit] at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:533) [junit] at org.hibernate.ejb.Ejb3Configuration.createFactory(Ejb3Configuration.java:109) [junit] at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:155) [junit] at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:82) [junit] at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:37) [junit] at d1.persist.PersistTools.createManagerFactory(PersistTools.java:82) [junit] at d1.persist.PersistTools.createDefaultManagerFactory(PersistTools.java:76) [junit] at d1.persist.test.Ejb3TestBase.setUp(Ejb3TestBase.java:27) [junit] at junit.framework.TestCase.runBare(TestCase.java:125) [junit] at junit.framework.TestResult$1.protect(TestResult.java:106) [junit] at junit.framework.TestResult.runProtected(TestResult.java:124) [junit] at junit.framework.TestResult.run(TestResult.java:109) [junit] at junit.framework.TestCase.run(TestCase.java:118) [junit] at junit.framework.TestSuite.runTest(TestSuite.java:208) [junit] at junit.framework.TestSuite.run(TestSuite.java:203) [junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:328) [junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:736) [junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:605) [junit] Caused by: net.sf.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null [junit] at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:237) [junit] at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:377) [junit] at net.sf.cglib.proxy.Enhancer.createClass(Enhancer.java:317) [junit] at org.hibernate.proxy.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:126) [junit] ... 30 more [junit] Caused by: java.lang.reflect.InvocationTargetException [junit] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [junit] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [junit] at java.lang.reflect.Method.invoke(Method.java:585) [junit] at net.sf.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:384) [junit] at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:219) [junit] ... 33 more [junit] Caused by: java.lang.SecurityException: class "d1.persist.Event$$EnhancerByCGLIB$$55c8eae8_2"'s signer information does not match signer information of other classes in the same package [junit] at java.lang.ClassLoader.checkCerts(ClassLoader.java:775) [junit] at java.lang.ClassLoader.preDefineClass(ClassLoader.java:487) [junit] at java.lang.ClassLoader.defineClass(ClassLoader.java:614) [junit] ... 39 more No doubt there is some way to configure hibernate to create proxies in a different package, and I shall seek that option out. All I want to note here is that NPEs are not the best way to report failure. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |