You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Andreas Benneke (JIRA)" <ji...@apache.org> on 2008/08/07 09:29:44 UTC

[jira] Created: (CXF-1737) NPE in ClientProxyFactoryBean on void methods

NPE in ClientProxyFactoryBean on void methods 
----------------------------------------------

                 Key: CXF-1737
                 URL: https://issues.apache.org/jira/browse/CXF-1737
             Project: CXF
          Issue Type: Bug
          Components: Core
    Affects Versions: 2.1.1
            Reporter: Andreas Benneke


If you try to access a service containing a method returning nothing (void), the ClientProxyFactoryBean fails with a NullPointerException:

Exception in thread "main" java.lang.NullPointerException
	at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeParameter(ReflectionServiceFactoryBean.java:643)
	at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeClassInfo(ReflectionServiceFactoryBean.java:609)
	at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeWSDLOperation(ReflectionServiceFactoryBean.java:540)
	at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeWSDLOperations(ReflectionServiceFactoryBean.java:510)
	at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromWSDL(ReflectionServiceFactoryBean.java:305)
	at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:394)
	at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:181)
	at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:79)
	at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:51)
	at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:97)

If you change the method returning something or eliminate the method altogether, everything works fine...

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


[jira] Commented: (CXF-1737) NPE in ClientProxyFactoryBean on void methods

Posted by "Simon Lessard (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-1737?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12620788#action_12620788 ] 

Simon Lessard commented on CXF-1737:
------------------------------------

I couldn't reproduce that issue, but found out the following piece of code within DefaultServiceConfiguration:

    @Override
    public Boolean hasOutMessage(Method m) {
        if (m.getReturnType().getClass().equals(void.class) && m.getExceptionTypes().length == 0) {
            return false;
        }
        return true;
    }

I believe Java 5 will do some auto-boxing with void.class that might result in Void.class which is, I think, different from Void.TYPE. So, since Void.TYPE is the Class representation of the primitive void, changing the method to the following might do the trick:

    @Override
    public Boolean hasOutMessage(Method m) {
        if (m.getReturnType().getClass().equals(Void.TYPE) && m.getExceptionTypes().length == 0) {
            return false;
        }
        return true;
    }



> NPE in ClientProxyFactoryBean on void methods 
> ----------------------------------------------
>
>                 Key: CXF-1737
>                 URL: https://issues.apache.org/jira/browse/CXF-1737
>             Project: CXF
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.1.1
>            Reporter: Andreas Benneke
>
> If you try to access a service containing a method returning nothing (void), the ClientProxyFactoryBean fails with a NullPointerException:
> Exception in thread "main" java.lang.NullPointerException
> 	at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeParameter(ReflectionServiceFactoryBean.java:643)
> 	at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeClassInfo(ReflectionServiceFactoryBean.java:609)
> 	at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeWSDLOperation(ReflectionServiceFactoryBean.java:540)
> 	at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeWSDLOperations(ReflectionServiceFactoryBean.java:510)
> 	at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromWSDL(ReflectionServiceFactoryBean.java:305)
> 	at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:394)
> 	at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:181)
> 	at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:79)
> 	at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:51)
> 	at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:97)
> If you change the method returning something or eliminate the method altogether, everything works fine...

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


[jira] Commented: (CXF-1737) NPE in ClientProxyFactoryBean on void methods

Posted by "Andreas Benneke (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-1737?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12620886#action_12620886 ] 

Andreas Benneke commented on CXF-1737:
--------------------------------------

Simon, thanks for looking into it. I've just attached a test case to reproduce the exception.

According to my tests, the following assertions are all valid:

		assertTrue(Void.TYPE.equals(void.class));
		assertFalse(Void.class.equals(void.class));
		assertFalse(Void.class.equals(Void.TYPE));

Therefore, as far as I see the change you propose would not change anything. One could however be on the very save side by doing somthing like this:

    @Override
    public Boolean hasOutMessage(Method m) {
        Class rt = m.getReturnType().getClass();
        if ((rt.equals(Void.TYPE) || rt.equals(Void.class)) && m.getExceptionTypes().length == 0) {
            return false;
        }
        return true;
    } 



