Can you give us the location where you have face with the null. If it is loading the XML file, is it available in your aar.

Thank you

Saminda

Sanjay Vivek wrote:
Hi Saminda,

I tried what you suggested as shown below but I'm getting a
java.lang.NullPointerException when I invoke GrouperWS. What am I doing
wrong? Once again any help would be welcome. 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 stream =
loader.getResourceAsStream(GROUPER_PROPERTIES);
if (stream != null) {
                String  subjectId = "[EMAIL PROTECTED]";
              Subject subject      = SubjectFinder.findById(subjectId);
              String user = subject.getId();
              return user;
                
          } else {
                  return "An error as occured";
          }

        }       
}//end of GrouperWS


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of saminda abeyruwan
Sent: 01 December 2007 13:12
To: [email protected]
Subject: Re: [wsas-java-user] Service impl classes not pickingup referencelibraries.

Hi,

There is a way to load resources on demand without implementing ServiceLifeCycle interface. Let me illustrate this with a simple example.

Web Service :


public class MyWebService {

        public void loadResource(String resourceName) throws AxisFault {
ClassLoader loader = MessageContext.getCurrentMessageContext().getAxisService()
                .getClassLoader().getResourceAsStream(resourceName);

            if (loader != null) {
                  // do something you want
            } else {
// throw an exception or fall back to a default loading mechanism. Option is up to you.
            }
        }       


}

Thus, to load a resource - say your aar file is MyWebService.aar - should contain the resource the way you wanted. ex

MyWebService.arr
       + META-INF
              + services.xml
              + ...
       + lib
             + ...
       + resources
                + foo.xml
                + bar.xml
                + ...

Hence, if you wanted to load bar.xml, invoke the "loadResource" operation with the argument "resources/bar.xml".

HTH

Thank you

Saminda

_______________________________________________
Wsas-java-user mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/wsas-java-user



_______________________________________________
Wsas-java-user mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/wsas-java-user

Reply via email to