You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Sanjay Vivek <Sa...@newcastle.ac.uk> on 2007/12/07 13:33:05 UTC

java.lang.NoClassDefFoundError exception. Service impl class not picking up external jars in /lib.

Hi everyone,

I'm attempting to deploy a Web Service from a simple Java class by
creating a service archive and deploying it to WSAS (Web Services
Application Server).

However, I'm having trouble invoking this service. The structure of my
service is given below (which I then deployed as an .aar file):

- Grouper.aar
  - META-INF
    - services.xml
  - lib
     - *.jar 

  - conf
    - sources.xml

  - test
    - GrouperWS.class


However, GrouperWS.class is not seeing the lib/*.jar in its classpath. I
get java.lang.NoClassDefFoundError exceptions when I invoke GrouperWS.
I've followed the advice given previously in this mailing list but to no
avail. I would really appreciate any insight or help in this matters. My
services.xml and GrouperWS.java is provided below for added clarity.
Cheers.

Regards
Sanjay

package test;

import java.io.InputStream;

import org.apache.axis2.AxisFault;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.description.AxisService;

import edu.internet2.middleware.grouper.SubjectFinder;
import edu.internet2.middleware.subject.Subject;
import edu.internet2.middleware.subject.SubjectNotFoundException;
import edu.internet2.middleware.subject.SubjectNotUniqueException;

public class GrouperWS {
	
private final static String GROUPER_PROPERTIES = "conf/sources.xml";
	
	public String loadResource() throws AxisFault,
SubjectNotFoundException, SubjectNotUniqueException{
		
		MessageContext context =
MessageContext.getCurrentMessageContext(); 
		AxisService service = context.getAxisService();
		ClassLoader loader = service.getClassLoader();
	    InputStream in =
loader.getResourceAsStream(GROUPER_PROPERTIES);
	    
             if (in != null) {
            	 
           	      String  subjectId = "carlos.tevez@hotmail.com";
           	      Subject subject      =
SubjectFinder.findById(subjectId);
           	      String user = subject.getId();
           	      return user;
           	      
             } else {
                   return "An error as occured";
             }
	} 	


} //end of GrouperWS


<service name="Grouper" scope="application">
    <description>
        This is the Grouper Service
    </description>
    <parameter name="ServiceTCCL">composite</parameter>
    <messageReceivers>
        <messageReceiver 
            mep="http://www.w3.org/2004/08/wsdl/in-only"
    class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"/>
        <messageReceiver
            mep="http://www.w3.org/2004/08/wsdl/in-out"
    class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
    </messageReceivers>
    <parameter name="ServiceClass">
        test.GrouperWS
    </parameter>
</service>


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


RE: java.lang.NoClassDefFoundError exception. Service impl class not picking up external jars in /lib.

Posted by Sanjay Vivek <Sa...@newcastle.ac.uk>.
I'm getting the exception at "Subject subject =
SubjectFinder.findById(subjectId)", which is the first instance when
GrouperWS tries to find an external class. This external class is found
in one of the jar files found in the lib folder. 

The class in question is
"edu.internet2.middleware.grouper.SubjectFinder". However, GrouperWS
can't see it in its classpath. 

Regards
Sanjay

>-----Original Message-----
>From: mgainty@hotmail.com [mailto:mgainty@hotmail.com] 
>Sent: 07 December 2007 14:56
>To: axis-user@ws.apache.org
>Subject: Re: java.lang.NoClassDefFoundError exception. Service 
>impl class not picking up external jars in /lib.
>
>which class produces the CNFE?
>
>M-

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: java.lang.NoClassDefFoundError exception. Service impl class not picking up external jars in /lib.

Posted by mg...@hotmail.com.
which class produces the CNFE?

M-
----- Original Message -----
Wrom: LHPQQWOYIYZUNNYCGPKYLEJGDGVCJVTLBXFGGMEPYOQKE
To: <ax...@ws.apache.org>
Sent: Friday, December 07, 2007 7:33 AM
Subject: java.lang.NoClassDefFoundError exception. Service impl class not
picking up external jars in /lib.


Hi everyone,

I'm attempting to deploy a Web Service from a simple Java class by
creating a service archive and deploying it to WSAS (Web Services
Application Server).

However, I'm having trouble invoking this service. The structure of my
service is given below (which I then deployed as an .aar file):

- Grouper.aar
  - META-INF
    - services.xml
  - lib
     - *.jar

  - conf
    - sources.xml

  - test
    - GrouperWS.class


However, GrouperWS.class is not seeing the lib/*.jar in its classpath. I
get java.lang.NoClassDefFoundError exceptions when I invoke GrouperWS.
I've followed the advice given previously in this mailing list but to no
avail. I would really appreciate any insight or help in this matters. My
services.xml and GrouperWS.java is provided below for added clarity.
Cheers.

Regards
Sanjay

package test;

import java.io.InputStream;

import org.apache.axis2.AxisFault;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.description.AxisService;

import edu.internet2.middleware.grouper.SubjectFinder;
import edu.internet2.middleware.subject.Subject;
import edu.internet2.middleware.subject.SubjectNotFoundException;
import edu.internet2.middleware.subject.SubjectNotUniqueException;

public class GrouperWS {

private final static String GROUPER_PROPERTIES = "conf/sources.xml";

public String loadResource() throws AxisFault,
SubjectNotFoundException, SubjectNotUniqueException{

MessageContext context =
MessageContext.getCurrentMessageContext();
AxisService service = context.getAxisService();
ClassLoader loader = service.getClassLoader();
    InputStream in =
loader.getResourceAsStream(GROUPER_PROPERTIES);

             if (in != null) {

                 String  subjectId = "carlos.tevez@hotmail.com";
                 Subject subject      =
SubjectFinder.findById(subjectId);
                 String user = subject.getId();
                 return user;

             } else {
                   return "An error as occured";
             }
}


} //end of GrouperWS


<service name="Grouper" scope="application">
    <description>
        This is the Grouper Service
    </description>
    <parameter name="ServiceTCCL">composite</parameter>
    <messageReceivers>
        <messageReceiver
            mep="http://www.w3.org/2004/08/wsdl/in-only"
    class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"/>
        <messageReceiver
            mep="http://www.w3.org/2004/08/wsdl/in-out"
    class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
    </messageReceivers>
    <parameter name="ServiceClass">
        test.GrouperWS
    </parameter>
</service>


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org