java.lang.NoClassDefFoundError: javax/servlet/ServletContext in AXIS client

M

Major

Hi all,
Iam getting java.lang.NoClassDefFoundError:
javax/servlet/ServletContext exception while invoking the service
deployed on websphere v5.1 from a dynamic axis client. Prior to that I
resolved the NoClassDefFoundError for LogFactory and DiscoverSingleton
classes by adding the commons-logging and commons-discover jars in
classpath. Below is the stack trace -

Exception in thread "main" java.lang.NoClassDefFoundError:
javax/servlet/ServletContext
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2365)
at java.lang.Class.getDeclaredMethod(Class.java:1907)
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)

Usually the cause for such exception is missing servlet.jar.
Can anybody point out what would be problem ?
 
J

John C. Bollinger

Major said:
Iam getting java.lang.NoClassDefFoundError:
javax/servlet/ServletContext exception while invoking the service
deployed on websphere v5.1 from a dynamic axis client. Prior to that I
resolved the NoClassDefFoundError for LogFactory and DiscoverSingleton
classes by adding the commons-logging and commons-discover jars in
classpath. Below is the stack trace -

Exception in thread "main" java.lang.NoClassDefFoundError:
javax/servlet/ServletContext
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2365)
at java.lang.Class.getDeclaredMethod(Class.java:1907)
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)

Usually the cause for such exception is missing servlet.jar.
Can anybody point out what would be problem ?

I don't quite understand what your client is trying to do, but something
is very fishy here. If the client has any reason to access a
ServletContext then it needs to be properly deployed in a servlet
container, and the container should be providing the servlet API to it.
I can't tell whether your client needs to run inside a servlet
container and you're trying to run it some other way, or whether it just
is incorrect in attempting to access a ServletContext; if I had to
guess, though, I would guess the former.
 
M

Major

The client is plain java class. Even this is very surprising to me also
that why it is demanding for a ServletContext. This is very apparent
with the code below -

import javax.xml.namespace.QName;

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

public class dynamicAxisClient {

public static void main(String[] args)
{
try {
String endpoint
="http://localhost:9080/TestWS/services/TestService?WSDL";
//ServiceFactory serviceFactory = (ServiceFactory)
ServiceFactory.newInstance();
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress( new java.net.URL(endpoint));
call.setOperationName(new QName("greetGuest"));
String[] param = new String[1];
param[0]= "Major";
String ret = (String) call.invoke(args );
System.out.println("The Return Xml is " + ret + "\n");
} catch (Exception e) {
System.err.println(e.toString());
}
}
}

Thanks for replying
 
J

John C. Bollinger

Major said:
The client is plain java class. Even this is very surprising to me also
that why it is demanding for a ServletContext. This is very apparent
with the code below -

[code elided]

You may have discovered an Axis bug, though I am not sufficiently expert
with Axis to be sure one way or another. I don't see any special reason
why a web services client should need to have the servlet API available
to it, though. A quick perusal of the Axis docs did not illuminate me
in this regard. I suggest you check the bug database and consider
submitting a bug report if this problem has not already been reported.
 
Joined
Mar 11, 2008
Messages
1
Reaction score
0
Facing the same problem

Hi

I am facing the same problem.I tried to invoke a web service which is created using Axis but the invocation code doesnt use the classess/methods of Axis. I just created an object for the proxy and then invoked the methods.
Can you please let me know how you solved the problem ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top