java.lang.NullPointerException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • A runnable example is attached. Here is its output: INFO : org.hibernate.cfg.Environment - Hibernate 3.0.5 INFO : org.hibernate.cfg.Environment - hibernate.properties not found INFO : org.hibernate.cfg.Environment - using CGLIB reflection optimizer INFO : org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling INFO : org.hibernate.cfg.Configuration - configuring from resource: /hibernate.cfg.xml INFO : org.hibernate.cfg.Configuration - Configuration resource: /hibernate.cfg.xml INFO : org.hibernate.cfg.Configuration - Mapping resource: PrivateNullConstructor.hbm.xml INFO : org.hibernate.cfg.HbmBinder - Mapping class: classesThatCauseTheBug.PrivateNullConstructor -> table1 INFO : org.hibernate.cfg.Configuration - Mapping resource: FinalClass.hbm.xml INFO : org.hibernate.cfg.HbmBinder - Mapping class: classesThatCauseTheBug.FinalClass -> table2 INFO : org.hibernate.cfg.Configuration - Configured SessionFactory: null INFO : org.hibernate.cfg.Configuration - processing extends queue INFO : org.hibernate.cfg.Configuration - processing collection mappings INFO : org.hibernate.cfg.Configuration - processing association property references INFO : org.hibernate.cfg.Configuration - processing foreign key constraints INFO : org.hibernate.connection.DriverManagerConnectionProvider - Using Hibernate built-in connection pool (not for production use!) INFO : org.hibernate.connection.DriverManagerConnectionProvider - Hibernate connection pool size: 1 INFO : org.hibernate.connection.DriverManagerConnectionProvider - autocommit mode: false INFO : org.hibernate.connection.DriverManagerConnectionProvider - using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost/pledgetally INFO : org.hibernate.connection.DriverManagerConnectionProvider - connection properties: {user=pledgetallyuser, password=****} INFO : org.hibernate.cfg.SettingsFactory - RDBMS: MySQL, version: 4.0.21 INFO : org.hibernate.cfg.SettingsFactory - JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-3.1.9 ( $Date: 2005/05/19 15:52:23 $, $Revision: 1.1.2.2 $ ) INFO : org.hibernate.dialect.Dialect - Using dialect: org.hibernate.dialect.MySQLDialect INFO : org.hibernate.transaction.TransactionFactoryFactory - Using default transaction strategy (direct JDBC transactions) INFO : org.hibernate.transaction.TransactionManagerLookupFactory - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended) INFO : org.hibernate.cfg.SettingsFactory - Automatic flush during beforeCompletion(): disabled INFO : org.hibernate.cfg.SettingsFactory - Automatic session close at end of transaction: disabled INFO : org.hibernate.cfg.SettingsFactory - JDBC batch size: 15 INFO : org.hibernate.cfg.SettingsFactory - JDBC batch updates for versioned data: disabled INFO : org.hibernate.cfg.SettingsFactory - Scrollable result sets: enabled INFO : org.hibernate.cfg.SettingsFactory - JDBC3 getGeneratedKeys(): enabled INFO : org.hibernate.cfg.SettingsFactory - Connection release mode: null INFO : org.hibernate.cfg.SettingsFactory - Maximum outer join fetch depth: 2 INFO : org.hibernate.cfg.SettingsFactory - Default batch fetch size: 1 INFO : org.hibernate.cfg.SettingsFactory - Generate SQL with comments: disabled INFO : org.hibernate.cfg.SettingsFactory - Order SQL updates by primary key: disabled INFO : org.hibernate.cfg.SettingsFactory - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory INFO : org.hibernate.hql.ast.ASTQueryTranslatorFactory - Using ASTQueryTranslatorFactory INFO : org.hibernate.cfg.SettingsFactory - Query language substitutions: {} INFO : org.hibernate.cfg.SettingsFactory - Second-level cache: enabled INFO : org.hibernate.cfg.SettingsFactory - Query cache: disabled INFO : org.hibernate.cfg.SettingsFactory - Cache provider: org.hibernate.cache.EhCacheProvider INFO : org.hibernate.cfg.SettingsFactory - Optimize cache for minimal puts: disabled INFO : org.hibernate.cfg.SettingsFactory - Structured second-level cache entries: disabled INFO : org.hibernate.cfg.SettingsFactory - Echoing all SQL to stdout INFO : org.hibernate.cfg.SettingsFactory - Statistics: disabled INFO : org.hibernate.cfg.SettingsFactory - Deleted entity synthetic identifier rollback: disabled INFO : org.hibernate.cfg.SettingsFactory - Default entity-mode: pojo INFO : org.hibernate.impl.SessionFactoryImpl - building session factory WARN : net.sf.ehcache.config.Configurator - No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/home/pcantrel/workspace/HHH471TestCaseToMakeGavinHappy/lib/ehcache-1.1.jar!/ehcache-failsafe.xml ERROR: org.hibernate.proxy.BasicLazyInitializer - CGLIB Enhancement failed: classesThatCauseTheBug.FinalClass java.lang.IllegalArgumentException: Cannot subclass final class class classesThatCauseTheBug.FinalClass at net.sf.cglib.proxy.Enhancer.generateClass(Enhancer.java:442) at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25) at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:215) at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:373) at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:281) at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:640) at org.hibernate.proxy.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:94) at org.hibernate.proxy.CGLIBProxyFactory.postInstantiate(CGLIBProxyFactory.java:42) at org.hibernate.tuple.PojoTuplizer.buildProxyFactory(PojoTuplizer.java:144) at org.hibernate.tuple.AbstractTuplizer.<init>(AbstractTuplizer.java:83) at org.hibernate.tuple.PojoTuplizer.<init>(PojoTuplizer.java:54) at org.hibernate.tuple.TuplizerLookup.create(TuplizerLookup.java:47) at org.hibernate.tuple.EntityMetamodel.<init>(EntityMetamodel.java:218) at org.hibernate.persister.entity.BasicEntityPersister.<init>(BasicEntityPersister.java:400) at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:104) at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55) at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:211) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1005) at Main.main(Main.java:10) WARN : org.hibernate.tuple.PojoTuplizer - could not create proxy factory for:classesThatCauseTheBug.FinalClass org.hibernate.HibernateException: CGLIB Enhancement failed: classesThatCauseTheBug.FinalClass at org.hibernate.proxy.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:108) at org.hibernate.proxy.CGLIBProxyFactory.postInstantiate(CGLIBProxyFactory.java:42) at org.hibernate.tuple.PojoTuplizer.buildProxyFactory(PojoTuplizer.java:144) at org.hibernate.tuple.AbstractTuplizer.<init>(AbstractTuplizer.java:83) at org.hibernate.tuple.PojoTuplizer.<init>(PojoTuplizer.java:54) at org.hibernate.tuple.TuplizerLookup.create(TuplizerLookup.java:47) at org.hibernate.tuple.EntityMetamodel.<init>(EntityMetamodel.java:218) at org.hibernate.persister.entity.BasicEntityPersister.<init>(BasicEntityPersister.java:400) at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:104) at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55) at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:211) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1005) at Main.main(Main.java:10) Caused by: java.lang.IllegalArgumentException: Cannot subclass final class class classesThatCauseTheBug.FinalClass at net.sf.cglib.proxy.Enhancer.generateClass(Enhancer.java:442) at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25) at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:215) at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:373) at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:281) at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:640) at org.hibernate.proxy.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:94) ... 12 more ERROR: org.hibernate.proxy.BasicLazyInitializer - CGLIB Enhancement failed: classesThatCauseTheBug.PrivateNullConstructor java.lang.IllegalArgumentException: Superclass has no null constructors but no arguments were given at net.sf.cglib.proxy.Enhancer.emitConstructors(Enhancer.java:682) at net.sf.cglib.proxy.Enhancer.generateClass(Enhancer.java:494) at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25) at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:215) at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:373) at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:281) at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:640) at org.hibernate.proxy.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:94) at org.hibernate.proxy.CGLIBProxyFactory.postInstantiate(CGLIBProxyFactory.java:42) at org.hibernate.tuple.PojoTuplizer.buildProxyFactory(PojoTuplizer.java:144) at org.hibernate.tuple.AbstractTuplizer.<init>(AbstractTuplizer.java:83) at org.hibernate.tuple.PojoTuplizer.<init>(PojoTuplizer.java:54) at org.hibernate.tuple.TuplizerLookup.create(TuplizerLookup.java:47) at org.hibernate.tuple.EntityMetamodel.<init>(EntityMetamodel.java:218) at org.hibernate.persister.entity.BasicEntityPersister.<init>(BasicEntityPersister.java:400) at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:104) at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55) at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:211) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1005) at Main.main(Main.java:10) WARN : org.hibernate.tuple.PojoTuplizer - could not create proxy factory for:classesThatCauseTheBug.PrivateNullConstructor org.hibernate.HibernateException: CGLIB Enhancement failed: classesThatCauseTheBug.PrivateNullConstructor at org.hibernate.proxy.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:108) at org.hibernate.proxy.CGLIBProxyFactory.postInstantiate(CGLIBProxyFactory.java:42) at org.hibernate.tuple.PojoTuplizer.buildProxyFactory(PojoTuplizer.java:144) at org.hibernate.tuple.AbstractTuplizer.<init>(AbstractTuplizer.java:83) at org.hibernate.tuple.PojoTuplizer.<init>(PojoTuplizer.java:54) at org.hibernate.tuple.TuplizerLookup.create(TuplizerLookup.java:47) at org.hibernate.tuple.EntityMetamodel.<init>(EntityMetamodel.java:218) at org.hibernate.persister.entity.BasicEntityPersister.<init>(BasicEntityPersister.java:400) at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:104) at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55) at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:211) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1005) at Main.main(Main.java:10) Caused by: java.lang.IllegalArgumentException: Superclass has no null constructors but no arguments were given at net.sf.cglib.proxy.Enhancer.emitConstructors(Enhancer.java:682) at net.sf.cglib.proxy.Enhancer.generateClass(Enhancer.java:494) at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25) at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:215) at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:373) at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:281) at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:640) at org.hibernate.proxy.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:94) ... 12 more INFO : org.hibernate.impl.SessionFactoryObjectFactory - Not binding factory to JNDI, no JNDI name configured INFO : org.hibernate.impl.SessionFactoryImpl - Checking 0 named queries Trying to load FinalClass... java.lang.NullPointerException at org.hibernate.tuple.AbstractTuplizer.createProxy(AbstractTuplizer.java:249) at org.hibernate.persister.entity.BasicEntityPersister.createProxy(BasicEntityPersister.java:2831) at org.hibernate.event.def.DefaultLoadEventListener.createProxyIfNecessary(DefaultLoadEventListener.java:218) at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:163) at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:79) at org.hibernate.impl.SessionImpl.load(SessionImpl.java:603) at org.hibernate.impl.SessionImpl.load(SessionImpl.java:596) at Main.main(Main.java:17) Trying to load PrivateNullConstructor... java.lang.NullPointerException at org.hibernate.tuple.AbstractTuplizer.createProxy(AbstractTuplizer.java:249) at org.hibernate.persister.entity.BasicEntityPersister.createProxy(BasicEntityPersister.java:2831) at org.hibernate.event.def.DefaultLoadEventListener.createProxyIfNecessary(DefaultLoadEventListener.java:218) at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:163) at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:79) at org.hibernate.impl.SessionImpl.load(SessionImpl.java:603) at org.hibernate.impl.SessionImpl.load(SessionImpl.java:596) at Main.main(Main.java:27)
    via by Paul Cantrell,
  • Hibernate cannot proxy final classes, or classes with private null constructors. Proxying is enabled by default in Hibernate 3. The result of this is that an innocent attempt to map a class of this kind generates an error -- which is expected behavior. However, the error Hibernate generates is supremely unhelpful, and looks for all the world like a bug in Hibernate: java.lang.NullPointerException at org.hibernate.tuple.AbstractTuplizer.createProxy(AbstractTuplizer.java:249) at org.hibernate.persister.entity.BasicEntityPersister.createProxy(BasicEntityPersister.java:2831) at org.hibernate.event.def.DefaultLoadEventListener.createProxyIfNecessary(DefaultLoadEventListener.java:218) at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:163) at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:79) at org.hibernate.impl.SessionImpl.load(SessionImpl.java:603) at org.hibernate.impl.SessionImpl.load(SessionImpl.java:596) (See HHH-685 for code to reproduce this stack trace.) At least six Hibernate users (including me) thought this was a bug, and voted for it as HHH-471. There are two much more reasonable behaviors Hibernate could have: (1) Disable proxying for the class, and issue a warning: WARN: com.whatever.FinalClass is declared final; proxying is disabled ...OR... (2) Issue a meaningful error message instead of the NPE: HibernateMappingException: com.whatever.FinalClass is declared final; disable proxies for this object using lazy="false"
    via by Paul Cantrell,
  • A runnable example is attached. Here is its output: INFO : org.hibernate.cfg.Environment - Hibernate 3.0.5 INFO : org.hibernate.cfg.Environment - hibernate.properties not found INFO : org.hibernate.cfg.Environment - using CGLIB reflection optimizer INFO : org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling INFO : org.hibernate.cfg.Configuration - configuring from resource: /hibernate.cfg.xml INFO : org.hibernate.cfg.Configuration - Configuration resource: /hibernate.cfg.xml INFO : org.hibernate.cfg.Configuration - Mapping resource: PrivateNullConstructor.hbm.xml INFO : org.hibernate.cfg.HbmBinder - Mapping class: classesThatCauseTheBug.PrivateNullConstructor -> table1 INFO : org.hibernate.cfg.Configuration - Mapping resource: FinalClass.hbm.xml INFO : org.hibernate.cfg.HbmBinder - Mapping class: classesThatCauseTheBug.FinalClass -> table2 INFO : org.hibernate.cfg.Configuration - Configured SessionFactory: null INFO : org.hibernate.cfg.Configuration - processing extends queue INFO : org.hibernate.cfg.Configuration - processing collection mappings INFO : org.hibernate.cfg.Configuration - processing association property references INFO : org.hibernate.cfg.Configuration - processing foreign key constraints INFO : org.hibernate.connection.DriverManagerConnectionProvider - Using Hibernate built-in connection pool (not for production use!) INFO : org.hibernate.connection.DriverManagerConnectionProvider - Hibernate connection pool size: 1 INFO : org.hibernate.connection.DriverManagerConnectionProvider - autocommit mode: false INFO : org.hibernate.connection.DriverManagerConnectionProvider - using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost/pledgetally INFO : org.hibernate.connection.DriverManagerConnectionProvider - connection properties: {user=pledgetallyuser, password=****} INFO : org.hibernate.cfg.SettingsFactory - RDBMS: MySQL, version: 4.0.21 INFO : org.hibernate.cfg.SettingsFactory - JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-3.1.9 ( $Date: 2005/05/19 15:52:23 $, $Revision: 1.1.2.2 $ ) INFO : org.hibernate.dialect.Dialect - Using dialect: org.hibernate.dialect.MySQLDialect INFO : org.hibernate.transaction.TransactionFactoryFactory - Using default transaction strategy (direct JDBC transactions) INFO : org.hibernate.transaction.TransactionManagerLookupFactory - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended) INFO : org.hibernate.cfg.SettingsFactory - Automatic flush during beforeCompletion(): disabled INFO : org.hibernate.cfg.SettingsFactory - Automatic session close at end of transaction: disabled INFO : org.hibernate.cfg.SettingsFactory - JDBC batch size: 15 INFO : org.hibernate.cfg.SettingsFactory - JDBC batch updates for versioned data: disabled INFO : org.hibernate.cfg.SettingsFactory - Scrollable result sets: enabled INFO : org.hibernate.cfg.SettingsFactory - JDBC3 getGeneratedKeys(): enabled INFO : org.hibernate.cfg.SettingsFactory - Connection release mode: null INFO : org.hibernate.cfg.SettingsFactory - Maximum outer join fetch depth: 2 INFO : org.hibernate.cfg.SettingsFactory - Default batch fetch size: 1 INFO : org.hibernate.cfg.SettingsFactory - Generate SQL with comments: disabled INFO : org.hibernate.cfg.SettingsFactory - Order SQL updates by primary key: disabled INFO : org.hibernate.cfg.SettingsFactory - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory INFO : org.hibernate.hql.ast.ASTQueryTranslatorFactory - Using ASTQueryTranslatorFactory INFO : org.hibernate.cfg.SettingsFactory - Query language substitutions: {} INFO : org.hibernate.cfg.SettingsFactory - Second-level cache: enabled INFO : org.hibernate.cfg.SettingsFactory - Query cache: disabled INFO : org.hibernate.cfg.SettingsFactory - Cache provider: org.hibernate.cache.EhCacheProvider INFO : org.hibernate.cfg.SettingsFactory - Optimize cache for minimal puts: disabled INFO : org.hibernate.cfg.SettingsFactory - Structured second-level cache entries: disabled INFO : org.hibernate.cfg.SettingsFactory - Echoing all SQL to stdout INFO : org.hibernate.cfg.SettingsFactory - Statistics: disabled INFO : org.hibernate.cfg.SettingsFactory - Deleted entity synthetic identifier rollback: disabled INFO : org.hibernate.cfg.SettingsFactory - Default entity-mode: pojo INFO : org.hibernate.impl.SessionFactoryImpl - building session factory WARN : net.sf.ehcache.config.Configurator - No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/home/pcantrel/workspace/HHH471TestCaseToMakeGavinHappy/lib/ehcache-1.1.jar!/ehcache-failsafe.xml ERROR: org.hibernate.proxy.BasicLazyInitializer - CGLIB Enhancement failed: classesThatCauseTheBug.FinalClass java.lang.IllegalArgumentException: Cannot subclass final class class classesThatCauseTheBug.FinalClass at net.sf.cglib.proxy.Enhancer.generateClass(Enhancer.java:442) at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25) at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:215) at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:373) at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:281) at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:640) at org.hibernate.proxy.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:94) at org.hibernate.proxy.CGLIBProxyFactory.postInstantiate(CGLIBProxyFactory.java:42) at org.hibernate.tuple.PojoTuplizer.buildProxyFactory(PojoTuplizer.java:144) at org.hibernate.tuple.AbstractTuplizer.<init>(AbstractTuplizer.java:83) at org.hibernate.tuple.PojoTuplizer.<init>(PojoTuplizer.java:54) at org.hibernate.tuple.TuplizerLookup.create(TuplizerLookup.java:47) at org.hibernate.tuple.EntityMetamodel.<init>(EntityMetamodel.java:218) at org.hibernate.persister.entity.BasicEntityPersister.<init>(BasicEntityPersister.java:400) at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:104) at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55) at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:211) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1005) at Main.main(Main.java:10) WARN : org.hibernate.tuple.PojoTuplizer - could not create proxy factory for:classesThatCauseTheBug.FinalClass org.hibernate.HibernateException: CGLIB Enhancement failed: classesThatCauseTheBug.FinalClass at org.hibernate.proxy.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:108) at org.hibernate.proxy.CGLIBProxyFactory.postInstantiate(CGLIBProxyFactory.java:42) at org.hibernate.tuple.PojoTuplizer.buildProxyFactory(PojoTuplizer.java:144) at org.hibernate.tuple.AbstractTuplizer.<init>(AbstractTuplizer.java:83) at org.hibernate.tuple.PojoTuplizer.<init>(PojoTuplizer.java:54) at org.hibernate.tuple.TuplizerLookup.create(TuplizerLookup.java:47) at org.hibernate.tuple.EntityMetamodel.<init>(EntityMetamodel.java:218) at org.hibernate.persister.entity.BasicEntityPersister.<init>(BasicEntityPersister.java:400) at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:104) at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55) at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:211) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1005) at Main.main(Main.java:10) Caused by: java.lang.IllegalArgumentException: Cannot subclass final class class classesThatCauseTheBug.FinalClass at net.sf.cglib.proxy.Enhancer.generateClass(Enhancer.java:442) at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25) at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:215) at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:373) at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:281) at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:640) at org.hibernate.proxy.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:94) ... 12 more ERROR: org.hibernate.proxy.BasicLazyInitializer - CGLIB Enhancement failed: classesThatCauseTheBug.PrivateNullConstructor java.lang.IllegalArgumentException: Superclass has no null constructors but no arguments were given at net.sf.cglib.proxy.Enhancer.emitConstructors(Enhancer.java:682) at net.sf.cglib.proxy.Enhancer.generateClass(Enhancer.java:494) at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25) at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:215) at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:373) at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:281) at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:640) at org.hibernate.proxy.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:94) at org.hibernate.proxy.CGLIBProxyFactory.postInstantiate(CGLIBProxyFactory.java:42) at org.hibernate.tuple.PojoTuplizer.buildProxyFactory(PojoTuplizer.java:144) at org.hibernate.tuple.AbstractTuplizer.<init>(AbstractTuplizer.java:83) at org.hibernate.tuple.PojoTuplizer.<init>(PojoTuplizer.java:54) at org.hibernate.tuple.TuplizerLookup.create(TuplizerLookup.java:47) at org.hibernate.tuple.EntityMetamodel.<init>(EntityMetamodel.java:218) at org.hibernate.persister.entity.BasicEntityPersister.<init>(BasicEntityPersister.java:400) at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:104) at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55) at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:211) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1005) at Main.main(Main.java:10) WARN : org.hibernate.tuple.PojoTuplizer - could not create proxy factory for:classesThatCauseTheBug.PrivateNullConstructor org.hibernate.HibernateException: CGLIB Enhancement failed: classesThatCauseTheBug.PrivateNullConstructor at org.hibernate.proxy.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:108) at org.hibernate.proxy.CGLIBProxyFactory.postInstantiate(CGLIBProxyFactory.java:42) at org.hibernate.tuple.PojoTuplizer.buildProxyFactory(PojoTuplizer.java:144) at org.hibernate.tuple.AbstractTuplizer.<init>(AbstractTuplizer.java:83) at org.hibernate.tuple.PojoTuplizer.<init>(PojoTuplizer.java:54) at org.hibernate.tuple.TuplizerLookup.create(TuplizerLookup.java:47) at org.hibernate.tuple.EntityMetamodel.<init>(EntityMetamodel.java:218) at org.hibernate.persister.entity.BasicEntityPersister.<init>(BasicEntityPersister.java:400) at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:104) at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55) at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:211) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1005) at Main.main(Main.java:10) Caused by: java.lang.IllegalArgumentException: Superclass has no null constructors but no arguments were given at net.sf.cglib.proxy.Enhancer.emitConstructors(Enhancer.java:682) at net.sf.cglib.proxy.Enhancer.generateClass(Enhancer.java:494) at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25) at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:215) at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:373) at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:281) at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:640) at org.hibernate.proxy.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:94) ... 12 more INFO : org.hibernate.impl.SessionFactoryObjectFactory - Not binding factory to JNDI, no JNDI name configured INFO : org.hibernate.impl.SessionFactoryImpl - Checking 0 named queries Trying to load FinalClass... java.lang.NullPointerException at org.hibernate.tuple.AbstractTuplizer.createProxy(AbstractTuplizer.java:249) at org.hibernate.persister.entity.BasicEntityPersister.createProxy(BasicEntityPersister.java:2831) at org.hibernate.event.def.DefaultLoadEventListener.createProxyIfNecessary(DefaultLoadEventListener.java:218) at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:163) at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:79) at org.hibernate.impl.SessionImpl.load(SessionImpl.java:603) at org.hibernate.impl.SessionImpl.load(SessionImpl.java:596) at Main.main(Main.java:17) Trying to load PrivateNullConstructor... java.lang.NullPointerException at org.hibernate.tuple.AbstractTuplizer.createProxy(AbstractTuplizer.java:249) at org.hibernate.persister.entity.BasicEntityPersister.createProxy(BasicEntityPersister.java:2831) at org.hibernate.event.def.DefaultLoadEventListener.createProxyIfNecessary(DefaultLoadEventListener.java:218) at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:163) at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:79) at org.hibernate.impl.SessionImpl.load(SessionImpl.java:603) at org.hibernate.impl.SessionImpl.load(SessionImpl.java:596) at Main.main(Main.java:27)
    via by Paul Cantrell,
  • Hibernate cannot proxy final classes, or classes with private null constructors. Proxying is enabled by default in Hibernate 3. The result of this is that an innocent attempt to map a class of this kind generates an error -- which is expected behavior. However, the error Hibernate generates is supremely unhelpful, and looks for all the world like a bug in Hibernate: java.lang.NullPointerException at org.hibernate.tuple.AbstractTuplizer.createProxy(AbstractTuplizer.java:249) at org.hibernate.persister.entity.BasicEntityPersister.createProxy(BasicEntityPersister.java:2831) at org.hibernate.event.def.DefaultLoadEventListener.createProxyIfNecessary(DefaultLoadEventListener.java:218) at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:163) at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:79) at org.hibernate.impl.SessionImpl.load(SessionImpl.java:603) at org.hibernate.impl.SessionImpl.load(SessionImpl.java:596) (See HHH-685 for code to reproduce this stack trace.) At least six Hibernate users (including me) thought this was a bug, and voted for it as HHH-471. There are two much more reasonable behaviors Hibernate could have: (1) Disable proxying for the class, and issue a warning: WARN: com.whatever.FinalClass is declared final; proxying is disabled ...OR... (2) Issue a meaningful error message instead of the NPE: HibernateMappingException: com.whatever.FinalClass is declared final; disable proxies for this object using lazy="false"
    via by Paul Cantrell,
  • I'm getting the NPE shown below when performing a session.get(Port.class, portID). It seems that despite the fact that the NE persister declares the entity as being lazy and therefore AbstractTuplizer not creating a proxyFactory for it, when loading an instance of Port which has a reference to an NE, the getProxyFactory() method is called in order to create a proxy, and failing Hibernate version: 3.03 Fragment of Mapping documents: <class name="Port" table="PORT" discriminator-value="PO"> <!--- properties ---> <many-to-one name="project" class="Project"lazy="true" column="PROJECT_ID"/> <many-to-one name="ne" class="NE" column="NE_ID" index="I_PORT_NE" /> </class> <class name="NE" table="NE" abstract="true"> ... other properties ... <set name="ports" inverse="true" cascade="save-update"> <key column="NE_ID"/> <one-to-many class="Port"/> </set> </class> Code between sessionFactory.openSession() and session.close(): getSessionFactory().openSession(); getSession().beginTransaction(); getSession().saveOrUpdate(ne); getSession().saveOrUpdate(nePort); getSession().flush(); neID = getSession().getIdentifier(ne); nePortID = getSession().getIdentifier(nePort); getSession().commitTransaction(); getSession().clear(); getSession().disconnect(); getSessionFactory().openSession(); getSession().beginTransaction(); port = getSession().get( Port.class, nePortID)); // exception thrown here ^ [/code] Full stack trace of any exception that occurs: java.lang.NullPointerException at org.hibernate.tuple.AbstractTuplizer.createProxy(AbstractTuplizer.java:249) at org.hibernate.persister.entity.BasicEntityPersister.createProxy(BasicEntityPersister.java:2813) at org.hibernate.event.def.DefaultLoadEventListener.createProxyIfNecessary(DefaultLoadEventListener.java:218) at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:163) at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:79) at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:655) at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:261) at org.hibernate.type.EntityType.resolve(EntityType.java:286) at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:105) at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:510) at org.hibernate.loader.Loader.doQuery(Loader.java:420) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:211) at org.hibernate.loader.Loader.loadEntity(Loader.java:1312) at org.hibernate.loader.entity.EntityLoader.load(EntityLoader.java:116) at org.hibernate.loader.entity.EntityLoader.load(EntityLoader.java:101) at org.hibernate.persister.entity.BasicEntityPersister.load(BasicEntityPersister.java:2461) at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:350) at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:331) at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:113) at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:167) at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:79) at org.hibernate.impl.SessionImpl.get(SessionImpl.java:621) at org.hibernate.impl.SessionImpl.get(SessionImpl.java:614) at au.com.siemens.ecs.spct.command.CreateTrailCommandTest.step1_execCommand(CreateTrailCommandTest.java:109) at au.com.siemens.ecs.spct.command.CreateTrailCommandTest.testCreateTrailUsingCommand(CreateTrailCommandTest.java:64) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at com.intellij.rt.execution.junit2.JUnitStarter.main(JUnitStarter.java:31) _________________ Cheers, Bonny
    via by Bonny Rais,
  • I'm getting the NPE shown below when performing a session.get(Port.class, portID). It seems that despite the fact that the NE persister declares the entity as being lazy and therefore AbstractTuplizer not creating a proxyFactory for it, when loading an instance of Port which has a reference to an NE, the getProxyFactory() method is called in order to create a proxy, and failing Hibernate version: 3.03 Fragment of Mapping documents: <class name="Port" table="PORT" discriminator-value="PO"> <!--- properties ---> <many-to-one name="project" class="Project"lazy="true" column="PROJECT_ID"/> <many-to-one name="ne" class="NE" column="NE_ID" index="I_PORT_NE" /> </class> <class name="NE" table="NE" abstract="true"> ... other properties ... <set name="ports" inverse="true" cascade="save-update"> <key column="NE_ID"/> <one-to-many class="Port"/> </set> </class> Code between sessionFactory.openSession() and session.close(): getSessionFactory().openSession(); getSession().beginTransaction(); getSession().saveOrUpdate(ne); getSession().saveOrUpdate(nePort); getSession().flush(); neID = getSession().getIdentifier(ne); nePortID = getSession().getIdentifier(nePort); getSession().commitTransaction(); getSession().clear(); getSession().disconnect(); getSessionFactory().openSession(); getSession().beginTransaction(); port = getSession().get( Port.class, nePortID)); // exception thrown here ^ [/code] Full stack trace of any exception that occurs: java.lang.NullPointerException at org.hibernate.tuple.AbstractTuplizer.createProxy(AbstractTuplizer.java:249) at org.hibernate.persister.entity.BasicEntityPersister.createProxy(BasicEntityPersister.java:2813) at org.hibernate.event.def.DefaultLoadEventListener.createProxyIfNecessary(DefaultLoadEventListener.java:218) at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:163) at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:79) at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:655) at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:261) at org.hibernate.type.EntityType.resolve(EntityType.java:286) at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:105) at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:510) at org.hibernate.loader.Loader.doQuery(Loader.java:420) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:211) at org.hibernate.loader.Loader.loadEntity(Loader.java:1312) at org.hibernate.loader.entity.EntityLoader.load(EntityLoader.java:116) at org.hibernate.loader.entity.EntityLoader.load(EntityLoader.java:101) at org.hibernate.persister.entity.BasicEntityPersister.load(BasicEntityPersister.java:2461) at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:350) at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:331) at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:113) at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:167) at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:79) at org.hibernate.impl.SessionImpl.get(SessionImpl.java:621) at org.hibernate.impl.SessionImpl.get(SessionImpl.java:614) at au.com.siemens.ecs.spct.command.CreateTrailCommandTest.step1_execCommand(CreateTrailCommandTest.java:109) at au.com.siemens.ecs.spct.command.CreateTrailCommandTest.testCreateTrailUsingCommand(CreateTrailCommandTest.java:64) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at com.intellij.rt.execution.junit2.JUnitStarter.main(JUnitStarter.java:31) _________________ Cheers, Bonny
    via by Bonny Rais,
    • java.lang.NullPointerException at org.hibernate.tuple.AbstractTuplizer.createProxy(AbstractTuplizer.java:249) at org.hibernate.persister.entity.BasicEntityPersister.createProxy(BasicEntityPersister.java:2831) at org.hibernate.event.def.DefaultLoadEventListener.createProxyIfNecessary(DefaultLoadEventListener.java:218) at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:163) at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:79) at org.hibernate.impl.SessionImpl.load(SessionImpl.java:603) at org.hibernate.impl.SessionImpl.load(SessionImpl.java:596)
    No Bugmate found.