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

Discussion in 'Java' started by Major, Nov 25, 2005.

  1. Major

    Major Guest

    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 ?
     
    Major, Nov 25, 2005
    #1
    1. Advertising

  2. Re: java.lang.NoClassDefFoundError: javax/servlet/ServletContextin AXIS client

    Major wrote:
    > 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.

    --
    John Bollinger
     
    John C. Bollinger, Nov 25, 2005
    #2
    1. Advertising

  3. Major

    Major Guest

    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
     
    Major, Nov 28, 2005
    #3
  4. Re: java.lang.NoClassDefFoundError: javax/servlet/ServletContextin AXIS client

    Major wrote:
    > 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.

    --
    John Bollinger
     
    John C. Bollinger, Nov 29, 2005
    #4
  5. Major

    johnrambo

    Joined:
    Mar 11, 2008
    Messages:
    1
    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 ?
     
    johnrambo, Mar 11, 2008
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    10,367
  2. rhimbo
    Replies:
    0
    Views:
    5,507
    rhimbo
    Mar 16, 2006
  3. Replies:
    1
    Views:
    2,179
    Irmen de Jong
    Jun 22, 2004
  4. Andrew Thompson

    javax.servlet and javax.servlet.http

    Andrew Thompson, Apr 24, 2007, in forum: Java
    Replies:
    1
    Views:
    683
    newbie_at_tomcat
    Apr 25, 2007
  5. Lew
    Replies:
    1
    Views:
    623
    newbie_at_tomcat
    Apr 25, 2007
Loading...

Share This Page