You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@wink.apache.org by "Pruitt, Byron S" <st...@hp.com> on 2014/01/30 19:31:04 UTC

can't determine why I get 404

My WS-RS client successfully loads a requested resource.
I have verified that contentBytes has the correct resource.
But I still get this error message
2014-01-30 13:16:33,382 INFO org.apache.wink.server.internal.RequestProcessor - The following error occurred during the
invocation of the handlers chain: WebApplicationException (404 - Not Found) with message 'null' while processing GET request sent to http://localhost:8080/myApp/resource/editor/css/bootstrap.css - 108657<http://localhost:8080/myApp/resource/editor/css/bootstrap.css%20-%20108657>

@Path(Controller.EDITOR_CSS_RESOURCE)
@Produces("text/css")
public Response getEditorCSSResource(@Context UriInfo ui)
{
       InputStream inStream;
       byte[] contentBytes = null;
       try {
           inStream = this.getClass().getClassLoader().getResourceAsStream("/resource/" + ui.getPath());
           contentBytes = IOUtils.toByteArray(inStream);
           inStream.close();
       }
       catch(IOException e) {
           e.printStackTrace();
       }
       return Response.ok(contentBytes, "text/css").build();
}

I have used this same above method in a different WS-RS client and it works fine.  The only difference is where I load the resource, but content bytes is the same.

Thanks.
-Steve

RE: can't determine why I get 404

Posted by "Pruitt, Byron S" <st...@hp.com>.
Finally, finally figured it out.  My problem was in the @Path annotation.  I had this:  @Path("/css").  But, my url was ../css/bootstrap.css.  I started playing around with annotation value and got things working.  Finally made the annotation value “/css/{fileName}" and it worked.

My problem was being fooled by the method still executing even the though the annotation was wrong.  So I thought there wasn’t anything wrong with the annotation.

Live and learn.

Thanks.

-Steve
From: Luciano Resende [mailto:luckbr1975@gmail.com]
Sent: Thursday, January 30, 2014 4:15 PM
To: user@wink.apache.org
Subject: Re: can't determine why I get 404

What do you mean by "the only difference is where I load the resource" ?

Also, could it be some clients passing the proper Content-type/Accept headers, where others are not ?

On Thu, Jan 30, 2014 at 10:31 AM, Pruitt, Byron S <st...@hp.com>> wrote:
My WS-RS client successfully loads a requested resource.
I have verified that contentBytes has the correct resource.
But I still get this error message
2014-01-30 13:16:33,382 INFO org.apache.wink.server.internal.RequestProcessor - The following error occurred during the
invocation of the handlers chain: WebApplicationException (404 - Not Found) with message 'null' while processing GET request sent to http://localhost:8080/myApp/resource/editor/css/bootstrap.css - 108657<http://localhost:8080/myApp/resource/editor/css/bootstrap.css%20-%20108657>

@Path(Controller.EDITOR_CSS_RESOURCE)
@Produces("text/css")
public Response getEditorCSSResource(@Context UriInfo ui)
{
       InputStream inStream;
       byte[] contentBytes = null;
       try {
           inStream = this.getClass().getClassLoader().getResourceAsStream("/resource/" + ui.getPath());
           contentBytes = IOUtils.toByteArray(inStream);
           inStream.close();
       }
       catch(IOException e) {
           e.printStackTrace();
       }
       return Response.ok(contentBytes, "text/css").build();
}

I have used this same above method in a different WS-RS client and it works fine.  The only difference is where I load the resource, but content bytes is the same.

Thanks.
-Steve



--
Luciano Resende
http://people.apache.org/~lresende
http://twitter.com/lresende1975
http://lresende.blogspot.com/

Re: can't determine why I get 404

Posted by Luciano Resende <lu...@gmail.com>.
What do you mean by "the only difference is where I load the resource" ?

Also, could it be some clients passing the proper Content-type/Accept
headers, where others are not ?


On Thu, Jan 30, 2014 at 10:31 AM, Pruitt, Byron S <st...@hp.com>wrote:

>  My WS-RS client successfully loads a requested resource.
>
> I have verified that contentBytes has the correct resource.
>
> But I still get this error message
>
> 2014-01-30 13:16:33,382 INFO
> org.apache.wink.server.internal.RequestProcessor - The following error
> occurred during the
>
> invocation of the handlers chain: WebApplicationException (404 - Not
> Found) with message 'null' while processing GET request sent to http://localhost:8080/myApp/resource/editor/css/bootstrap.css
> - 108657
>
>
>
> @Path(Controller.*EDITOR_CSS_RESOURCE*)
>
> @Produces("text/css")
>
> *public* Response getEditorCSSResource(@Context UriInfo ui)
>
> {
>
>        InputStream inStream;
>
>        *byte*[] contentBytes = *null*;
>
>        *try* {
>
>            inStream = *this*
> .getClass().getClassLoader().getResourceAsStream("/resource/" +
> ui.getPath());
>
>            contentBytes = IOUtils.*toByteArray*(inStream);
>
>            inStream.close();
>
>        }
>
>        *catch*(IOException e) {
>
>            e.printStackTrace();
>
>        }
>
>        *return* Response.*ok*(contentBytes, "text/css").build();
>
> }
>
>
>
> I have used this same above method in a different WS-RS client and it
> works fine.  The only difference is where I load the resource, but content
> bytes is the same.
>
>
>
> Thanks.
>
> -Steve
>



-- 
Luciano Resende
http://people.apache.org/~lresende
http://twitter.com/lresende1975
http://lresende.blogspot.com/