Reputation: 41
I'l working with a Java project that uses HSQLDB (2.3.2) and Hibernate (4.3.6) via Eclipse (Luna) using Java JDK 64 bits 1.8.0.25, I prepared a very small and simple test class that queries the Database.
As far as I run the application as a standard java application (that is from command line) everything works fine but when I try to debug or run the application from Eclipse I get an error during the Registry builder initialization (see asterisks):
Configuration c1= new Configuration();
c1.configure("/hibernate.cfg.xml");
**serviceRegistry = new StandardServiceRegistryBuilder().applySettings( c1.getProperties()).build();**
return c1.buildSessionFactory(serviceRegistry );
The error is:
ott 24, 2014 3:29:39 PM org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.5.Final}
ott 24, 2014 3:29:39 PM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.3.6.Final}
ott 24, 2014 3:29:39 PM org.hibernate.cfg.Environment <clinit>
INFO: HHH000205: Loaded properties from resource hibernate.properties: {hibernate.bytecode.use_reflection_optimizer=false}
ott 24, 2014 3:29:39 PM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
ott 24, 2014 3:29:40 PM org.hibernate.cfg.Configuration configure
INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml
ott 24, 2014 3:29:40 PM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: HHH000040: Configuration resource: /hibernate.cfg.xml
ott 24, 2014 3:29:41 PM org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: test/db/generated/MainConfParams.hbm.xml
ott 24, 2014 3:29:42 PM org.hibernate.cfg.Configuration doConfigure
INFO: HHH000041: Configured SessionFactory: null
Initial SessionFactory creation failed.java.lang.NullPointerException
Exception in thread "main" java.lang.ExceptionInInitializerError
at test.db.HibernateUtil.buildSessionFactory(HibernateUtil.java:28)
at test.db.HibernateUtil.getSessionFactory(HibernateUtil.java:34)
at test.db.Test.createAndStoreEvent(Test.java:26)
at test.db.Test.main(Test.java:17)
Caused by: java.lang.NullPointerException
at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl$AggregatedClassLoader.getResources(ClassLoaderServiceImpl.java:186)
at java.util.ServiceLoader$LazyIterator.hasNextService(ServiceLoader.java:348
at java.util.ServiceLoader$LazyIterator.hasNext(ServiceLoader.java:393)
at java.util.ServiceLoader$1.hasNext(ServiceLoader.java:474)
at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.loadJavaServices(ClassLoaderServiceImpl.java:339)
at org.hibernate.integrator.internal.IntegratorServiceImpl.<init>(IntegratorServiceImpl.java:57)
at org.hibernate.boot.registry.BootstrapServiceRegistryBuilder.build(BootstrapServiceRegistryBuilder.java:247)
at org.hibernate.boot.registry.StandardServiceRegistryBuilder.<init>(StandardServiceRegistryBuilder.java:73)
at test.db.HibernateUtil.buildSessionFactory(HibernateUtil.java:22)
... 3 more
Could you please help me ? I think it is not related to the properties files as they are parsed and used correctly.
Upvotes: 1
Views: 1743
Reputation: 41
thanks to the eclipse support we managed to solve the problem, the reason is the definition of the Hibernate libraries as "system" ones.
You can get all the details following this link: https://www.eclipse.org/forums/index.php/m/1476143/#msg_1476143
BRs
Upvotes: 1