`

JUnit4使用中发生NoClassDefFoundError: antlr/ANTLRException报错

 
阅读更多

NoClassDefFoundError: antlr/ANTLRException报错问题的修改

 

java.lang.NoClassDefFoundError: antlr/ANTLRException

at org.hibernate.hql.ast.ASTQueryTranslatorFactory.createQueryTranslator(ASTQueryTranslatorFactory.java:27)

at org.hibernate.impl.SessionFactoryImpl.createQueryTranslators(SessionFactoryImpl.java:357)

at org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:423)

at org.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:884)

at org.hibernate.impl.SessionImpl.list(SessionImpl.java:834)

at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)

at org.hibernate.impl.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:603)

at com.msmiles.dao.impl.UserDAOImpl.select(UserDAOImpl.java:28)

at com.msmiles.service.impl.UserServiceImpl.register(UserServiceImpl.java:46)

at com.msmiles.junit.IUserServiceTest.testRegister(IUserServiceTest.java:55)

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

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:597)

at junit.framework.TestCase.runTest(TestCase.java:168)

at junit.framework.TestCase.runBare(TestCase.java:134)

at junit.framework.TestResult$1.protect(TestResult.java:110)

at junit.framework.TestResult.runProtected(TestResult.java:128)

at junit.framework.TestResult.run(TestResult.java:113)

at junit.framework.TestCase.run(TestCase.java:124)

at junit.framework.TestSuite.runTest(TestSuite.java:232)

at junit.framework.TestSuite.run(TestSuite.java:227)

at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:79)

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

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

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

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

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

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

Caused by: java.lang.ClassNotFoundException: antlr.ANTLRException

at java.net.URLClassLoader$1.run(URLClassLoader.java:200)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(URLClassLoader.java:188)

at java.lang.ClassLoader.loadClass(ClassLoader.java:307)

at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)

at java.lang.ClassLoader.loadClass(ClassLoader.java:252)

at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)

... 29 more

 

 

问题原因:

使用subclass配置hibernate的时候,使用父类的service操作数据库时会报如下的错误,其原因是缺少jar包,引入就没有问题了。

 

 

 

解决:

导入包:见附件

 

 

<!--EndFragment-->
  • 大小: 6.7 KB
分享到:
评论

相关推荐

    feed4junit源码

    Feed4JUnit能够让编写JUnit的参数化测试变得简便,并为这些测试提供预定义或随机测试数据。它能够从业务分析人员定义好的CVS或 Excel文件读取测试用例数据并在构建/单元测试框架中报告测试成功。利用Feed4JUnit能够...

    junit-4.11.jar

    JUnit报initializationError的解决方法在新搭建的环境上测试时,一个模块发现错误:java.lang.NoClassDefFoundError:org/hamcrest/SelfDescribing 一看就是缺少Class。多方查找,发现是少了hamcrest包。将hamcrest-...

    Junit5.zip

    此资源包含了junit5的jar包和源码,junit5-r5.4.0.zip 和demo的zip文件,对于测试来说是比较有用的

    最新版本的Struts2+Spring4+Hibernate4框架整合

    同时使用了Struts2、Spring4、Hibernate4、log4j、slf4j、junit4、ehcache等库或框架,搭建一个最基本的项目原型。 三、 三大框架最新版本下载:截止2014-10-01 Struts2.3.6:发布于2014-05-03,目前的最新版本。...

    JUnit 入门教程

    官方Junit教程,益读、清晰.分成多个模块编写,易于学习

    在Eclipse中使用JUnit4进行单元测试

    Ant And Junit 代码 博文链接:https://jimi68.iteye.com/blog/88128

    springmvc+spring+mybatis+maven示例_1.0

    工程名ssmm表示:springmvc+spring+mybatis+maven ...使用Junit4进行单元测试, 使用Log4j管理日志 本例仅为示例,结构简单,不包含Ajax 测试url http://localhost:8080/ssmm_demo/userController/showUser.do?id=1 ...

    测试实践:Eclipse 之 JUnit

    测试实践:Eclipse 之 JUnit 本人所发布的所有资源,请访问以下地址 http://download.csdn.net/user/hahaomi23&lt;br&gt;http://download.csdn.net/user/hahaomi23&lt;br&gt;&lt;br&gt;希望这些资源对大家有所帮助! 如有问题...

    javajunit源码-ant-java-junit:我的页面上的Java单元测试JUnit的源代码:http://jumpstartprog

    java junit源码

    Maven更新失败,Cannot resolve plugin org.apache.maven.plugins:maven-compiler-plugin:3.1

    在apache-maven-3.5.2/conf/setting.xml中加入以下配置即可解决 alimaven aliyun maven http://maven.aliyun.com/nexus/content/repositories/central/ central junit junit Address/ ...

    hamcrest-all-1.0.jar.zip包

    使用JUnit时报错java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing

    windows下eclipse跑junit报错:CreateProcess error=206

    windows下eclipse跑junit报错:CreateProcess error=206后面跟着乱码。 把这个jar替换掉就好了,放在:eclipse/plugins/下面。 参考:https://bugs.eclipse.org/bugs/show_bug.cgi?id=327193

    android junit4

    Debug as android Junit Test 4.Logcat就能看到测试输出 AndroidManifest.xml导入(已做好) 1. &lt;!-- Android JUnit配置 --&gt; &lt;uses-library android:name="android.test.runner" /&gt; 2. targetPackage与上面...

    【JTHarness4_4_0】【需要用到的包】

    JT Harness引用了其他的开源包,并且对包的版本有要求,一定要使用对应的版本,否则可能会出现函数或类找不到的问题,导致编译不通过。下面的包我都会打包放在附件中,不用自己去下载。 引用的jar包 下载地址 说明 ...

    Activiti Designer

    除了可视化设计之外,还可以打包流程资源文件(包括bpmn、png、jar)、自动生成流程测试代码(JUnit)。 版本更新一般在引擎发布后一周左右,支持Eclipse 3.6+。 插件安装地址:...

    Junit 测试

    小的junit的测试实例,mock测试,对spring mvc中“c”的测试

    eclipse中使用junit做单元测试

    junit部署环境 博文链接:https://zhouyunjian.iteye.com/blog/2326046

Global site tag (gtag.js) - Google Analytics