Hibernate创建sessionFactory null

问题描述

请问各位: 我在使用junit进行单元测试的时候,到实例化SessionFactory的时候不成功,控制台打印的信息如下:2013-8-14 15:36:45 org.hibernate.annotations.common.Version <clinit>INFO: HCANN000001: Hibernate Commons Annotations {4.0.1.Final}2013-8-14 15:36:45 org.hibernate.Version logVersionINFO: HHH000412: Hibernate Core {4.1.9.Final}2013-8-14 15:36:45 org.hibernate.cfg.Environment <clinit>INFO: HHH000206: hibernate.properties not found2013-8-14 15:36:45 org.hibernate.cfg.Environment buildBytecodeProviderINFO: HHH000021: Bytecode provider name : javassist2013-8-14 15:36:45 org.hibernate.cfg.Configuration configureINFO: HHH000043: Configuring from resource: /hibernate.cfg.xml2013-8-14 15:36:45 org.hibernate.cfg.Configuration getConfigurationInputStreamINFO: HHH000040: Configuration resource: /hibernate.cfg.xml2013-8-14 15:36:45 org.hibernate.cfg.Configuration addResourceINFO: HHH000221: Reading mappings from resource: com/hanqi/po/TempPrice.hbm.xml2013-8-14 15:36:45 org.hibernate.cfg.Configuration addResourceINFO: HHH000221: Reading mappings from resource: com/hanqi/po/Product.hbm.xml2013-8-14 15:36:45 org.hibernate.cfg.Configuration addResourceINFO: HHH000221: Reading mappings from resource: com/hanqi/po/CurrentPrice.hbm.xml2013-8-14 15:36:45 org.hibernate.cfg.Configuration addResourceINFO: HHH000221: Reading mappings from resource: com/hanqi/po/LookupCode.hbm.xml2013-8-14 15:36:45 org.hibernate.cfg.Configuration addResourceINFO: HHH000221: Reading mappings from resource: com/hanqi/po/LookupType.hbm.xml2013-8-14 15:36:45 org.hibernate.cfg.Configuration doConfigureINFO: HHH000041: Configured SessionFactory: null我检查过我的hibernate.cfg.xml文件和未发现错误。如下:<hibernate-configuration><session-factory> <property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property> <property name="connection.url">jdbc:oracle:thin:@localhost:1521:orcl</property> <property name="connection.username">POSMAN</property> <property name="connection.password">POSMAN</property> <property name="dialect">org.hibernate.dialect.Oracle10gDialect</property> <!-- Echo all executed SQL to stdout --> <property name="show_sql">true</property><mapping resource="com/hanqi/po/TempPrice.hbm.xml"/><mapping resource="com/hanqi/po/Product.hbm.xml"/><mapping resource="com/hanqi/po/CurrentPrice.hbm.xml"/><mapping resource="com/hanqi/po/LookupCode.hbm.xml"/><mapping resource="com/hanqi/po/LookupType.hbm.xml"/></session-factory></hibernate-configuration>xxx.hbm.xml文件我也检查过未发现问题,请问会是在哪个地方出的错。感谢!

解决方案

1 代码没问题的话,请把所有的映射文件删除,看下是什么效果2 把配置属性修改成 <property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property> <property name="hibernate. connection.url">jdbc:oracle:thin:@localhost:1521:orcl</property> <property name="hibernate.connection.username">POSMAN</property> <property name="hibernate.connection.password">POSMAN</property>官方文档时这种写法http://docs.jboss.org/hibernate/orm/3.3/reference/en-US/html/session-configuration.html
解决方案二:
你的错误信息:INFO: HHH000206: hibernate.properties not found 需要的属性文件没找到,那么很可能你的jar包没放对位置也可能hibernate.cfg.xml 路径问题吧!仔细检查!
解决方案三:
只有这些报错信息吗?

时间: 2024-07-30 12:31:43

Hibernate创建sessionFactory null的相关文章

java-关于spring+hibernate 注入sessionFactory为null的问题

问题描述 关于spring+hibernate 注入sessionFactory为null的问题 最近一个项目需要用到struts2+spring+hibernate组合框架,我在一点一点的做配置,但做到注入SessionFactory时,一直不成功,在网上搜的一些解决方案也都不适用.故在此发布,希望高手们不吝赐教.web.xml的配置为: <?xml version=""1.0"" encoding=""UTF-8""

spring整合hibernate出现sessionFactory的bean创建异常错误

问题描述 spring整合hibernate出现sessionFactory的bean创建异常错误 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; neste

hibernate-Hibernate 5.0.1 Final中怎么创建SessionFactory 详细步骤

问题描述 Hibernate 5.0.1 Final中怎么创建SessionFactory 详细步骤 新手求教,Hibernate 5.0.1 Final中怎么创建SessionFactory 这是我自己写的步骤,但是测试不行,提示 hibernate.properties not found: SessionFactory sessionFactory = null; Configuration configuration = new Configuration().configure();

javase-Hibernate4创建SessionFactory时卡住不运行?

问题描述 Hibernate4创建SessionFactory时卡住不运行? Hibernate4创建SessionFactory时卡住不运行? 使用Hibernate4写一个CRUD示例,javase程序,在main方法中创建sessionFactory,使用如下代码: private HibernateUtils() { try { if (this.sessionFactory == null) { Configuration cfg = new Configuration(); cfg.

如何验证hibernate的sessionfactory是线程安全的?

问题描述 如何验证hibernate的sessionfactory是线程安全的? 如题,如何验证hibernate的sessionfactory是线程安全的? 解决方案 使用singleton模式,在一个应用的生命周期中只创建一次SessionFactory

关于使用ssh框架的问题,关于hibernate的sessionfactory

问题描述 关于使用ssh框架的问题,关于hibernate的sessionfactory 我在项目中使用了mysql生成的hibernatesessionfactory这个类,直接拷过来的,然后把他写在了applicationcontext.xml里写成了< bean id="..".../>,在运行项目的时候我看控制台里是直接初始化了的..这个没什么问题 现在如果我再在applicationcontext.xml里面写一个< bean id="...&qu

数据库-hibernate创建了两个相同的表,字段都一样,大小写不一样

问题描述 hibernate创建了两个相同的表,字段都一样,大小写不一样 应该是第一次启动工程,hibernate生成一次表,这一次是正常的,之后修改了某些实体类 再重新启动工程,数据库里的表就多了一份,比如表bt_study表下面多了个bt_Study的表 ,然后导致外键的一些错误. 解决方案 解决方案二: 解决方案三: 你修改了实体类,那么你的hbernate的配置文件也要改,删除之前的那张表,如果用到hibernate一般建议实体类不要改动

hibernate的sessionFactory的问题

问题描述 2014-8-8 17:29:19 org.hibernate.cfg.Environment <clinit>信息: Hibernate 3.2.72014-8-8 17:29:19 org.hibernate.cfg.Environment <clinit>信息: hibernate.properties not found2014-8-8 17:29:19 org.hibernate.cfg.Environment buildBytecodeProvider信息:

websphere6.1 不能创建sessionfactory

问题描述 户使用的服务器是websphere6.1,所以项目要发布在websphere上面,以前没弄过,看了下websphere的安装和配置把项目发布到websphere6.1上面就有问题了,老报sessionFactory创建不了,但是在tomcat5.5下面没有任务问题,网上找了很多资料都没有相关问题,请以前有websphere开发经验的高手帮帮忙,不尽感激-配置文件路径没对?还是Websphere没有配置数据源,这个和Websphere配置无关吧?web.xml文件<web-appver