我正在使用Java项目,使用Java JDK 64位1.8.0.25通过Eclipse(Luna)使用HSQLDB(2.3.2)和Hibernate(4.3.6),我准备了一个非常小而简单的测试查询数据库的类。
至于我将应用程序作为标准java应用程序(来自命令行)运行一切正常但是当我尝试从Eclipse调试或运行应用程序时,我在注册表构建器初始化期间收到错误(请参阅星号) :
Configuration c1= new Configuration();
c1.configure("/hibernate.cfg.xml");
**serviceRegistry = new StandardServiceRegistryBuilder().applySettings( c1.getProperties()).build();**
return c1.buildSessionFactory(serviceRegistry );
错误是:
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
你能帮帮我吗?我认为它与属性文件无关,因为它们被正确解析和使用。
答案 0 :(得分:1)
您可以在此链接后获取所有详细信息:https://www.eclipse.org/forums/index.php/m/1476143/#msg_1476143
的BR