日期:2014-05-20  浏览次数:20748 次

求助,java.lang.NoClassDefFoundError错误?
学习webservice中即时发布的一个例子;即时发布包含服务端和客户端。客户端的例子代码如下:
code=Java]package webservice;

import java.rmi.RemoteException;

import javax.xml.namespace.QName;
import javax.xml.rpc.ServiceException;

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;


public class ClientJWS {

public static void main(String[] args) {
try{
String url = "http://127.0.0.1:8080/axis/Helloworld.jws";
Service serv = new Service();
Call call = (Call) serv.createCall();
call.setTargetEndpointAddress(url);
call.setOperationName(new QName(url,"test"));
String result = (String)call.invoke(new Object[]{"Quahilong",100});

System.out.println("result = "+result);
}catch(ServiceException e){
e.printStackTrace();
}catch(RemoteException e){
e.printStackTrace();
}
}
}[/code]
运行时出现错误:
Java code
Exception in thread "main" java.lang.NoClassDefFoundError: org.apache.commons.logging.LogFactory
    at org.apache.axis.components.logger.LogFactory.class$(LogFactory.java:45)
    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 webservice.ClientJWS.main(ClientJWS.java:17)


请问怎么解决啊?!

------解决方案--------------------
org.apache.commons.logging.LogFactory
这个类所在的jar包引进来了么?
建议楼主先把基础打好。
------解决方案--------------------
在struts2的LIB包里加入:
commons-logging-1.0.4.jar
commons-logging-api-1.1.jar