You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by Lorenzo Bolzani <l....@gmail.com> on 2010/07/14 17:01:31 UTC

CxfSeEndpoint NPE, InOut?

Hi all.

I'm wrtiting a simple web service and I have a NPE. I'm running smix 3.3.1
and I cannot find the right sources for this version so it's quite hard to
debug it myself.

This is the service  definition

@WebService(serviceName = "PECService", targetNamespace = "
http://www.klever.it/kdv/pec/ws")
@SOAPBinding(style = SOAPBinding.Style.DOCUMENT, use =
SOAPBinding.Use.LITERAL, parameterStyle =
SOAPBinding.ParameterStyle.WRAPPED)
public class PECService {

    @WebMethod(operationName = "sendMessage", action = "urn:sendMessage")
    public void sendMessage(
            @WebParam(name = "to", targetNamespace = "
http://www.klever.it/kdv/pec/ws") String to,
            @WebParam(name = "document", targetNamespace = "
http://www.klever.it/kdv/pec/ws") Document document) throws
PECServiceException {

        System.out.println("sendMessage");

        PECMailService mailService = new PECMailService();
        mailService.send(to, document);
    }
}

the wsdl is generated with jaxws. This is the endpoint definition

    <cxfse:endpoint mtomEnabled="true" useJBIWrapper="false">
        <cxfse:pojo>
            <bean class="it.klever.kdv.pec.PECService" />
        </cxfse:pojo>
    </cxfse:endpoint>

and this is the consumer definition

  <cxfbc:consumer wsdl="classpath:wsdl/PECService.wsdl"
                      targetService="pec:PECService"
                      targetInterface="pec:PECServicePort"
                      locationURI="http://localhost:8092/PECService/"
                      mtomEnabled="true" useJBIWrapper="false" />

This is what I get on the console when I call it with a jaxws generated
client.

INFO  - JBITransportFactory            - configuring DeliveryChannel:
org.apache.servicemix.common.EndpointDeliveryChannel@2310ff2b
ERROR - CxfSeComponent                 - Error processing exchange InOut[
  id: ID:127.0.1.1-129d12553b7-29:6
  status: Active
  role: provider
  interface: {http://www.klever.it/kdv/pec/ws}PECServicePort
  service: {http://www.klever.it/kdv/pec/ws}PECService
  endpoint: PECServicePort
  operation: {http://www.klever.it/kdv/pec/ws}sendMessage
  in: <?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:soap="
http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns3:sendMessage
xmlns:ns3="http://www.klever.it/kdv/pec/ws" xmlns:ns2="
http://www.klever.it/kdv/registry"><ns3:to>aaa</ns3:to><ns3:document
ns2:name="pippo"/></ns3:sendMessage></soap:Body></soap:Envelope>
]
java.lang.NullPointerException
    at
org.apache.servicemix.cxfse.CxfSeEndpoint.process(CxfSeEndpoint.java:359)
    at
org.apache.servicemix.common.AsyncBaseLifeCycle.doProcess(AsyncBaseLifeCycle.java:627)
    at
org.apache.servicemix.common.AsyncBaseLifeCycle.processExchange(AsyncBaseLifeCycle.java:581)
    at
org.apache.servicemix.common.AsyncBaseLifeCycle.onMessageExchange(AsyncBaseLifeCycle.java:535)
    at
org.apache.servicemix.common.SyncLifeCycleWrapper.onMessageExchange(SyncLifeCycleWrapper.java:60)
    at
org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.processInBound(DeliveryChannelImpl.java:623)
    at
org.apache.servicemix.jbi.nmr.flow.AbstractFlow.doRouting(AbstractFlow.java:172)
    at
org.apache.servicemix.jbi.nmr.flow.seda.SedaFlow.doRouting(SedaFlow.java:168)
    at
org.apache.servicemix.jbi.nmr.flow.seda.SedaQueue$1.run(SedaQueue.java:134)
    at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:651)
    at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:676)
    at java.lang.Thread.run(Thread.java:595)
INFO  - PhaseInterceptorChain          - Interceptor has thrown exception,
unwinding now null


I noticed that it is trying to do a InOut exchange where I expect an InOnly
one. Could this be the problem?


Thanks in advance.


Bye

Lorenzo

Re: CxfSeEndpoint NPE, InOut?

Posted by Freeman Fang <fr...@gmail.com>.
On 2010-7-16, at 下午6:39, Lorenzo Bolzani wrote:

> 2010/7/16 Freeman Fang <fr...@gmail.com>
>
>>
>> Hi,
>>
>> Could you please use java2wsdl tool from apache cxf instead?
>> You can use the tool from CLI or maven plugin.
>>
>> Take a look at [1] to get more details.
>>
>> [1]http://cxf.apache.org/docs/java-to-wsdl.html
>>
>>
> Ok, I'll try with this one too.
>
> In the meantime I "fixed" the problem changing the targetInterface  
> value
> from PECServicePort to PECService in the cxfbc:consumer.
>
>  <cxfbc:consumer wsdl="classpath:wsdl/PECService.wsdl"
>                      targetService="pec:PECService"
>                      targetInterface="pec:PECService"
>                      locationURI="http://localhost:8092/PECService/"
>                      mtomEnabled="true" useJBIWrapper="false" />
>
> I think this is quite an hack, but I think was worth to report in case
> others could have a similar issue.
Hi,

Ok, I'm not aware that you specify targetInterface as PECServicePort  
previously, I think this should be the problem.
The port name (PECServicePort for your case) used in the wsdl should  
map tp the targetEndpoint but not the targetInterface, the  
targetInterface should be the portType name from wsdl.

Freeman
>
>
> Thanks, bye
>
> Lorenzo


-- 
Freeman Fang

------------------------
Open Source SOA: http://fusesource.com
Apache Servicemix:http://servicemix.apache.org
Apache Cxf: http://cxf.apache.org
Apache Karaf: http://karaf.apache.org
Apache Felix: http://felix.apache.org


Re: CxfSeEndpoint NPE, InOut?

Posted by Lorenzo Bolzani <l....@gmail.com>.
2010/7/16 Freeman Fang <fr...@gmail.com>

>
> Hi,
>
> Could you please use java2wsdl tool from apache cxf instead?
> You can use the tool from CLI or maven plugin.
>
> Take a look at [1] to get more details.
>
> [1]http://cxf.apache.org/docs/java-to-wsdl.html
>
>
Ok, I'll try with this one too.

In the meantime I "fixed" the problem changing the targetInterface value
from PECServicePort to PECService in the cxfbc:consumer.

  <cxfbc:consumer wsdl="classpath:wsdl/PECService.wsdl"
                      targetService="pec:PECService"
                      targetInterface="pec:PECService"
                      locationURI="http://localhost:8092/PECService/"
                      mtomEnabled="true" useJBIWrapper="false" />

I think this is quite an hack, but I think was worth to report in case
others could have a similar issue.


Thanks, bye

Lorenzo

Re: CxfSeEndpoint NPE, InOut?

Posted by Freeman Fang <fr...@gmail.com>.
On 2010-7-16, at 下午6:19, Lorenzo Bolzani wrote:

> 2010/7/15 Freeman Fang <fr...@gmail.com>
>
>>
>>> The servicemix-cxf-bc code used for smx 3.3.1 is here[1]
>> the servicemix-cxf-se code used for smx 3.3.1 is here[2]
>> [1]
>> https://svn.apache.org/repos/asf/servicemix/components/bindings/servicemix-cxf-bc/tags/servicemix-cxf-bc-2009.01/
>> [2]
>> https://svn.apache.org/repos/asf/servicemix/components/engines/servicemix-cxf-se/tags/servicemix-cxf-se-2009.01/
>
>
> Thanks, this helps a lot.
>
>
>
>>
>> the wsdl is generated with jaxws. This is the endpoint definition
>>>
>>> What you mean here by "generated with jaxws"? do you mean you are  
>>> using
>> cxf?
>
>
> I use the org.codehaus.mojo/jaxws-maven-plugin (wsgen and wsimport).
Hi,

Could you please use java2wsdl tool from apache cxf instead?
You can use the tool from CLI or maven plugin.

Take a look at [1] to get more details.

[1]http://cxf.apache.org/docs/java-to-wsdl.html

Freeman

>
>
> What I found out is the following:
>
> The CxfSeEndpoint receive an exchange with
>
> serviceName={http://www.klever.it/kdv/pec/ws}PECService
> interfaceName={http://www.klever.it/kdv/pec/ws}PECServicePort
>
> and I think this is correct considering this wsdl
>
>  <service name="PECService">
>    <port name="PECServicePort" binding="tns:PECServicePortBinding">
>      <soap:address location="REPLACE_WITH_ACTUAL_URL"/>
>    </port>
>  </service>
>
> In the JBITransportFactory.destinationMap I have the following mapping
>
> {
> http://www.klever.it/kdv/pec/ws}PECService{http://www.klever.it/kdv/pec/ws 
> }PECService=org.apache.cxf.transport.jbi.JBIDestination@306d94ee,
> ecc.
>
> I tried to change the annotations on the service class removing the
> serviceName but now the service is registered as
>
> {
> http://www.klever.it/kdv/pec/ws}PECServiceService{http://www.klever.it/kdv/pec/ws 
> }PECService
>
> and I request
>
> {
> http://www.klever.it/kdv/pec/ws}PECServiceService{http://www.klever.it/kdv/pec/ws 
> }PECServicePort
>
> I tried to add the portName="PECServicePort" on the service  
> annotation but
> it did not help.
>
> What am I missing?
>
>
> Bye
>
> Lorenzo


-- 
Freeman Fang

------------------------
Open Source SOA: http://fusesource.com
Apache Servicemix:http://servicemix.apache.org
Apache Cxf: http://cxf.apache.org
Apache Karaf: http://karaf.apache.org
Apache Felix: http://felix.apache.org


Re: CxfSeEndpoint NPE, InOut?

Posted by Lorenzo Bolzani <l....@gmail.com>.
2010/7/15 Freeman Fang <fr...@gmail.com>

>
>>  The servicemix-cxf-bc code used for smx 3.3.1 is here[1]
> the servicemix-cxf-se code used for smx 3.3.1 is here[2]
> [1]
> https://svn.apache.org/repos/asf/servicemix/components/bindings/servicemix-cxf-bc/tags/servicemix-cxf-bc-2009.01/
> [2]
> https://svn.apache.org/repos/asf/servicemix/components/engines/servicemix-cxf-se/tags/servicemix-cxf-se-2009.01/


Thanks, this helps a lot.



>
> the wsdl is generated with jaxws. This is the endpoint definition
>>
>>  What you mean here by "generated with jaxws"? do you mean you are using
> cxf?


I use the org.codehaus.mojo/jaxws-maven-plugin (wsgen and wsimport).


What I found out is the following:

The CxfSeEndpoint receive an exchange with

serviceName={http://www.klever.it/kdv/pec/ws}PECService
interfaceName={http://www.klever.it/kdv/pec/ws}PECServicePort

and I think this is correct considering this wsdl

  <service name="PECService">
    <port name="PECServicePort" binding="tns:PECServicePortBinding">
      <soap:address location="REPLACE_WITH_ACTUAL_URL"/>
    </port>
  </service>

In the JBITransportFactory.destinationMap I have the following mapping

{
http://www.klever.it/kdv/pec/ws}PECService{http://www.klever.it/kdv/pec/ws}PECService=org.apache.cxf.transport.jbi.JBIDestination@306d94ee,
ecc.

I tried to change the annotations on the service class removing the
serviceName but now the service is registered as

{
http://www.klever.it/kdv/pec/ws}PECServiceService{http://www.klever.it/kdv/pec/ws}PECService

and I request

{
http://www.klever.it/kdv/pec/ws}PECServiceService{http://www.klever.it/kdv/pec/ws}PECServicePort

I tried to add the portName="PECServicePort" on the service annotation but
it did not help.

What am I missing?


Bye

Lorenzo

Re: CxfSeEndpoint NPE, InOut?

Posted by Freeman Fang <fr...@gmail.com>.
Hi,

My comment inline.
On 2010-7-14, at 下午11:01, Lorenzo Bolzani wrote:

> Hi all.
>
> I'm wrtiting a simple web service and I have a NPE. I'm running smix  
> 3.3.1
> and I cannot find the right sources for this version so it's quite  
> hard to
> debug it myself.
>
The servicemix-cxf-bc code used for smx 3.3.1 is here[1]
the servicemix-cxf-se code used for smx 3.3.1 is here[2]
[1]https://svn.apache.org/repos/asf/servicemix/components/bindings/servicemix-cxf-bc/tags/servicemix-cxf-bc-2009.01/
[2]https://svn.apache.org/repos/asf/servicemix/components/engines/servicemix-cxf-se/tags/servicemix-cxf-se-2009.01/
> This is the service  definition
>
> @WebService(serviceName = "PECService", targetNamespace = "
> http://www.klever.it/kdv/pec/ws")
> @SOAPBinding(style = SOAPBinding.Style.DOCUMENT, use =
> SOAPBinding.Use.LITERAL, parameterStyle =
> SOAPBinding.ParameterStyle.WRAPPED)
> public class PECService {
>
>    @WebMethod(operationName = "sendMessage", action =  
> "urn:sendMessage")
>    public void sendMessage(
>            @WebParam(name = "to", targetNamespace = "
> http://www.klever.it/kdv/pec/ws") String to,
>            @WebParam(name = "document", targetNamespace = "
> http://www.klever.it/kdv/pec/ws") Document document) throws
> PECServiceException {
>
>        System.out.println("sendMessage");
>
>        PECMailService mailService = new PECMailService();
>        mailService.send(to, document);
>    }
> }
>
> the wsdl is generated with jaxws. This is the endpoint definition
>
What you mean here by "generated with jaxws"? do you mean you are  
using cxf?
>    <cxfse:endpoint mtomEnabled="true" useJBIWrapper="false">
>        <cxfse:pojo>
>            <bean class="it.klever.kdv.pec.PECService" />
>        </cxfse:pojo>
>    </cxfse:endpoint>
>
> and this is the consumer definition
>
>  <cxfbc:consumer wsdl="classpath:wsdl/PECService.wsdl"
>                      targetService="pec:PECService"
>                      targetInterface="pec:PECServicePort"
>                      locationURI="http://localhost:8092/PECService/"
>                      mtomEnabled="true" useJBIWrapper="false" />
>
> This is what I get on the console when I call it with a jaxws  
> generated
> client.
>
> INFO  - JBITransportFactory            - configuring DeliveryChannel:
> org.apache.servicemix.common.EndpointDeliveryChannel@2310ff2b
> ERROR - CxfSeComponent                 - Error processing exchange  
> InOut[
>  id: ID:127.0.1.1-129d12553b7-29:6
>  status: Active
>  role: provider
>  interface: {http://www.klever.it/kdv/pec/ws}PECServicePort
>  service: {http://www.klever.it/kdv/pec/ws}PECService
>  endpoint: PECServicePort
>  operation: {http://www.klever.it/kdv/pec/ws}sendMessage
>  in: <?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:soap="
> http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns3:sendMessage
> xmlns:ns3="http://www.klever.it/kdv/pec/ws" xmlns:ns2="
> http://www.klever.it/kdv/registry"><ns3:to>aaa</ns3:to><ns3:document
> ns2:name="pippo"/></ns3:sendMessage></soap:Body></soap:Envelope>
> ]
> java.lang.NullPointerException
>    at
> org.apache.servicemix.cxfse.CxfSeEndpoint.process(CxfSeEndpoint.java: 
> 359)
>    at
The NPE exception means the jbiDestination is null, usually caused by  
the serviceName/interfaceName used for jbiDestination registry and  
retrieve mismatch.
Can't tell so much now, may be you can debug it use the source code I  
point above.

> org 
> .apache 
> .servicemix 
> .common.AsyncBaseLifeCycle.doProcess(AsyncBaseLifeCycle.java:627)
>    at
> org 
> .apache 
> .servicemix 
> .common.AsyncBaseLifeCycle.processExchange(AsyncBaseLifeCycle.java: 
> 581)
>    at
> org 
> .apache 
> .servicemix 
> .common.AsyncBaseLifeCycle.onMessageExchange(AsyncBaseLifeCycle.java: 
> 535)
>    at
> org 
> .apache 
> .servicemix 
> .common 
> .SyncLifeCycleWrapper.onMessageExchange(SyncLifeCycleWrapper.java:60)
>    at
> org 
> .apache 
> .servicemix 
> .jbi 
> .messaging 
> .DeliveryChannelImpl.processInBound(DeliveryChannelImpl.java:623)
>    at
> org 
> .apache 
> .servicemix.jbi.nmr.flow.AbstractFlow.doRouting(AbstractFlow.java:172)
>    at
> org 
> .apache 
> .servicemix.jbi.nmr.flow.seda.SedaFlow.doRouting(SedaFlow.java:168)
>    at
> org.apache.servicemix.jbi.nmr.flow.seda.SedaQueue 
> $1.run(SedaQueue.java:134)
>    at
> java.util.concurrent.ThreadPoolExecutor 
> $Worker.runTask(ThreadPoolExecutor.java:651)
>    at
> java.util.concurrent.ThreadPoolExecutor 
> $Worker.run(ThreadPoolExecutor.java:676)
>    at java.lang.Thread.run(Thread.java:595)
> INFO  - PhaseInterceptorChain          - Interceptor has thrown  
> exception,
> unwinding now null
>
>
> I noticed that it is trying to do a InOut exchange where I expect an  
> InOnly
> one. Could this be the problem?
>
The MEP (InOut/InOnly) is determined from the servicemodel (build from  
wsdl or java code)
You method sendMessage throws exception, so it's not InOnly.

Freeman
>
> Thanks in advance.
>
>
> Bye
>
> Lorenzo


-- 
Freeman Fang

------------------------
Open Source SOA: http://fusesource.com
Apache Servicemix:http://servicemix.apache.org
Apache Cxf: http://cxf.apache.org
Apache Karaf: http://karaf.apache.org
Apache Felix: http://felix.apache.org