Hi Deepal,
I found that the cause of NPE is "unassinged parent". If the service is
already registered in axisConfig it doesn't enter in the code that
assings a parent to the service. Also, it doesn't uses the parent of
the registered service.
The code causes NPE is here:
----------------------------------------------------------------
// org.apache.axis2.client.ServiceClient
public ServiceClient(ConfigurationContext configContext,
AxisService axisService) throws AxisFault {
...
// If the service is already registered, it doesn't enter
// here so there will be no parent.
if (this.axisConfig.getService(this.axisService.getName()) == null) {
this.axisConfig.addService(this.axisService);
}
ServiceGroupContext sgc = new ServiceGroupContext(this.configContext,
(AxisServiceGroup) this.axisService.getParent());
this.serviceContext = sgc.getServiceContext(this.axisService);
}
----------------------------------------------------------------
Here is the my way of passing this problem:
----------------------------------------------------------------
// org.apache.axis2.client.ServiceClient
public ServiceClient(ConfigurationContext configContext,
AxisService axisService) throws AxisFault {
...
AxisService service = null;
AxisService registeredService =
this.axisConfig.getService(this.axisService.getName());
if (registeredService != null) {
service = registeredService;
} else {
this.axisConfig.addService(this.axisService);
service = this.axisService;
}
ServiceGroupContext sgc = new ServiceGroupContext(this.configContext,
(AxisServiceGroup) service.getParent());
this.serviceContext = sgc.getServiceContext(service);
}
----------------------------------------------------------------
But I'm still having an exception that says:
----------------------------------------------------------------
...
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
[ERROR]
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/axis2].[jsp]
- Servlet.service() for servlet jsp threw exception
java.lang.IllegalStateException: getOutputStream() has already been
called for this response
at org.apache.catalina.connector.Response.getWriter(Response.java:606)
at
org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:195)
at
org.apache.jasper.runtime.JspWriterImpl.initOut(JspWriterImpl.java:124)
----------------------------------------------------------------
Thanks,
Ali Sadik Kumlali
--- Ali Sadik Kumlali <[EMAIL PROTECTED]> wrote:
> Deepal,
>
> I've just tried it with axis2 war distribution (RC5) and got NPE.
>
> Here is my code snippet that uses ListenerManager:
>
> ---------------------------------------------------------
> System.out.println("ListenerManager.defaultConfigurationContext: " +
> ListenerManager.defaultConfigurationContext);
>
System.out.println("ListenerManager.defaultConfigurationContext.getServiceGroupContexts():
> " +
>
ListenerManager.defaultConfigurationContext.getServiceGroupContexts());
> com.mycompany.service.test.account.AccountServicesStub stub = new
>
com.mycompany.service.test.account.AccountServicesStub(ListenerManager.defaultConfigurationContext,
> targetEndpoint);
> ---------------------------------------------------------
>
> Here is the output:
>
> ---------------------------------------------------------
> ListenerManager.defaultConfigurationContext:
> [EMAIL PROTECTED]
>
ListenerManager.defaultConfigurationContext.getServiceGroupContexts():
> {}
> java.lang.NullPointerException
> at
>
org.apache.axis2.context.ServiceGroupContext.getServiceContext(ServiceGroupContext.java:59)
> at
> org.apache.axis2.client.ServiceClient.<init>(ServiceClient.java:101)
> at
>
com.mycompany.service.test.account.AccountServicesStub.<init>(AccountServicesStub.java:329)
> at
> ...
> ---------------------------------------------------------
>
> What I've seen from the output is
> ListenerManager.defaultConfigurationContext is successfully set as
> it's
> not null. But I cannot think furthermore :-)
>
> What should I do?
>
> Thanks a lot.
>
> Ali Sadik Kumlali
>
>
> --- Ali Sadik Kumlali <[EMAIL PROTECTED]> wrote:
>
> > Thanks Deepal. I'll try it with 1.0 RC3 and let you know the
> result.
> >
> > Best regards,
> >
> > Ali Sadik Kumlali
> >
> > --- Deepal Jayasinghe <[EMAIL PROTECTED]> wrote:
> >
> > > You can have this with Axis2 RC or above :)
> > >
> > > You have to follow the following procedure for doing this
> > > - When you creating stub , it has a constructor which take
> > > configuration context as argument.
> > > - So pass that as "ListenerManager.defaultConfigurationContext"
> > > - In this case client will be created using server
> configuration
> > > context
> > > - And this will work in axis2 war distribution out of the box
> > >
> > > Note : In the case of AxisServlet , it will create a
> > ListenerManager
> > > and
> > > will set defaultConfigurationContext as the server configuration
> > > context.
> > >
> > > If you are using some other thing say simpleHTTPServer then you
> > have
> > > to
> > > do the following procedure.
> > > - Create a ConfigurationConetx using some axis2.xml and that
> > > axis2.xml can have all the transport listeners that you want
> > > - Then create a ListenerManager
> > > - and call startSystem
> > > - and finally
> > > ListenerManager.defaultConfigurationContext=
> > > configurationcotext;
> > >
> > > Ali Sadik Kumlali wrote:
> > >
> > > >Hi all,
> > > >
> > > >Since there is no response yet, I assume that my posting had a
> > lack
> > > of
> > > >information :)
> > > >
> > > >Here is my scenario:
> > > >1) I have serviceA.wsdl and serviceB.wsdl.
> > > >2) I generate skeletons and stubs with WSDL2Java
> > > >3) I have serviceA.aar which has serviceB.wsdl's stub
> > > >4) When I call serviceB's stub from a class found in
> serviceA.aar,
> > > my
> > > >soap message does not have addressing and security headers.
> > > >5) When I explicitly pass a repository location to constructor
> of
> > > >serviceB's stub, it fails saying double initialization of
> > addressing
> > > >and security modules.
> > > >6) It cannot find the modules and gives me error when I try to
> > > engage
> > > >the addressing and security modules by following code:
> > > > stubB._getServiceClient().engageModule(new
> QName("addressing"));
> > > > stubB._getServiceClient().engageModule(new QName("security"));
> > > >
> > > >Thanks again.
> > > >
> > > >Ali Sadik Kumlali
> > > >
> > > >
> > > >--- Ali Sadik Kumlali <[EMAIL PROTECTED]> wrote:
> > > >
> > > >
> > > >
> > > >>Hi all,
> > > >>
> > > >>I need my service to call another service. But, it somehow
> cannot
> > > see
> > > >>modules and thus doesn't add security/addressing headers.
> > > >>
> > > >>I tried engaging the modules manually as in test client. But,
> it
> > > >>couldn't find the modules.
> > > >>
> > > >>Any help would be appreciated.
> > > >>
> > > >>Thanks,
> > > >>
> > > >>Ali Sadik Kumlali
> > > >>
> > > >>__________________________________________________
> > > >>Do You Yahoo!?
> > > >>Tired of spam? Yahoo! Mail has the best spam protection around
>
> > > >>http://mail.yahoo.com
> > > >>
> > > >>
> > > >>
> > > >
> > > >
> > > >__________________________________________________
> > > >Do You Yahoo!?
> > > >Tired of spam? Yahoo! Mail has the best spam protection around
> > > >http://mail.yahoo.com
> > > >
> > > >
> > > >
> > > >
> > >
> > > --
> > > Thanks,
> > > Deepal
> > > ................................................................
> > > ~Future is Open~
> > >
> > >
> > >
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam? Yahoo! Mail has the best spam protection around
> > http://mail.yahoo.com
> >
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com