2 dingyuanzi dingyuanzi 于 2016.09.16 13:29 提问

使用junit4 报错 弄了几天了 一点头绪都没有 5C

java.lang.ExceptionInInitializerError
at com.java1234.service.StudentTest.(StudentTest.java:18)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:217)
at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:266)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
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)
Caused by: org.hibernate.exception.JDBCConnectionException: Error calling Driver#connect
at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:132)
at org.hibernate.engine.jdbc.connections.internal.BasicConnectionCreator$1$1.convert(BasicConnectionCreator.java:118)
at org.hibernate.engine.jdbc.connections.internal.BasicConnectionCreator.convertSqlException(BasicConnectionCreator.java:140)
at org.hibernate.engine.jdbc.connections.internal.DriverConnectionCreator.makeConnection(DriverConnectionCreator.java:58)
at org.hibernate.engine.jdbc.connections.internal.BasicConnectionCreator.createConnection(BasicConnectionCreator.java:75)
at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.configure(DriverManagerConnectionProviderImpl.java:106)
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.engine.jdbc.internal.JdbcServicesImpl.buildJdbcConnectionAccess(JdbcServicesImpl.java:260)
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:94)
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:1885)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1843)
at com.java1234.util.HibernateUtil.buildSessionFactory(HibernateUtil.java:15)
at com.java1234.util.HibernateUtil.(HibernateUtil.java:10)
... 23 more
Caused by: com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception:

** BEGIN NESTED EXCEPTION **

java.net.SocketException
MESSAGE: java.net.ConnectException: Connection refused: connect

STACKTRACE:

java.net.SocketException: java.net.ConnectException: Connection refused: connect
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:156)
at com.mysql.jdbc.MysqlIO.(MysqlIO.java:284)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:2555)
at com.mysql.jdbc.Connection.(Connection.java:1485)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
at org.hibernate.engine.jdbc.connections.internal.DriverConnectionCreator.makeConnection(DriverConnectionCreator.java:55)
at org.hibernate.engine.jdbc.connections.internal.BasicConnectionCreator.createConnection(BasicConnectionCreator.java:75)
at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.configure(DriverManagerConnectionProviderImpl.java:106)
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.engine.jdbc.internal.JdbcServicesImpl.buildJdbcConnectionAccess(JdbcServicesImpl.java:260)
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:94)
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:1885)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1843)
at com.java1234.util.HibernateUtil.buildSessionFactory(HibernateUtil.java:15)
at com.java1234.util.HibernateUtil.(HibernateUtil.java:10)
at com.java1234.service.StudentTest.(StudentTest.java:18)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:217)
at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:266)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
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)

** END NESTED EXCEPTION **

Last packet sent to the server was 10 ms ago.
at com.mysql.jdbc.Connection.createNewIO(Connection.java:2621)
at com.mysql.jdbc.Connection.(Connection.java:1485)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
at org.hibernate.engine.jdbc.connections.internal.DriverConnectionCreator.makeConnection(DriverConnectionCreator.java:55)
... 37 more

3个回答

My012_
My012_   2016.09.16 18:58

初始化变量错误,你用的什么框架

qq_23039605
qq_23039605   2016.09.17 09:46

它提示了错误原因,看这里 找找看: Caused by: org.hibernate.exception.JDBCConnectionException: Error calling Driver#connect
特别是后面的 driver#connect

u011606457
u011606457   2016.09.19 16:12

数据源配置不对吧,数据库连接失败了

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!
其他相关推荐
该是时候缕缕头绪了
这个头绪,要怎么缕呢,从哪里开始呢? 就从我上学开始吧,都学习了什么,从小学一年级的课本到现在的知识笔记。想想现在的心算能力,已经大不如前了,最简单的例子就是,现在买条鲤鱼,再买两条鲫鱼,给人家100元后,人家找钱,就算不明白了。 小学学习数学、语文、自然、思想、美术、音乐、体育、科学、劳动,不记得还有什么了。 初中学习数学、语文、英语、政治、地理、历史、物理、化学、生物、体育、信息技术。原
要做毕设了,一点头绪没有,怎么办啊?
快毕业了,马上就要交毕设论文,我现在还一点头绪都没有,忙着找工作,现在真是晕死了……呜呜,有高手能帮帮忙吗?毕设题目:视频监控系统中存储管理模块的设计与实现基本要求:1.磁盘容量检测模块的编写2.存储策略选择及数据存储模块的编写 谢谢各位了 !!!!
这几天太忙了?
这几天的工作突然一下变得繁忙起来,刚一坐到办公室,事情就来了,而且感觉有些没有头绪,混乱。不行,我得好好的整理一下,冷静冷静。
junit4单元测试报错解决
junit4进行单元测试时,报错appliactionContext.xml无法加载,在网上找了很多方法都没法解决(一个是看classpath里spring位置,一个是windows属性里先把编译里的一条去掉,保存,在加上)。     后来,问前辈发现问题,有数据库情况,要加入如下代码: @Override @Resource(name = "dataSource") publ
JUnit4单元测试报错问题:method initializationerror not found
今天使用JUnit 4进行单元测试时,测试程序一直运行不起来,报method initializationerror not found错误。
初学C语言,没有头绪,怎么办
【学生来信】老师您好:我很想学好C语言,但又不知道该怎么学,没有头绪。看到那些跟自己同龄的同学,可以编出那么长的程序,真的是很羡慕,但又不知道该怎么做。希望老师给我一些方法吧,谢谢老师。【我的回复】用代码行说话!他们也不是一下子就能写出那么多程序的,你从他们博文中可以看出他们是在持续地努力。写不出来,看。看完了,自己写。可以抄人家的程序调试,调完了,一定抛开参考,自己再来一遍。可能初期会有些不适(
hadoop,sparksql学习过程中遇到的报错及解决方法
四五个月之前学习了hadoop,sparksql,在学习过程中遇到了许多问题,陆续地总结到了word文档中,现在把这些东西放到博客里,虽然都是些基础的问题,但是相信也能够帮助到和我一样刚刚入门的小伙伴们。 我的环境:CentOS 6.4     hadoop-2.6.0-cdh5.7.0    hive-1.1.0-cdh5.7.0     scala2.11.8     spark-2.1
myeclipse 2017 ci 3 破解工具 破解补丁CI激活码
网上都是很多什么save一下文件然后在替换plugins目录,但是一点用都没有,进入后还是试用期5天。我这边就弄了一个绝对可以使用。
感觉自己好没用
       现在工作这么久了,还没有完成那个该死的C++程序,真是郁闷死我了。真的都不好意思在公司呆着了。不想干了。一点信心都没有了。好颓废哦。。。。。虽然已经有了突破口,但是还是完成不了。好郁闷啊。。。。天啊,谁救我啊,问的人,都没有给我看程序的,都是口头的。。。。。哎。。。。命好苦啊。如果一个月内再弄不出,我就辞职不干了。哎。。。。。。。。。。丢人。。。。自己好好想想吧。自己努力吧。工作工作
maven项目配置报错,scala、junit版本报错解决
报错如下: Error:scalac: error while loading JUnit4, Scala signature JUnit4 has wrong version  expected: 5.0  found: 4.1 in JUnit4.class 解决: 创建archetype,注意修改版本为1.6