2010-09-02 124 views
0

當我運行一個使用eclipse,j2sdk1.4.2_13,axis1.0和WSDL文件創建的webservice客戶端時,出現以下錯誤。運行webservice客戶端時發生java.lang.NoClassDefFoundError

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; 
    } 
     ...  
+0

你確定你沒有錯過一個圖書館嗎?確保所有的庫都在你的類路徑中。 – 2010-09-02 14:19:30

回答

3

您需要的servlet罐子在classpath或使用軸的最新版本。

注: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) 
    ... 

資源:

0

與桌面應用程序有類似的問題。在Netbeans中,這突然出現了,儘管我只改變了無關的sql查詢。有問題的軟件包仍然在我的主要軟件包中,儘管找不到。

解決了重命名有問題的類在我的主包(和重命名回來,如果需要)。還修正了命名標準偏差(一些類名的第一個字母是低的)。

相關問題