You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by "Stephan Siano (JIRA)" <ji...@apache.org> on 2010/09/23 12:58:40 UTC

[jira] Created: (CAMEL-3151) NullPointerException in CXF Producer if no type converter is available

NullPointerException in CXF Producer if no type converter is available
----------------------------------------------------------------------

                 Key: CAMEL-3151
                 URL: https://issues.apache.org/activemq/browse/CAMEL-3151
             Project: Apache Camel
          Issue Type: Bug
          Components: camel-cxf
            Reporter: Stephan Siano
            Priority: Minor


When I am trying to send the content of a file to an CXF endpoint in PAYLOAD format, I get a NullPointerException in line 603 of the CXFEndpoint class (in the current trunk). The offending coding is:
                CxfPayload<?> payload = (CxfPayload<?>)params[0];
                List<Element> elements = payload.getBody();

The params are set in line 282 of the CxfProducer class:
            params = new Object[1];
            // TODO: maybe it should be mandatory body?
            params[0] = exchange.getIn().getBody(CxfPayload.class);

The fix is most probably trivial (change to getMandatoryBody()) and add a throws InvalidPayloadException to the getParams() method of CxfProducer). After this is fixed (the same for the MESSAGE format two lines lower), the example will still not work, but I get a meaningful error message saying that there is no type converter between GenericFile and CxfPayload.

