Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2005

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Major - 25 Nov 2005 09:00 GMT
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 ?
John C. Bollinger - 25 Nov 2005 17:47 GMT
> Iam getting java.lang.NoClassDefFoundError:
> javax/servlet/ServletContext exception while invoking the service
[quoted text clipped - 25 lines]
> 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.

Signature

John Bollinger
jobollin@indiana.edu

Major - 28 Nov 2005 06:22 GMT
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
John C. Bollinger - 29 Nov 2005 03:15 GMT
> 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.

Signature

John Bollinger
jobollin@indiana.edu



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.