I have a method that I have been using to create a Hibernate SessionFactory.
The following worked just fine while using 4.2.8-Final
Code:
public static SessionFactory getDefaultSessionFactory() {
Configuration configuration = new Configuration();
// do stuff to configuration
ServiceRegistryBuilder serviceRegistryBuilder = new ServiceRegistryBuilder()
.applySettings(configuration.getProperties());
return configuration.buildSessionFactory(serviceRegistryBuilder
.buildServiceRegistry());
}
In updating to 4.3.0-Final (JPA 2.1 certification - YAY!) and to address the deprecation warnings I changed the code to the following:
Code:
public static SessionFactory getDefaultSessionFactory() {
Configuration configuration = new Configuration();
// do stuff to configuration
StandardServiceRegistryBuilder serviceRegistryBuilder = new StandardServiceRegistryBuilder()
.applySettings(configuration.getProperties());
return configuration.buildSessionFactory(serviceRegistryBuilder
.getBootstrapServiceRegistry());
}
Here is the log and stack trace. Guidance is very appreciated!
[2014-01-14 13:44:25,371 main] [org.hibernate.cfg.Configuration : 2073] [INFO ] HHH000043: Configuring from resource: systemidataaccess.dtauth.hibernate.cfg.xml
[2014-01-14 13:44:25,371 main] [org.hibernate.cfg.Configuration : 2092] [INFO ] HHH000040: Configuration resource: systemidataaccess.dtauth.hibernate.cfg.xml
[2014-01-14 13:44:25,413 main] [org.hibernate.internal.util.xml.DTDEntityResolver : 69] [DEBUG] Trying to resolve system-id [http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd]
[2014-01-14 13:44:25,413 main] [org.hibernate.internal.util.xml.DTDEntityResolver : 71] [DEBUG] Recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/
[2014-01-14 13:44:25,414 main] [org.hibernate.internal.util.xml.DTDEntityResolver : 108] [DEBUG] Located [http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd] in classpath
[2014-01-14 13:44:25,431 main] [org.hibernate.cfg.Configuration : 2254] [DEBUG] Session-factory config [null] named resource [hbm/Dtauth.hbm.xml] for mapping
[2014-01-14 13:44:25,432 main] [org.hibernate.cfg.Configuration : 757] [INFO ] HHH000221: Reading mappings from resource: hbm/Dtauth.hbm.xml
[2014-01-14 13:44:25,457 main] [org.hibernate.internal.util.xml.DTDEntityResolver : 69] [DEBUG] Trying to resolve system-id [http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd]
[2014-01-14 13:44:25,457 main] [org.hibernate.internal.util.xml.DTDEntityResolver : 71] [DEBUG] Recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/
[2014-01-14 13:44:25,458 main] [org.hibernate.internal.util.xml.DTDEntityResolver : 108] [DEBUG] Located [http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd] in classpath
[2014-01-14 13:44:25,490 main] [org.hibernate.cfg.Configuration : 2214] [INFO ] HHH000041: Configured SessionFactory: null
[2014-01-14 13:44:25,505 main] [org.hibernate.integrator.internal.IntegratorServiceImpl : 63] [DEBUG] Adding Integrator [org.hibernate.cfg.beanvalidation.BeanValidationIntegrator].
[2014-01-14 13:44:25,509 main] [org.hibernate.integrator.internal.IntegratorServiceImpl : 63] [DEBUG] Adding Integrator [org.hibernate.secure.spi.JaccIntegrator].
[2014-01-14 13:44:25,511 main] [org.hibernate.integrator.internal.IntegratorServiceImpl : 63] [DEBUG] Adding Integrator [org.hibernate.cache.internal.CollectionCacheInvalidator].
[2014-01-14 13:44:25,537 main] [org.hibernate.boot.registry.selector.internal.StrategySelectorImpl : 79] [DEBUG] Registering named strategy selector [org.hibernate.dialect.Dialect] : [MySQL5] -> [org.hibernate.dialect.MySQL5Dialect] (replacing [org.hibernate.dialect.MySQL5Dialect])
[2014-01-14 13:44:25,537 main] [org.hibernate.boot.registry.selector.internal.StrategySelectorImpl : 79] [DEBUG] Registering named strategy selector [org.hibernate.dialect.Dialect] : [MySQL5InnoDB] -> [org.hibernate.dialect.MySQL5InnoDBDialect] (replacing [org.hibernate.dialect.MySQL5InnoDBDialect])
[2014-01-14 13:44:25,609 main] [org.hibernate.cfg.Configuration : 1841] [DEBUG] Preparing to build session factory with filters : {}
[2014-01-14 13:44:25,611 main] [org.hibernate.cfg.Configuration : 1841] [DEBUG] Preparing to build session factory with filters : {}
java.lang.NullPointerException
at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1885)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1843)
at com.mypckg.systemidataaccess.main.dataaccess.dr.HibernateUtilCore.getDefaultSessionFactory(HibernateUtilCore.java:197)
at com.mypckg.systemidataaccess.main.dataaccess.dr.HibernateUtilCore.buildSessionFactory(HibernateUtilCore.java:312)
at com.mypckg.systemidataaccess.dtauth.impl.DtauthDataAccess.<clinit>(DtauthDataAccess.java:17)
at com.mypckg.systemidataaccess.dtauth.test.Test.TestDtauth(Test.java:25)
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)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)