有包,还是报
ClassNotFoundException项目中有,commons-logging-1.1.1.jar但是还是报
Caused by: java.lang.ClassNotFoundException: org.apache.commons.discovery.tools.DiscoverSingleton
出现这种状况的原因:
我在一个类 A--- Bill99CheckingJob 里要用另一个类 B ---- GatewayPayOrderQueryServiceLocator
我在类A 里new B,并且给B的属性赋值、
在new 的时候,出错了。
Exception in thread "main"
java.lang.NoClassDefFoundError: org/apache/commons/discovery/tools/DiscoverSingleton
at org.apache.axis.components.logger.LogFactory$1.run(LogFactory.java:45)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.axis.components.logger.LogFactory.getLogFactory(LogFactory.java:41)
at org.apache.axis.components.logger.LogFactory.<clinit>(LogFactory.java:33)
at org.apache.axis.handlers.BasicHandler.<clinit>(BasicHandler.java:43)
at org.apache.axis.client.Service.getAxisClient(Service.java:104)
at org.apache.axis.client.Service.<init>(Service.java:113)
at com.caitong.payment.bean.bill99.GatewayPayOrderQueryServiceLocator.<init>(GatewayPayOrderQueryServiceLocator.java:12)
at com.caitong.payment.scheduler.umpAndBill99Card.Bill99CheckingJob.<init>(Bill99CheckingJob.java:62)
at com.caitong.payment.scheduler.PayCheckingJob.payCheck(PayCheckingJob.java:135)
at com.caitong.payment.scheduler.PayCheckingJob.invokeMethod(PayCheckingJob.java:76)
at com.caitong.payment.scheduler.PayCheckingJob.main(PayCheckingJob.java:390)
Caused by:
java.lang.ClassNotFoundException: org.apache.commons.discovery.tools.DiscoverSingleton
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 12 more
ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2
JDWP exit error AGENT_ERROR_NO_JNI_ENV(183): [../../../src/share/back/util.c:820]
类B中有一个空的构造方法,还有好几个带参数的
------解决方案--------------------
报错说的是没有找到“java.lang.Class
NotFoundException: org.apache.commons.discovery.tools.DiscoverSingleton”,跟commons-logging-1.1.1.jar有啥关系?
请下载commons-discovery.jar
------解决方案--------------------new的时候出错基本就可以确定是缺少包了!!!楼主缺少的是org.apache.commons.discovery.tools.DiscoverSingleton
,你需要去lib里好好查看下了。。。
------解决方案--------------------org/apache/commons/discovery/tools/DiscoverSingleton
这个类在commons-logging-1.1.1.jar包里不存在吧,你看看该包里是否存在?
------解决方案--------------------遇到这种问题直接百度或者google类名,就知道是那个包了。
------解决方案--------------------楼主被群殴了,我还以为是确确实实有对应的包,然后new不出来呢。如果确实是这样的问题,那就重新编译项目,基本上这样就行了
------解决方案--------------------www.findjar.com org.apache.commons.discovery.tools.DiscoverSingleton
------解决方案--------------------细心下哈,确认下这个jar包吧
不过有时会发生,那就重新编译下项目就好了