> NPE in ClientProxyFactoryBean on void methods 
> ----------------------------------------------
>
>                 Key: CXF-1737
>                 URL: https://issues.apache.org/jira/browse/CXF-1737
>             Project: CXF
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.1.1
>            Reporter: Andreas Benneke
>         Attachments: void.zip
>
>
> If you try to access a service containing a method returning nothing (void), the ClientProxyFactoryBean fails with a NullPointerException:
> Exception in thread "main" java.lang.NullPointerException
> 	at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeParameter(ReflectionServiceFactoryBean.java:643)
> 	at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeClassInfo(ReflectionServiceFactoryBean.java:609)
> 	at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeWSDLOperation(ReflectionServiceFactoryBean.java:540)
> 	at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeWSDLOperations(ReflectionServiceFactoryBean.java:510)
> 	at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromWSDL(ReflectionServiceFactoryBean.java:305)
> 	at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:394)
> 	at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:181)
> 	at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:79)
> 	at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:51)
> 	at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:97)
> If you change the method returning something or eliminate the method altogether, everything works fine...

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


[jira] Commented: (CXF-1737) NPE in ClientProxyFactoryBean on void methods

Posted by "Andreas Benneke (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-1737?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12620888#action_12620888 ] 

Andreas Benneke commented on CXF-1737:
--------------------------------------

Aaaaah, I see. It does m.getReturnType().getClass() which will always be "Class" as getReturnType() already returns the value. So this method will never return false and it should read:

    @Override
    public Boolean hasOutMessage(Method m) {
        Class rt = m.getReturnType().getClass();
        if ((rt.equals(Void.TYPE) || rt.equals(Void.class)) && m.getExceptionTypes().length == 0) {
            return false;
        }
        return true;
    } 

However I think, the following change would be enough:

    @Override
    public Boolean hasOutMessage(Method m) {
        if (m.getReturnType().equals(void.class) && m.getExceptionTypes().length == 0) {
            return false;
        }
        return true;
    } 



> NPE in ClientProxyFactoryBean on void methods 
> ----------------------------------------------
>
>                 Key: CXF-1737
>                 URL: https://issues.apache.org/jira/browse/CXF-1737
>             Project: CXF
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.1.1
>            Reporter: Andreas Benneke
>         Attachments: void.zip
>
>
> If you try to access a service containing a method returning nothing (void), the ClientProxyFactoryBean fails with a NullPointerException:
> Exception in thread "main" java.lang.NullPointerException
> 	at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeParameter(ReflectionServiceFactoryBean.java:643)
> 	at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeClassInfo(ReflectionServiceFactoryBean.java:609)
> 	at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeWSDLOperation(ReflectionServiceFactoryBean.java:540)
> 	at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeWSDLOperations(ReflectionServiceFactoryBean.java:510)
> 	at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromWSDL(ReflectionServiceFactoryBean.java:305)
> 	at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:394)
> 	at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:181)
> 	at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:79)
> 	at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:51)
> 	at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:97)
> If you change the method returning something or eliminate the method altogether, everything works fine...

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


[jira] Commented: (CXF-1737) NPE in ClientProxyFactoryBean on void methods

Posted by "Daniel Kulp (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-1737?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12621012#action_12621012 ] 

Daniel Kulp commented on CXF-1737:
----------------------------------



Thanks for the testcase.   Very useful.  

The "correct" fix is actually on line 618:
        if (!initializeParameter(o, method, -1, paramType, genericType)) {
            return false;
        }

should change to:
        if (o.hasOutput()
            && !initializeParameter(o, method, -1, paramType, genericType)) {
            return false;
        }

