线程“main”中的异常 java.lang.NoClassDefFoundError: org/apache/commons/discovery/tools/DiscoverSingleton
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21168432/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/discovery/tools/DiscoverSingleton
提问by b22
here i am trying to make call using webservices via wsdl, while running code getting following exception. showing the testing code as well, please help me out. Thanks.
在这里,我试图通过 wsdl 使用 webservices 进行调用,同时运行代码时出现以下异常。也显示测试代码,请帮帮我。谢谢。
import org.apache.axis.client.Service;
import org.apache.axis.client.Call;
import org.apache.commons.codec.binary.Base64;
import javax.xml.namespace.QName;
import java.net.URL;
public class WebTest {
Service service = null;
String endpoint = "http://mytest.com/test/Signup.jws";
String userName = "globel";
String userPw = new String(Base64.decodeBase64("Z23fG46732345FG=".getBytes()));;
public WebTest() {
try {
service = new Service();
System.out.println("*** executed successfully ");
} catch (Exception e) {
System.out.println("Exception - " + e.getMessage());
}
}
public void testWeb(String f1, String f2, String f3, int itemcode, String f4){
try {
Call call = (Call)service.createCall();
call.setTargetEndpointAddress(new URL(endpoint));
call.setOperationName(new QName("emp"));
call.setUsername(userName);
call.setPassword(userPw);
Object[] params = new Object[5];
params[0] = new String(f1);
params[1] = new String(f2);
params[2] = new String(f3);
params[3] = new Integer(itemcode);
params[4] = new String(f4);
call.invoke(params);
} catch (Exception e) {
System.out.println("Exception - " + e.getMessage());
}
}
public static void main(String[] args) {
String orderDate = "03-Jan-2013";
WebTest webtest= new WebTest() ;
webtest.testWeb("rayban","aviator",orderDate,82724,"113000") ;
}
}
getting following error -
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.(LogFactory.java:33) at org.apache.axis.handlers.BasicHandler.(BasicHandler.java:43) at org.apache.axis.client.Service.getAxisClient(Service.java:207) at org.apache.axis.client.Service.(Service.java:225)
得到以下错误 -
线程“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.(LogFactory.java:33) at org .apache.axis.handlers.BasicHandler.(BasicHandler.java:43) at org.apache.axis.client.Service.getAxisClient(Service.java:207) at org.apache.axis.client.Service.(Service.java) :225)
回答by b22
Added discovery-0.4.jar to my code and it resolved my problem.
在我的代码中添加了 discovery-0.4.jar,它解决了我的问题。
回答by ErisoHV
in my case I added commons-discovery-0.2.jar
就我而言,我添加了 commons-discovery-0.2.jar
回答by Imran.Khan
For maven users: add commons-discovery dependency to your pom.xml file e.g
对于 maven 用户:将 commons-discovery 依赖项添加到您的 pom.xml 文件中,例如
<dependency>
<groupId>commons-discovery</groupId>
<artifactId>commons-discovery</artifactId>
<version>0.4</version>
</dependency>
回答by Murat Melek
Add pom.xml
添加 pom.xml
<dependency>
<groupId>commons-discovery</groupId>
<artifactId>commons-discovery</artifactId>
<version>0.5</version>
</dependency>