You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Shaun Elliott (JIRA)" <ji...@apache.org> on 2011/06/10 00:45:58 UTC

[jira] [Created] (CXF-3581) CXF JAX-RS Client Null Pointer Exception

CXF JAX-RS Client Null Pointer Exception
----------------------------------------

                 Key: CXF-3581
                 URL: https://issues.apache.org/jira/browse/CXF-3581
             Project: CXF
          Issue Type: Bug
          Components: JAX-RS
    Affects Versions: 2.4
         Environment: Apache Maven 3.0.3 (r1075438; 2011-02-28 09:31:09-0800)
Maven home: C:\Program Files\apache-maven-3.0.3\bin\..
Java version: 1.6.0_23, vendor: Sun Microsystems Inc.
Java home: C:\Program Files (x86)\Java\jdk1.6.0_23\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "x86", family: "windows"
            Reporter: Shaun Elliott


I am trying to use the Apache CXF JAX-RS Client API code found http://cxf.apache.org/docs/jax-rs-client-api.html#JAX-RSClientAPI-ProxybasedAPI. However, when I run the client it throws this:

{code}
Exception in thread "main" java.lang.NullPointerException
    at java.util.HashMap.<init>(HashMap.java:223)
    at org.restlet.ext.jaxrs.internal.core.ResponseBuilderImpl.clone(ResponseBuilderImpl.java:126)
    at org.restlet.ext.jaxrs.internal.core.ResponseBuilderImpl.clone(ResponseBuilderImpl.java:62)
    at org.apache.cxf.jaxrs.client.AbstractClient.setResponseBuilder(AbstractClient.java:374)
    at org.apache.cxf.jaxrs.client.ClientProxyImpl.handleResponse(ClientProxyImpl.java:451)
    at org.apache.cxf.jaxrs.client.ClientProxyImpl.doChainedInvocation(ClientProxyImpl.java:445)
    at org.apache.cxf.jaxrs.client.ClientProxyImpl.invoke(ClientProxyImpl.java:177)
    at $Proxy12.foo(Unknown Source)
    at com.paml.JaxTestClient.main(JaxTestClient.java:20)
{code}

This is my client:

{code}
public class JaxTestClient {

    public static void main( String[] args ) {
        // Works with Restlet API - but paths are not mapped automatically
        // JaxExampleEcho jaxExampleEcho = ClientResource.create( "http://localhost:8111/", JaxExampleEcho.class );

        JaxExampleEcho jaxExampleEcho = JAXRSClientFactory.create( "http://localhost:8111/", JaxExampleEcho.class );
        System.out.println( jaxExampleEcho.foo() );
        System.out.println( jaxExampleEcho.bar() );
        System.out.println( jaxExampleEcho.baz() );
    }
}
{code}

And here is my interface:
{code}
@Path( "/" )
public interface JaxExampleEcho {

    @GET
    @Path( "foo" )
    @Produces( "text/plain" )
    String foo();

    @GET
    @Path( "bar" )
    @Produces( "text/plain" )
    String bar();

    @GET
    @Path( "baz" )
    @Produces( "text/plain" )
    String baz();

}
{code}

I can see the requests hitting the right url server side.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Resolved] (CXF-3581) CXF JAX-RS Client Null Pointer Exception

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

Shaun Elliott resolved CXF-3581.
--------------------------------

    Resolution: Invalid

The problem was not CXF, but rather the JAX-RS restlet extension being on my path. Removing all restlet dependencies fixed the issue.

> CXF JAX-RS Client Null Pointer Exception
> ----------------------------------------
>
>                 Key: CXF-3581
>                 URL: https://issues.apache.org/jira/browse/CXF-3581
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 2.4
>         Environment: Apache Maven 3.0.3 (r1075438; 2011-02-28 09:31:09-0800)
> Maven home: C:\Program Files\apache-maven-3.0.3\bin\..
> Java version: 1.6.0_23, vendor: Sun Microsystems Inc.
> Java home: C:\Program Files (x86)\Java\jdk1.6.0_23\jre
> Default locale: en_US, platform encoding: Cp1252
> OS name: "windows 7", version: "6.1", arch: "x86", family: "windows"
>            Reporter: Shaun Elliott
>
> I am trying to use the Apache CXF JAX-RS Client API code found http://cxf.apache.org/docs/jax-rs-client-api.html#JAX-RSClientAPI-ProxybasedAPI. However, when I run the client it throws this:
> {code}
> Exception in thread "main" java.lang.NullPointerException
>     at java.util.HashMap.<init>(HashMap.java:223)
>     at org.restlet.ext.jaxrs.internal.core.ResponseBuilderImpl.clone(ResponseBuilderImpl.java:126)
>     at org.restlet.ext.jaxrs.internal.core.ResponseBuilderImpl.clone(ResponseBuilderImpl.java:62)
>     at org.apache.cxf.jaxrs.client.AbstractClient.setResponseBuilder(AbstractClient.java:374)
>     at org.apache.cxf.jaxrs.client.ClientProxyImpl.handleResponse(ClientProxyImpl.java:451)
>     at org.apache.cxf.jaxrs.client.ClientProxyImpl.doChainedInvocation(ClientProxyImpl.java:445)
>     at org.apache.cxf.jaxrs.client.ClientProxyImpl.invoke(ClientProxyImpl.java:177)
>     at $Proxy12.foo(Unknown Source)
>     at com.paml.JaxTestClient.main(JaxTestClient.java:20)
> {code}
> This is my client:
> {code}
> public class JaxTestClient {
>     public static void main( String[] args ) {
>         // Works with Restlet API - but paths are not mapped automatically
>         // JaxExampleEcho jaxExampleEcho = ClientResource.create( "http://localhost:8111/", JaxExampleEcho.class );
>         JaxExampleEcho jaxExampleEcho = JAXRSClientFactory.create( "http://localhost:8111/", JaxExampleEcho.class );
>         System.out.println( jaxExampleEcho.foo() );
>         System.out.println( jaxExampleEcho.bar() );
>         System.out.println( jaxExampleEcho.baz() );
>     }
> }
> {code}
> And here is my interface:
> {code}
> @Path( "/" )
> public interface JaxExampleEcho {
>     @GET
>     @Path( "foo" )
>     @Produces( "text/plain" )
>     String foo();
>     @GET
>     @Path( "bar" )
>     @Produces( "text/plain" )
>     String bar();
>     @GET
>     @Path( "baz" )
>     @Produces( "text/plain" )
>     String baz();
> }
> {code}
> I can see the requests hitting the right url server side.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira