Hello all,

I am in the middle of trying to get a JAX-RS Client/Server project to work.
I am having trouble because I cannot figure out how to get my Customer class
to find out about the sub-resource method located in a CustomerState class.
I have tried assigning it to a resource provider. I have tried declaring
Interfaces to both Customer and CustomerState, putting them in both the
server and client folders. I have tried declaring CustomerState as a
provider. I don't remember what else I tried, but I have been trying for
approximately 4 hours now. I have looked everywhere, but the documentation
implies that nothing more is necessary than to put an @GET on the method of
choice and call that method from the class containing the @Path. I have
thought about context injection, but don't know what to do. I do not have an
explicit Application subclass. The JAX-RS api is sparse with comments. The
sparseness of the spec in definitions and scope, leaves something to be
desired also (at least for me).

If you look here:
http://pages.cs.wisc.edu/~zoerner/downloads/dev/samples/customerservice/testing/
you can see the code.

Here is the most recent error message from the Server:

[INFO]
[INFO] >>> exec-maven-plugin:1.2:java (default) @ jax_rs_basic >>>
[INFO]
[INFO] <<< exec-maven-plugin:1.2:java (default) @ jax_rs_basic <<<
[INFO]
[INFO] --- exec-maven-plugin:1.2:java (default) @ jax_rs_basic ---
May 15, 2011 10:12:14 PM org.apache.cxf.jaxrs.utils.ResourceUtils
checkMethodDispatcher
WARNING: No resource methods have been found for resource class
java.lang.Class
May 15, 2011 10:12:15 PM org.apache.cxf.endpoint.ServerImpl initDestination
INFO: Setting the server's publish address to be http://localhost:9000/
May 15, 2011 10:12:15 PM org.eclipse.jetty.util.log.Slf4jLog info
INFO: jetty-7.3.1.v20110307
May 15, 2011 10:12:15 PM org.eclipse.jetty.util.log.Slf4jLog info
INFO: Started SelectChannelConnector@localhost:9000
May 15, 2011 10:12:15 PM org.eclipse.jetty.util.log.Slf4jLog info
INFO: started o.e.j.s.h.ContextHandler{,null}
Server ready...
May 15, 2011 10:12:24 PM org.apache.cxf.jaxrs.utils.ResourceUtils
checkMethodDispatcher
WARNING: No resource methods have been found for resource class
java.lang.String
May 15, 2011 10:12:24 PM org.apache.cxf.jaxrs.JAXRSInvoker invoke
SEVERE: No subresource locator found for path /
May 15, 2011 10:12:24 PM
org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper toResponse
WARNING: WebApplicationException has been caught : no cause is available
May 15, 2011 10:12:24 PM org.apache.cxf.jaxrs.utils.ResourceUtils
checkMethodDispatcher
WARNING: No resource methods have been found for resource class
java.lang.String
May 15, 2011 10:12:24 PM org.apache.cxf.jaxrs.JAXRSInvoker invoke
SEVERE: No subresource locator found for path /
May 15, 2011 10:12:24 PM
org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper toResponse
WARNING: WebApplicationException has been caught : no cause is available

Any suggestions that you might have would be helpful.

Here is the client code message:

Sent HTTP GET request to query customer info

url:****************************
http://localhost:9000/customer/state/
********************************

getHeaderField(0)****************

   [HTTP/1.1 404 Not Found]

getHeaderField(1)****************

   [Mon, 16 May 2011 03:12:24 GMT]

getHeaderField(2)****************

   [0]

getHeaderField(3)****************

   [text/xml]

getHeaderField(4)****************

   [Jetty(7.3.1.v20110307)]

getContent:********************

[INFO]
------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO]
------------------------------------------------------------------------

This works fine and dandy when I return a CustomerState Object from a field
belonging to Customer, but the problem is, I really don't need a subresource
method to return it. I think, although, at the time, I had a method declared
called getCustomerState which returned the String from CustomerState, and I
had it annotated with @GET. If I removed that, perhaps the other
configuration wouldn't work also?

Here was the message for that, from the Client:

Sent HTTP GET request to query customer info

url:****************************
http://localhost:9000/customer/state/
********************************

getHeaderField(0)****************

   [HTTP/1.1 200 OK]

getHeaderField(1)****************

   [Mon, 16 May 2011 02:45:13 GMT]

getHeaderField(2)****************

   [14]

getHeaderField(3)****************

   [text/html]

getHeaderField(4)****************

   [Jetty(7.3.1.v20110307)]

getContent:********************

sun.net.www.protocol.http.HttpURLConnection$HttpInputStream@1d1cdf7
*******************************

__INSTANTIATED
*******************************

__INSTANTIATED
*******************************

The last three lines in the output correspond to these methods:

        System.out.println(((InputStream) url.getContent()).toString());

        in = (InputStream) url.getContent();
        System.out.println(getStringFromInputStream(in));


        in = (InputStream) url.getContent();
        System.out.println(getStringFromInputStream(in));

I'm not sure if this is the answer or not right now. If you have any
suggestions about how to make it work from the other class, that would be
preferable.

Thank you.

Sorry if this is so much sprawling output.

Ryan

Reply via email to