我弄的是公司员工管理系统是java项目,用的是swing+hibernate3.2+Oracle9i
以下是错误提示:
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "AWT-EventQueue-0" java.lang.ExceptionInInitializerError
at org.hibernate.cfg.Configuration.reset(Configuration.java:168)
at org.hibernate.cfg.Configuration.<init>(Configuration.java:187)
at org.hibernate.cfg.Configuration.<init>(Configuration.java:191)
at com.mwq.hibernate.HibernateSessionFactory.<clinit>(HibernateSessionFactory.java:16)
at com.mwq.hibernate.BaseDao.queryList(BaseDao.java:29)
at com.mwq.hibernate.Dao.queryManagerOfNatural(Dao.java:141)
at com.mwq.frame.LandFrame.<init>(LandFrame.java:100)
at com.mwq.PersonnelManage.land(PersonnelManage.java:32)
at com.mwq.PersonnelManage$1.run(PersonnelManage.java:26)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at org.hibernate.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:144)
at org.hibernate.cfg.Environment.<clinit>(Environment.java:529)
... 17 more
以下是我的hibernate.cfg.xml配置文件的内容:
<?xml version='1.0' encoding='GBK'?>
<!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.driver_class">
oracle.jdbc.driver.OracleDriver
</property>
<property name="connection.url">
jdbc:oracle:thin:@127.0.0.1:1521:DBSQL
</property>
<property name="connection.username">PERSONNEL_MANAGE</property>
<property name="connection.password">MWQ</property>
<property name="dialect">
org.hibernate.dialect.OracleDialect
</property>
<property name="show_sql">true</property>
<property name="format_sql">true</property>
<property name="use_sql_comments">true</property> <mapping resource="com/mwq/hibernate/mapping/TbDept.hbm.xml" />
<mapping
resource="com/mwq/hibernate/mapping/TbPersonalInfo.hbm.xml" />
<mapping
resource="com/mwq/hibernate/mapping/TbNativePlace.hbm.xml" />
<mapping
resource="com/mwq/hibernate/mapping/TbBringUpContent.hbm.xml" />
<mapping
resource="com/mwq/hibernate/mapping/TbReckoningList.hbm.xml" />
<mapping resource="com/mwq/hibernate/mapping/TbManager.hbm.xml" />
<mapping
resource="com/mwq/hibernate/mapping/TbRewardsAndPunishment.hbm.xml" />
<mapping
resource="com/mwq/hibernate/mapping/TbAccountItem.hbm.xml" />
<mapping
resource="com/mwq/hibernate/mapping/TbDutyInfo.hbm.xml" />
<mapping
resource="com/mwq/hibernate/mapping/TbReckoning.hbm.xml" />
<mapping
resource="com/mwq/hibernate/mapping/TbTimecard.hbm.xml" />
<mapping resource="com/mwq/hibernate/mapping/TbNation.hbm.xml" />
<mapping resource="com/mwq/hibernate/mapping/TbRecord.hbm.xml" />
<mapping
resource="com/mwq/hibernate/mapping/TbReckoningInfo.hbm.xml" />
<mapping
resource="com/mwq/hibernate/mapping/TbAccessionForm.hbm.xml" />
<mapping resource="com/mwq/hibernate/mapping/TbDuty.hbm.xml" />
<mapping
resource="com/mwq/hibernate/mapping/TbBringUpOntent.hbm.xml" /> </session-factory></hibernate-configuration>先谢谢了!!!

解决方案 »

  1.   

    at com.mwq.hibernate.HibernateSessionFactory. <clinit>(HibernateSessionFactory.java:16) 
    at com.mwq.hibernate.BaseDao.queryList(BaseDao.java:29) 
    at com.mwq.hibernate.Dao.queryManagerOfNatural(Dao.java:141) 
    at com.mwq.frame.LandFrame. <init>(LandFrame.java:100) 
    at com.mwq.PersonnelManage.land(PersonnelManage.java:32) 
    at com.mwq.PersonnelManage$1.run(PersonnelManage.java:26) 
    主要看这里,初始化hibernate工厂的时候没有能够成功,空指针异常,看看这几个方法之间的连接是哪个就明白了。
      

  2.   

    Caused by: java.lang.NullPointerException 
    at org.hibernate.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:144) 
    at org.hibernate.cfg.Environment. <clinit>(Environment.java:529) 空指针 ,貌似没找到配置文件中的某些内容