Jersey and static http handler

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Jersey and static http handler

Dezider Mesko
Hi,
I'm trying to setup Grizzly so StaticHttpHandler is serving content from local folder "./client" as server root like this:

server.getServerConfiguration().addHttpHandler(new StaticHttpHandler("./client"), "")

I have Jersey REST functions registered as well.

@Path("rest")
class RestFunctions {
...
    @GET @Path("staticData")
    @Produces("application/json")
    def getStaticData(){
...


Unfortunately function staticData is not invoked. Logs reports that path ./client/rest/staticData doesn't exist.

In other words, is possible to server static data and have rest functions on subpath?

Thank you, Dezo
Reply | Threaded
Open this post in threaded view
|

Re: Jersey and static http handler

oleksiys
Administrator
Hi,

pls. share your code (project on github?).

Thanks.

WBR,
Alexey.

On 14.01.15 13:34, Dezider Mesko wrote:

> Hi,
> I'm trying to setup Grizzly so StaticHttpHandler is serving content
> from local folder "./client" as server root like this:
>
> server.getServerConfiguration().addHttpHandler(new
> StaticHttpHandler("./client"), "")
>
> I have Jersey REST functions registered as well.
>
> @Path("rest")
> class RestFunctions {
> ...
>     @GET @Path("staticData")
>     @Produces("application/json")
>     def getStaticData(){
> ...
>
>
> Unfortunately function staticData is not invoked. Logs reports that
> path ./client/rest/staticData doesn't exist.
>
> In other words, is possible to server static data and have rest
> functions on subpath?
>
> Thank you, Dezo

Reply | Threaded
Open this post in threaded view
|

Re: Jersey and static http handler

Dezider Mesko
I've extracted some small reproducer.


Thank you

d.

On Thu, Jan 15, 2015 at 12:53 AM, Oleksiy Stashok <[hidden email]> wrote:
Hi,

pls. share your code (project on github?).

Thanks.

WBR,
Alexey.


On 14.01.15 13:34, Dezider Mesko wrote:
Hi,
I'm trying to setup Grizzly so StaticHttpHandler is serving content from local folder "./client" as server root like this:

server.getServerConfiguration().addHttpHandler(new StaticHttpHandler("./client"), "")

I have Jersey REST functions registered as well.

@Path("rest")
class RestFunctions {
...
    @GET @Path("staticData")
    @Produces("application/json")
    def getStaticData(){
...


Unfortunately function staticData is not invoked. Logs reports that path ./client/rest/staticData doesn't exist.

In other words, is possible to server static data and have rest functions on subpath?

Thank you, Dezo


Reply | Threaded
Open this post in threaded view
|

Re: Jersey and static http handler

oleksiys
Administrator
Looks like StaticHttpHandler for "/client" overwrites the Rest endpoint, because they are both registered on default context-root.
In order to fix it you have to use different context-root either for rest app or static handler.

If you want to use different context-root on rest app, your baseUri should look like:
http://localhost:9998/your-context-root

WBR,
Alexey.

On 15.01.15 03:03, Dezider Mesko wrote:
I've extracted some small reproducer.


Thank you

d.

On Thu, Jan 15, 2015 at 12:53 AM, Oleksiy Stashok <[hidden email]> wrote:
Hi,

pls. share your code (project on github?).

Thanks.

WBR,
Alexey.


On 14.01.15 13:34, Dezider Mesko wrote:
Hi,
I'm trying to setup Grizzly so StaticHttpHandler is serving content from local folder "./client" as server root like this:

server.getServerConfiguration().addHttpHandler(new StaticHttpHandler("./client"), "")

I have Jersey REST functions registered as well.

@Path("rest")
class RestFunctions {
...
    @GET @Path("staticData")
    @Produces("application/json")
    def getStaticData(){
...


Unfortunately function staticData is not invoked. Logs reports that path ./client/rest/staticData doesn't exist.

In other words, is possible to server static data and have rest functions on subpath?

Thank you, Dezo