问答详情
源自:1-11 通过Hibernate API编写访问数据库的代码

无法运行啊

十一月 07, 2016 6:57:17 下午 org.hibernate.annotations.common.Version <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.2.Final}
十一月 07, 2016 6:57:17 下午 org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.2.4.Final}
十一月 07, 2016 6:57:17 下午 org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
十一月 07, 2016 6:57:17 下午 org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
十一月 07, 2016 6:57:17 下午 org.hibernate.cfg.Configuration configure
INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml
十一月 07, 2016 6:57:17 下午 org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: HHH000040: Configuration resource: /hibernate.cfg.xml



//错误信息

StudentsTest.testSaveStudents (Failed Tests first)
testSaveStudents(hibernate_001.StudentsTest)
org.hibernate.HibernateException: /hibernate.cfg.xml not found

 at org.hibernate.internal.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:173)

 at org.hibernate.cfg.Configuration.getConfigurationInputStream(Configuration.java:2026)

 at org.hibernate.cfg.Configuration.configure(Configuration.java:2007)

 at org.hibernate.cfg.Configuration.configure(Configuration.java:1987)

 at hibernate_001.StudentsTest.init(StudentsTest.java:29)

 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

 at java.lang.reflect.Method.invoke(Unknown Source)

 at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)

 at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)

 at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)

 at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)

 at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)

 at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)

 at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)

 at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)

 at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)

 at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)

 at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)

 at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)

 at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)

 at org.junit.runners.ParentRunner.run(ParentRunner.java:300)

 at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)

 at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)

 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)

 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)

 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)

 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

java.lang.NullPointerException

 at hibernate_001.StudentsTest.destory(StudentsTest.java:53)

 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

 at java.lang.reflect.Method.invoke(Unknown Source)

 at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)

 at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)

 at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)

 at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:36)

 at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)

 at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)

 at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)

 at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)

 at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)

 at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)

 at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)

 at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)

 at org.junit.runners.ParentRunner.run(ParentRunner.java:300)

 at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)

 at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)

 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)

 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)

 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)

 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)


提问者:粑粑3722522 2016-11-07 19:07

个回答

  • qq_苌伴澜星宇_03993684
    2016-11-23 19:16:15

    我也是这种错误  你解决了吗?


  • 粑粑3722522
    2016-11-08 21:55:13

    我的配置文件写错的话会不会出现这种问题


  • qq_独奏彡_03973255
    2016-11-07 23:09:02

    找不到你的hibernate.cfg.xml 配置文件