运行webservice客户端时的java.lang.NoClassDefFoundError

时间:2010-09-02 14:17:30

标签: java eclipse exception webservice-client

当我运行我使用的web服务客户端时,我收到以下错误:eclipse,j2sdk1.4.2_13,axis1.0和WSDL文件。

java.lang.NoClassDefFoundError: javax/servlet/ServletContext
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:1655)
    at java.lang.Class.getDeclaredMethod(Class.java:1262)
    at org.apache.commons.discovery.tools.ClassUtils.findPublicStaticMethod(ClassUtils.java:116)
    at org.apache.axis.configuration.EngineConfigurationFactoryFinder.newFactory(EngineConfigurationFactoryFinder.java:214)
    at org.apache.axis.configuration.EngineConfigurationFactoryFinder.access$300(EngineConfigurationFactoryFinder.java:92)
    at org.apache.axis.configuration.EngineConfigurationFactoryFinder$1.run(EngineConfigurationFactoryFinder.java:179)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.apache.axis.configuration.EngineConfigurationFactoryFinder.newFactory(EngineConfigurationFactoryFinder.java:148)
    at org.apache.axis.configuration.EngineConfigurationFactoryFinder.newFactory(EngineConfigurationFactoryFinder.java:204)
    at org.apache.axis.client.Service.<init>(Service.java:111)
    at com.example.xmlns.SOAPEventSourceBindingStub.<init>(SOAPEventSourceBindingStub.java:27)
    at com.example.xmlns.SOAPEventSourceBindingStub.<init>(SOAPEventSourceBindingStub.java:17)
    at com.example.xmlns.Cliente.main(Cliente.java:16)
Exception in thread "main" 

客户这样做:
  SOAPEventSourceBindingStub stub = new SOAPEventSourceBindingStub();

public SOAPEventSourceBindingStub() throws org.apache.axis.AxisFault {
     this(null); (this is line 17)
}

public SOAPEventSourceBindingStub(java.net.URL endpointURL, javax.xml.rpc.Service service) throws org.apache.axis.AxisFault {
     this(service);
     super.cachedEndpoint = endpointURL;
}

public SOAPEventSourceBindingStub(javax.xml.rpc.Service service) throws org.apache.axis.AxisFault {
    if (service == null) {
        super.service = new org.apache.axis.client.Service(); (this is line 27)
    } else {
        super.service = service;
    }
        ...     

2 个答案:

答案 0 :(得分:3)

您需要在类路径中使用servlet Jar或使用更新版本的轴。

  

注意:即使在客户端,AXIS 1.0版本也需要servlet JAR文件,否则会出现以下异常:    (即将发布的1.1版应该有此修复)

Exception in thread "main" java.lang.NoClassDefFoundError: javax/servlet/ServletContext
     at java.lang.Class.getDeclaredMethods0(Native Method)
     at java.lang.Class.privateGetDeclaredMethods(Class.java:1613)
     at java.lang.Class.getMethod0(Class.java:1732)
     at java.lang.Class.getDeclaredMethod(Class.java:1219)
     ...

资源:

答案 1 :(得分:0)

桌面应用程序存在类似问题。在Netbeans中,这突然出现了,尽管我只更改了不相关的SQL查询。问题包仍然在我的主要包中,但找不到。

解决了在我的主程序包中重命名有问题的类(并在需要时重命名)。同样更正了命名标准偏差(某些类名首字母是低位的)。