会话工厂构建hibernate 4中的java.lang.NullPointerException

会话工厂构建hibernate 4中的java.lang.NullPointerException,java,hibernate,session,sessionfactory,hibernate-4.x,Java,Hibernate,Session,Sessionfactory,Hibernate 4.x,我只是想在Hibernate4中创建一个会话工厂对象。它在创建会话工厂对象时引发空指针异常 休眠配置文件 <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration

我只是想在Hibernate4中创建一个会话工厂对象。它在创建会话工厂对象时引发空指针异常

休眠配置文件

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>

<property name="connection.url">jdbc:oracle:thin:@SHKG9072DB:5030:TMSD10G2</property>
<property name="connection.username">ICTDEV$EDI_APP</property>
<property name="connection.password">p2II9JLIaea06</property>
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>

<property name="show_sql">true</property>

<property name="format_sql">true</property>


<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>
<property name="current_session_context_class">thread</property> 

</session-factory>
</hibernate-configuration>
日志

Trying to create a test connection with the database.
May 20, 2015 5:04:55 PM  org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.5.Final}
May 20, 2015 5:04:55 PM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.3.10.Final}
May 20, 2015 5:04:55 PM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
May 20, 2015 5:04:55 PM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
May 20, 2015 5:04:55 PM org.hibernate.cfg.Configuration configure
INFO: HHH000043: Configuring from resource: hibernate.cfg.xml
May 20, 2015 5:04:55 PM org.hibernate.cfg.Configuration  getConfigurationInputStream
May 20, 2015 5:04:56 PM org.hibernate.internal.util.xml.DTDEntityResolver resolveEntityINFO: HHH000040: Configuration resource: hibernate.cfg.xml
WARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
May 20, 2015 5:04:56 PM org.hibernate.cfg.Configuration doConfigure
INFO: HHH000041: Configured SessionFactory: null
May 20, 2015 5:04:56 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
WARN: HHH000402: Using Hibernate built-in connection pool (not for production use!)
May 20, 2015 5:04:56 PM  org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH000401: using driver [oracle.jdbc.driver.OracleDriver] at URL [jdbc:oracle:thin:@SHKG9072DB:5030:TMSD10G2]
 May 20, 2015 5:04:56 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH000046: Connection properties: {user=ICTDEV$EDI_APP, password=****}
May 20, 2015 5:04:56 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH000006: Autocommit mode: false
May 20, 2015 5:04:56 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000115: Hibernate connection pool size: 1 (min=1)
May 20, 2015 5:04:56 PM org.hibernate.engine.jdbc.internal.JdbcServicesImpl configure
WARN: HHH000341: Could not obtain connection metadata : Unsupported feature
May 20, 2015 5:04:56 PM org.hibernate.engine.jdbc.internal.LobCreatorBuilder useContextualLobCreation
  INFO: HHH000422: Disabling contextual LOB creation as connection was null

Exception in thread "main" java.lang.NullPointerException
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:244)
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:111)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:234)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:206)
at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1887)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1845)
at com.world.demo.Main.main(Main.java:17)
正在尝试创建与数据库的测试连接。
2015年5月20日下午5:04:55 org.hibernate.annotations.common.reflection.java.JavaReflectionManager
信息:HCANN000001:Hibernate Commons注释{4.0.5.Final}
2015年5月20日下午5:04:55 org.hibernate.Version日志版本
信息:hh000412:Hibernate核心{4.3.10.Final}
2015年5月20日下午5:04:55 org.hibernate.cfg.Environment
信息:HH000206:找不到hibernate.properties
2015年5月20日下午5:04:55 org.hibernate.cfg.Environment buildBytecodeProvider
信息:HH000021:字节码提供程序名称:javassist
2015年5月20日下午5:04:55 org.hibernate.cfg.Configuration
信息:HH000043:从资源配置:hibernate.cfg.xml
2015年5月20日下午5:04:55 org.hibernate.cfg.Configuration getConfigurationInputStream
2015年5月20日下午5:04:56 org.hibernate.internal.util.xml.dtdentialResolver resolveEntityINFO:hh000040:配置资源:hibernate.cfg.xml
警告:HH000223:已识别过时的hibernate命名空间http://hibernate.sourceforge.net/. 使用名称空间http://www.hibernate.org/dtd/ 相反请参阅Hibernate 3.6迁移指南!
2015年5月20日下午5:04:56 org.hibernate.cfg.Configuration doConfigure
信息:HH000041:配置的会话工厂:null
2015年5月20日下午5:04:56 org.hibernate.engine.jdbc.connections.internal.driverManager连接提供MPL配置
警告:HH000402:使用Hibernate内置连接池(不用于生产!)
2015年5月20日下午5:04:56 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
信息:HHH000401:在URL[jdbc:oracle:thin:@SHKG9072DB:5030:TMSD10G2]处使用驱动程序[oracle.jdbc.driver.OracleDriver]
2015年5月20日下午5:04:56 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
信息:hh000046:连接属性:{user=ICTDEV$EDI_应用程序,密码=**}
2015年5月20日下午5:04:56 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
信息:HH000006:自动提交模式:错误
2015年5月20日下午5:04:56 org.hibernate.engine.jdbc.connections.internal.driverManager连接提供MPL配置
信息:HH000115:休眠连接池大小:1(最小值=1)
2015年5月20日下午5:04:56 org.hibernate.engine.jdbc.internal.jdbcservicesiml configure
警告:HH000341:无法获取连接元数据:不支持的功能
2015年5月20日下午5:04:56 org.hibernate.engine.jdbc.internal.LobCreatorBuilder UseContexturationAllobCreation
信息:HH000422:由于连接为空,因此禁用上下文LOB创建
线程“main”java.lang.NullPointerException中出现异常
位于org.hibernate.engine.jdbc.internal.jdbcservicesiml.configure(jdbcservicesiml.java:244)
位于org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:111)
位于org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:234)
位于org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:206)
位于org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1887)
位于org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1845)
位于com.world.demo.Main.Main(Main.java:17)

是否尝试在xml文件中添加这些属性:

name=“hibernate.temp.use\u jdbc\u metadata\u defaults”value=“false”

name=“hibernate.jdbc.lob.non_context_creation”=“true”

如果您使用的是hibernate hikaricp,如果您未设置连接提供程序类,则可能会发生这种情况:

hibernate.connection.provider_class=org.hibernate.hikaricp.internal.HikariCPConnectionProvider
hibernate.hikari.jdbcUrl=...
hibernate.connection.provider_class=org.hibernate.hikaricp.internal.HikariCPConnectionProvider
hibernate.hikari.jdbcUrl=...