One could argue, that under some circumstances null payloads may be legal (I just don't see any), but in this case the CxfEndpoint class would have to be modified to avoid the NullPointerException. As the coding is a missing converter or a null payload will trigger NullPointerExceptions for CxfEndpoints unconditionally.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (CAMEL-3151) NullPointerException in CXF Producer if no type converter is available

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/CAMEL-3151?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen resolved CAMEL-3151.
--------------------------------

    Resolution: Fixed

trunk: 1003946.

Now uses mandatory body.

> NullPointerException in CXF Producer if no type converter is available
> ----------------------------------------------------------------------
>
>                 Key: CAMEL-3151
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-3151
>             Project: Apache Camel
>          Issue Type: Bug
>          Components: camel-cxf
>            Reporter: Stephan Siano
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 2.5.0
>
>
> When I am trying to send the content of a file to an CXF endpoint in PAYLOAD format, I get a NullPointerException in line 603 of the CXFEndpoint class (in the current trunk). The offending coding is:
>                 CxfPayload<?> payload = (CxfPayload<?>)params[0];
>                 List<Element> elements = payload.getBody();
> The params are set in line 282 of the CxfProducer class:
>             params = new Object[1];
>             // TODO: maybe it should be mandatory body?
>             params[0] = exchange.getIn().getBody(CxfPayload.class);
> The fix is most probably trivial (change to getMandatoryBody()) and add a throws InvalidPayloadException to the getParams() method of CxfProducer). After this is fixed (the same for the MESSAGE format two lines lower), the example will still not work, but I get a meaningful error message saying that there is no type converter between GenericFile and CxfPayload.
> One could argue, that under some circumstances null payloads may be legal (I just don't see any), but in this case the CxfEndpoint class would have to be modified to avoid the NullPointerException. As the coding is a missing converter or a null payload will trigger NullPointerExceptions for CxfEndpoints unconditionally.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CAMEL-3151) NullPointerException in CXF Producer if no type converter is available

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-3151?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=62102#action_62102 ] 

Claus Ibsen commented on CAMEL-3151:
------------------------------------

Can you attach a small unit test which demonstrates this?

And what content in the message do you send?

> NullPointerException in CXF Producer if no type converter is available
> ----------------------------------------------------------------------
>
>                 Key: CAMEL-3151
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-3151
>             Project: Apache Camel
>          Issue Type: Bug
>          Components: camel-cxf
>            Reporter: Stephan Siano
>            Priority: Minor
>
> When I am trying to send the content of a file to an CXF endpoint in PAYLOAD format, I get a NullPointerException in line 603 of the CXFEndpoint class (in the current trunk). The offending coding is:
>                 CxfPayload<?> payload = (CxfPayload<?>)params[0];
>                 List<Element> elements = payload.getBody();
> The params are set in line 282 of the CxfProducer class:
>             params = new Object[1];
>             // TODO: maybe it should be mandatory body?
>             params[0] = exchange.getIn().getBody(CxfPayload.class);
> The fix is most probably trivial (change to getMandatoryBody()) and add a throws InvalidPayloadException to the getParams() method of CxfProducer). After this is fixed (the same for the MESSAGE format two lines lower), the example will still not work, but I get a meaningful error message saying that there is no type converter between GenericFile and CxfPayload.
> One could argue, that under some circumstances null payloads may be legal (I just don't see any), but in this case the CxfEndpoint class would have to be modified to avoid the NullPointerException. As the coding is a missing converter or a null payload will trigger NullPointerExceptions for CxfEndpoints unconditionally.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (CAMEL-3151) NullPointerException in CXF Producer if no type converter is available

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/CAMEL-3151?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen reassigned CAMEL-3151:
----------------------------------

    Assignee: Claus Ibsen

> NullPointerException in CXF Producer if no type converter is available
> ----------------------------------------------------------------------
>
>                 Key: CAMEL-3151
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-3151
>             Project: Apache Camel
>          Issue Type: Bug
>          Components: camel-cxf
>            Reporter: Stephan Siano
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 2.5.0
>
>
> When I am trying to send the content of a file to an CXF endpoint in PAYLOAD format, I get a NullPointerException in line 603 of the CXFEndpoint class (in the current trunk). The offending coding is:
>                 CxfPayload<?> payload = (CxfPayload<?>)params[0];
>                 List<Element> elements = payload.getBody();
> The params are set in line 282 of the CxfProducer class:
>             params = new Object[1];
>             // TODO: maybe it should be mandatory body?
>             params[0] = exchange.getIn().getBody(CxfPayload.class);
> The fix is most probably trivial (change to getMandatoryBody()) and add a throws InvalidPayloadException to the getParams() method of CxfProducer). After this is fixed (the same for the MESSAGE format two lines lower), the example will still not work, but I get a meaningful error message saying that there is no type converter between GenericFile and CxfPayload.
> One could argue, that under some circumstances null payloads may be legal (I just don't see any), but in this case the CxfEndpoint class would have to be modified to avoid the NullPointerException. As the coding is a missing converter or a null payload will trigger NullPointerExceptions for CxfEndpoints unconditionally.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (CAMEL-3151) NullPointerException in CXF Producer if no type converter is available

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/CAMEL-3151?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen updated CAMEL-3151:
-------------------------------

    Fix Version/s: 2.5.0

> NullPointerException in CXF Producer if no type converter is available
> ----------------------------------------------------------------------
>
>                 Key: CAMEL-3151
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-3151
>             Project: Apache Camel
>          Issue Type: Bug
>          Components: camel-cxf
>            Reporter: Stephan Siano
>            Priority: Minor
>             Fix For: 2.5.0
>
>
> When I am trying to send the content of a file to an CXF endpoint in PAYLOAD format, I get a NullPointerException in line 603 of the CXFEndpoint class (in the current trunk). The offending coding is:
>                 CxfPayload<?> payload = (CxfPayload<?>)params[0];
>                 List<Element> elements = payload.getBody();
> The params are set in line 282 of the CxfProducer class:
>             params = new Object[1];
>             // TODO: maybe it should be mandatory body?
>             params[0] = exchange.getIn().getBody(CxfPayload.class);
> The fix is most probably trivial (change to getMandatoryBody()) and add a throws InvalidPayloadException to the getParams() method of CxfProducer). After this is fixed (the same for the MESSAGE format two lines lower), the example will still not work, but I get a meaningful error message saying that there is no type converter between GenericFile and CxfPayload.
> One could argue, that under some circumstances null payloads may be legal (I just don't see any), but in this case the CxfEndpoint class would have to be modified to avoid the NullPointerException. As the coding is a missing converter or a null payload will trigger NullPointerExceptions for CxfEndpoints unconditionally.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CAMEL-3151) NullPointerException in CXF Producer if no type converter is available

Posted by "Stephan Siano (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-3151?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=62144#action_62144 ] 

Stephan Siano commented on CAMEL-3151:
--------------------------------------

Actually it is an issue in error handling, so I don't really know how to write a unit test for that. 

Maybe it helps explaining what I actually do:
I have a beans.xml that looks like that:

<?xml version="1.0"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	   xmlns:camel="http://camel.apache.org/schema/spring"
	   xmlns:cxf="http://camel.apache.org/schema/cxf"
	   xmlns:http-conf="http://cxf.apache.org/transports/http/configuration"
	   xmlns:sample="http://services.samples/xsd"
	   xsi:schemaLocation="
         http://www.springframework.org/schema/beans
         http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
         http://cxf.apache.org/transports/http/configuration
         http://cxf.apache.org/schemas/configuration/http-conf.xsd
         http://camel.apache.org/schema/cxf
         http://camel.apache.org/schema/cxf/camel-cxf.xsd
         http://camel.apache.org/schema/spring
         http://camel.apache.org/schema/spring/camel-spring.xsd">

	<import resource="classpath:META-INF/cxf/cxf.xml" />
	<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
	<import resource="classpath:META-INF/cxf/cxf-extension-http.xml"/>  
     
	<cxf:cxfEndpoint id="serviceEndpoint"
        		     address="http://myhost:8080/MockServices/EchoService"
        		     wsdlURL="EchoService.wsdl"
        		     endpointName="sample:EchoServicePort" 
        		     serviceName="sample:EchoService">
		<cxf:properties>
			<entry key="dataFormat" value="PAYLOAD" />
		</cxf:properties>
	</cxf:cxfEndpoint>

	<camel:camelContext>
		<camel:route>
			<camel:from uri="file://c:/temp/camel/poller" />
			<!-- The wsdl contains multiple operations, so we select one -->
			<camel:setHeader headerName="operationName">
				<camel:constant>buyStocksOperation1K</camel:constant>
			</camel:setHeader>	
			<camel:to uri="cxf:bean:serviceEndpoint" />
		</camel:route>
	</camel:camelContext>
</beans>

You can use any wsdl for that (even for a webservice that does not exist, because it will not get called). Then put a xml-file matching the request type of the endpoint into the /temp/camel/poller directory. You will encounter a NullPointerException. After the getBody() statements are replaced by getMandatoryBody() statements, the scenario does still not work, but now you get a (IMO much better) TypeConversionException that indicates the reason for the issue.

Mid-term it might be a good idea to have a TypeConverter for CxfPayload type messages. If that is there, the fix will not show up anymore in this scenario (but maybe in other scenarios where no type converter is available).

> NullPointerException in CXF Producer if no type converter is available
> ----------------------------------------------------------------------
>
>                 Key: CAMEL-3151
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-3151
>             Project: Apache Camel
>          Issue Type: Bug
>          Components: camel-cxf
>            Reporter: Stephan Siano
>            Priority: Minor
>             Fix For: 2.5.0
>
>
> When I am trying to send the content of a file to an CXF endpoint in PAYLOAD format, I get a NullPointerException in line 603 of the CXFEndpoint class (in the current trunk). The offending coding is:
>                 CxfPayload<?> payload = (CxfPayload<?>)params[0];
>                 List<Element> elements = payload.getBody();
> The params are set in line 282 of the CxfProducer class:
>             params = new Object[1];
>             // TODO: maybe it should be mandatory body?
>             params[0] = exchange.getIn().getBody(CxfPayload.class);
> The fix is most probably trivial (change to getMandatoryBody()) and add a throws InvalidPayloadException to the getParams() method of CxfProducer). After this is fixed (the same for the MESSAGE format two lines lower), the example will still not work, but I get a meaningful error message saying that there is no type converter between GenericFile and CxfPayload.
> One could argue, that under some circumstances null payloads may be legal (I just don't see any), but in this case the CxfEndpoint class would have to be modified to avoid the NullPointerException. As the coding is a missing converter or a null payload will trigger NullPointerExceptions for CxfEndpoints unconditionally.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CAMEL-3151) NullPointerException in CXF Producer if no type converter is available

Posted by "Stephan Siano (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-3151?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=62311#action_62311 ] 

Stephan Siano commented on CAMEL-3151:
--------------------------------------

The file contains the XML for the Payload of the SOAP message (without the SOAP Envelope). If the file did contain the whole SOAP message (with envelope and all) this would be MESSAGE data format and that works.

Writing a type converter for camel-cxf is pretty easy. The CXFPayload contains two lists, one for headers, that can remain empty for this use case and one for the body, which is a list of DOM elements, so it's actually pretty easy to have a type converter between NodeList, Document or Element and CXFPayload. This can be glued together with other type converters by a default converter.

I have already done so (about 100 lines of code), however before I can provide the code we need to undergo some outbound open source process, which will take some weeks, sorry for that.

Nevertheless, I think this fix here is useful, even if these type converters where there, because there could still be some StrangeMessageWithoutConverters and it is helpful to get the error message that there is no type converter for that instead of a NullPointerException.

> NullPointerException in CXF Producer if no type converter is available
> ----------------------------------------------------------------------
>
>                 Key: CAMEL-3151
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-3151
>             Project: Apache Camel
>          Issue Type: Bug
>          Components: camel-cxf
>            Reporter: Stephan Siano
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 2.5.0
>
>
> When I am trying to send the content of a file to an CXF endpoint in PAYLOAD format, I get a NullPointerException in line 603 of the CXFEndpoint class (in the current trunk). The offending coding is:
>                 CxfPayload<?> payload = (CxfPayload<?>)params[0];
>                 List<Element> elements = payload.getBody();
> The params are set in line 282 of the CxfProducer class:
>             params = new Object[1];
>             // TODO: maybe it should be mandatory body?
>             params[0] = exchange.getIn().getBody(CxfPayload.class);
> The fix is most probably trivial (change to getMandatoryBody()) and add a throws InvalidPayloadException to the getParams() method of CxfProducer). After this is fixed (the same for the MESSAGE format two lines lower), the example will still not work, but I get a meaningful error message saying that there is no type converter between GenericFile and CxfPayload.
> One could argue, that under some circumstances null payloads may be legal (I just don't see any), but in this case the CxfEndpoint class would have to be modified to avoid the NullPointerException. As the coding is a missing converter or a null payload will trigger NullPointerExceptions for CxfEndpoints unconditionally.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CAMEL-3151) NullPointerException in CXF Producer if no type converter is available

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-3151?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=62289#action_62289 ] 

Claus Ibsen commented on CAMEL-3151:
------------------------------------

So the file contains the XML for the SOAP message? You can use the SOAP data format to transform that file into SOAP.

But yes I wonder if the camel-cxf can have a type converter which can do that as well?

> NullPointerException in CXF Producer if no type converter is available
> ----------------------------------------------------------------------
>
>                 Key: CAMEL-3151
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-3151
>             Project: Apache Camel
>          Issue Type: Bug
>          Components: camel-cxf
>            Reporter: Stephan Siano
>            Priority: Minor
>             Fix For: 2.5.0
>
>
> When I am trying to send the content of a file to an CXF endpoint in PAYLOAD format, I get a NullPointerException in line 603 of the CXFEndpoint class (in the current trunk). The offending coding is:
>                 CxfPayload<?> payload = (CxfPayload<?>)params[0];
>                 List<Element> elements = payload.getBody();
> The params are set in line 282 of the CxfProducer class:
>             params = new Object[1];
>             // TODO: maybe it should be mandatory body?
>             params[0] = exchange.getIn().getBody(CxfPayload.class);
> The fix is most probably trivial (change to getMandatoryBody()) and add a throws InvalidPayloadException to the getParams() method of CxfProducer). After this is fixed (the same for the MESSAGE format two lines lower), the example will still not work, but I get a meaningful error message saying that there is no type converter between GenericFile and CxfPayload.
> One could argue, that under some circumstances null payloads may be legal (I just don't see any), but in this case the CxfEndpoint class would have to be modified to avoid the NullPointerException. As the coding is a missing converter or a null payload will trigger NullPointerExceptions for CxfEndpoints unconditionally.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.