Basically, if the wsdl states there is no output message (it's a one-way), then the return type is irrelevant and should/could be completely skipped.

> NPE in ClientProxyFactoryBean on void methods 
> ----------------------------------------------
>
>                 Key: CXF-1737
>                 URL: https://issues.apache.org/jira/browse/CXF-1737
>             Project: CXF
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.1.1
>            Reporter: Andreas Benneke
>         Attachments: void.zip
>
>
> If you try to access a service containing a method returning nothing (void), the ClientProxyFactoryBean fails with a NullPointerException:
> Exception in thread "main" java.lang.NullPointerException
> 	at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeParameter(ReflectionServiceFactoryBean.java:643)
> 	at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeClassInfo(ReflectionServiceFactoryBean.java:609)
> 	at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeWSDLOperation(ReflectionServiceFactoryBean.java:540)
> 	at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeWSDLOperations(ReflectionServiceFactoryBean.java:510)
> 	at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromWSDL(ReflectionServiceFactoryBean.java:305)
> 	at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:394)
> 	at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:181)
> 	at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:79)
> 	at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:51)
> 	at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:97)
> If you change the method returning something or eliminate the method altogether, everything works fine...

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


[jira] Updated: (CXF-1737) NPE in ClientProxyFactoryBean on void methods

Posted by "Andreas Benneke (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CXF-1737?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andreas Benneke updated CXF-1737:
---------------------------------

    Attachment: void.zip

Finally I managed to strip things down to the attached test project. 

The junit test starts the server endpoint and tries to call it with 
- plain JaxWS (which works), 
- the JaxWsProxyFactoryBean (which also works) and 
- the ClientProxyFactoryBean (which fails with the given exception)

> NPE in ClientProxyFactoryBean on void methods 
> ----------------------------------------------
>
>                 Key: CXF-1737
>                 URL: https://issues.apache.org/jira/browse/CXF-1737
>             Project: CXF
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.1.1
>            Reporter: Andreas Benneke
>         Attachments: void.zip
>
>
> If you try to access a service containing a method returning nothing (void), the ClientProxyFactoryBean fails with a NullPointerException:
> Exception in thread "main" java.lang.NullPointerException
> 	at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeParameter(ReflectionServiceFactoryBean.java:643)
> 	at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeClassInfo(ReflectionServiceFactoryBean.java:609)
> 	at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeWSDLOperation(ReflectionServiceFactoryBean.java:540)
> 	at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeWSDLOperations(ReflectionServiceFactoryBean.java:510)
> 	at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromWSDL(ReflectionServiceFactoryBean.java:305)
> 	at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:394)
> 	at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:181)
> 	at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:79)
> 	at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:51)
> 	at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:97)
> If you change the method returning something or eliminate the method altogether, everything works fine...

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


[jira] Resolved: (CXF-1737) NPE in ClientProxyFactoryBean on void methods

Posted by "Daniel Kulp (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CXF-1737?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Daniel Kulp resolved CXF-1737.
------------------------------

       Resolution: Fixed
    Fix Version/s: 2.0.9
                   2.1.2
         Assignee: Daniel Kulp

> NPE in ClientProxyFactoryBean on void methods 
> ----------------------------------------------
>
>                 Key: CXF-1737
>                 URL: https://issues.apache.org/jira/browse/CXF-1737
>             Project: CXF
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.1.1
>            Reporter: Andreas Benneke
>            Assignee: Daniel Kulp
>             Fix For: 2.1.2, 2.0.9
>
>         Attachments: void.zip
>
>
> If you try to access a service containing a method returning nothing (void), the ClientProxyFactoryBean fails with a NullPointerException:
> Exception in thread "main" java.lang.NullPointerException
> 	at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeParameter(ReflectionServiceFactoryBean.java:643)
> 	at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeClassInfo(ReflectionServiceFactoryBean.java:609)
> 	at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeWSDLOperation(ReflectionServiceFactoryBean.java:540)
> 	at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeWSDLOperations(ReflectionServiceFactoryBean.java:510)
> 	at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromWSDL(ReflectionServiceFactoryBean.java:305)
> 	at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:394)
> 	at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:181)
> 	at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:79)
> 	at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:51)
> 	at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:97)
> If you change the method returning something or eliminate the method altogether, everything works fine...

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