在运行测试用的HiberTest类时抛出如下异常,我找了很长时间还是没能解决,外国论坛也有这种,但是他们的方法有的我试过,还是不行。有的看不懂,请高手们帮帮忙,能解决的话,我有分再加分。
Exception in thread "main " java.lang.ExceptionInInitializerError
at com.ctcmc.hibernate.HibernateUtil. <clinit> (HibernateUtil.java:11)
at com.ctcmc.hibernate.DAOImp.createStu(DAOImp.java:23)
at com.ctcmc.hibernate.HiberTest.main(HiberTest.java:16)
Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException (Caused by java.lang.NullPointerException) (Caused by org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException (Caused by java.lang.NullPointerException))
at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:543)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:235)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:209)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
at org.hibernate.cfg.Configuration. <clinit> (Configuration.java:116)
... 3 more
Caused by: org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException (Caused by java.lang.NullPointerException)
at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:397)
at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:529)
... 7 more
Caused by: java.lang.NullPointerException
at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:374)
... 8 more
hibernate.cfg.xml文件内容:
<hibernate-configuration>
<session-factory>
<!-- local connection properties -->
<property name= "hibernate.connection.url ">
jdbc:microsoft:sqlserver://192.168.0.1:1433;databasename=test
</property>
<property name= "hibernate.connection.driver_class ">
com.microsoft.jdbc.sqlserver.SQLServerDriver
</property>
<property name= "hibernate.connection.username "> sa </property>
<property name= "hibernate.connection.password "> fhwlcatv </property>
<!-- property name= "hibernate.connection.pool_size "> </property -->
<!-- dialect for Microsoft SQL Server -->
<property name= "dialect ">
org.hibernate.dialect.SQLServerDialect
</property>
<property name= "hibernate.show_sql "> true </property>
<property name= "hibernate.transaction.factory_class ">
org.hibernate.transaction.JDBCTransactionFactory
</property>
<mapping resource= "com/ctcmc/hibernate/Test.hbm.xml " />
</session-factory>
</hibernate-configuration>
Test.hbm.xml文件内容:
<?xml version= "1.0 "?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN "
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd " >
<hibernate-mapping package= "com.ctcmc.hibernate ">
<class
name= "Test "
table= "test "