views:

92

answers:

1

Hi,

I'm getting the following error when I run a webservice client I've created using: eclipse, j2sdk1.4.2_13, axis1.0 and a WSDL file.

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" 

The client is doing this:
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;
    }
        ...     
+3  A: 

You need the servlet Jar in your classpath or use a more recent version of axis.

NOTE: AXIS 1.0 version even on client side needs servlet JAR file or you get this exception: (upcoming 1.1 version should have this fixed)

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

Resources :

Colin Hebert