missing servletPath and contextPath with WebSockets

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

missing servletPath and contextPath with WebSockets

digsim
Hi,
I'm developing a REST application and would add some WebSocket to it. I did my first tests (based on the provided samples with the atmosphere framework) and finally got running everyting with Jetty 8.0.0.M3 and atmosphere 0.8-SNAPSHOT.

However when i started developing my own applications I figure the following problem:

I define a url-pattern in my web.xml:
<servlet-mapping>
    <servlet-name>wstest</servlet-name>
    <url-pattern>/work/*</url-pattern>
</servlet-mapping>

The final application is deployed under "wstest".

I have a first REST class like:

@Path("/myresource")
public class MyResource {
   
    @GET
    @Produces("text/plain")
    public String getIt() {
    return "Hello"
    }
 }

which I can address fine under http://localhost:9090/wstest/work/myresource

Besides, I have another class (the WebSocket) like:

@Path("/status")
public class MyOtherResource {

   
    @GET
    @Suspend
    public SuspendResponse<String> subscribe() {
        Broadcaster topic = BroadcasterFactory.getDefault().lookup(JerseyBroadcaster.class, "5", true);
        return new SuspendResponse.SuspendResponseBuilder<String>()
                .broadcaster(topic)
                .outputComments(true)
                .addListener(new WSEventListener())
                .build();
    }

 
}

(and of course the class WSEventListener which just does some logging).

Yet, I am unable to make a WebSocket connection (I use chromium togheter with the "Dark WebSocket Terminal"). When I connect to ws://localhost:9090/wstest/work/status/ I get in the Jetty log:

14505 [qtp491187868-24] INFO org.atmosphere.cpr.AtmosphereServlet - WebSocket upgrade requested
14520 [qtp491187868-24] INFO org.atmosphere.cpr.WebSocketProcessor - Atmosphere detected WebSocketSupport: org.atmosphere.websocket.container.JettyWebSocketSupport

and in the browser:
16:11:19 system: connection established, ws://localhost:9090/wstest/work/status
16:11:19 system: connection closed, ws://localhost:9090/wstest/work/status

so no error occurs.
When i change the @Path annotation to @Path("/work/status") everything works fine.

After some digging around I found out why it behaves like this. If I set a breakpoint in my MyOtherResource class I can see that
in the JettyWebSocketHandler class the Request object contains the following:
*) _contextPath is null
*) _pathInfo is "/wstest/work/status/"
*) _requestURI is "/wstest/work/status/"
*) _servletPath is ""
which IMHO is not correct.

I further found out that when the constructor of the JettyWebSocketHandler class is called everything is initialized well:
*) _contextPath is "/wstest"
*) _pathInfo is "/status"
*) _requestURI is "/wstest/work/status/"
*) _servletPath is "/work"
but later when the onConnect() function is called _contextPath, _pathInfo and _servletPath values are changed. If I change these variables by hand (during debugging in JettyWebSocketHandler.onConnect() just before executing webSocketProcessor.connect(new JettyRequestFix(request));) everything seems to work.

Though, my question: is this behaviour normal (REST classes use @Path("/abc") whereas WebSocket classes use @Path(/work/abc) "/work" beeing the servletPath)?

Jetty: 8.0.0.M3
Atmosphere: 0.8-SNAPSHOT
Google Chrome: 12.0.742.112 (90304) Ubuntu 11.04
OS: Ubuntu

BTW: you can find a simple Maven project showing the problem at websocket-test-webapp.tar.bz2 or http://diuf.unifr.ch/people/ruppena/websocket-test-webapp.tar.bz2
Reply | Threaded
Open this post in threaded view
|

[atmosphere-users] Re: missing servletPath and contextPath with WebSockets

Jeanfrancois Arcand-4

Salut,

I recall with early version of Jetty I was experiencing issue with the
path value, but I think that has been fixed. I will work on it and push
the fix in 0.8-SNAPSHOT.

Thanks!

-- Jeanfrancois

P.S Let continue the on [hidden email] where
there is no delay like right now with java.net


On 11-09-19 7:48 AM, digsim wrote:

> Hi,
> I'm developing a REST application and would add some WebSocket to it. I did
> my first tests (based on the provided samples with the atmosphere framework)
> and finally got running everyting with Jetty 8.0.0.M3 and atmosphere
> 0.8-SNAPSHOT.
>
> However when i started developing my own applications I figure the following
> problem:
>
> I define a url-pattern in my web.xml:
> <servlet-mapping>
>      <servlet-name>wstest</servlet-name>
>      <url-pattern>/work/*</url-pattern>
> </servlet-mapping>
>
> The final application is deployed under "wstest".
>
> I have a first REST class like:
>
> @Path("/myresource")
> public class MyResource {
>
>      @GET
>      @Produces("text/plain")
>      public String getIt() {
>       return "Hello"
>      }
>   }
>
> which I can address fine under http://localhost:9090/wstest/work/myresource
>
> Besides, I have another class (the WebSocket) like:
>
> @Path("/status")
> public class MyOtherResource {
>
>
>      @GET
>      @Suspend
>      public SuspendResponse<String>  subscribe() {
>          Broadcaster topic =
> BroadcasterFactory.getDefault().lookup(JerseyBroadcaster.class, "5", true);
>          return new SuspendResponse.SuspendResponseBuilder<String>()
>                  .broadcaster(topic)
>                  .outputComments(true)
>                  .addListener(new WSEventListener())
>                  .build();
>      }
>
>
> }
>
> (and of course the class WSEventListener which just does some logging).
>
> Yet, I am unable to make a WebSocket connection (I use chromium togheter
> with the "Dark WebSocket Terminal"). When I connect to
> ws://localhost:9090/wstest/work/status/ I get in the Jetty log:
>
> 14505 [qtp491187868-24] INFO org.atmosphere.cpr.AtmosphereServlet -
> WebSocket upgrade requested
> 14520 [qtp491187868-24] INFO org.atmosphere.cpr.WebSocketProcessor -
> Atmosphere detected WebSocketSupport:
> org.atmosphere.websocket.container.JettyWebSocketSupport
>
> and in the browser:
> 16:11:19 system: connection established,
> ws://localhost:9090/wstest/work/status
> 16:11:19 system: connection closed, ws://localhost:9090/wstest/work/status
>
> so no error occurs.
> When i change the @Path annotation to @Path("/work/status") everything works
> fine.
>
> After some digging around I found out why it behaves like this. If I set a
> breakpoint in my MyOtherResource class I can see that
> in the JettyWebSocketHandler class the Request object contains the
> following:
> *) _contextPath is null
> *) _pathInfo is "/wstest/work/status/"
> *) _requestURI is "/wstest/work/status/"
> *) _servletPath is ""
> which IMHO is not correct.
>
> I further found out that when the constructor of the JettyWebSocketHandler
> class is called everything is initialized well:
> *) _contextPath is "/wstest"
> *) _pathInfo is "/status"
> *) _requestURI is "/wstest/work/status/"
> *) _servletPath is "/work"
> but later when the onConnect() function is called _contextPath, _pathInfo
> and _servletPath values are changed. If I change these variables by hand
> (during debugging in JettyWebSocketHandler.onConnect() just before executing
> webSocketProcessor.connect(new JettyRequestFix(request));) everything seems
> to work.
>
> Though, my question: is this behaviour normal (REST classes use
> @Path("/abc") whereas WebSocket classes use @Path(/work/abc) "/work" beeing
> the servletPath)?
>
> Jetty: 8.0.0.M3
> Atmosphere: 0.8-SNAPSHOT
> Google Chrome: 12.0.742.112 (90304) Ubuntu 11.04
> OS: Ubuntu
>
> BTW: you can find a simple Maven project showing the problem at
> http://atmosphere-users-mailling-list.2493822.n2.nabble.com/file/n6808645/websocket-test-webapp.tar.bz2
> websocket-test-webapp.tar.bz2  or
> http://diuf.unifr.ch/people/ruppena/websocket-test-webapp.tar.bz2
>
> --
> View this message in context: http://atmosphere-users-mailling-list.2493822.n2.nabble.com/missing-servletPath-and-contextPath-with-WebSockets-tp6808645p6808645.html
> Sent from the Atmosphere users mailling list mailing list archive at Nabble.com.
Reply | Threaded
Open this post in threaded view
|

[atmosphere-users] {fixed} Re: missing servletPath and contextPath with WebSockets

Jeanfrancois Arcand-4
Salut,

I've implemented a workaround and uploaded the SNAPSHOT.

BTW note that I've found a regression (confirmed by the Jetty dev) with
7.5.1 and 8.0.1, so stick with M3 for now.

Let me know how it goes.

A+

-- Jeanfrancois


On 11-09-19 11:45 AM, Jeanfrancois Arcand wrote:

>
> Salut,
>
> I recall with early version of Jetty I was experiencing issue with the
> path value, but I think that has been fixed. I will work on it and
> push the fix in 0.8-SNAPSHOT.
>
> Thanks!
>
> -- Jeanfrancois
>
> P.S Let continue the on [hidden email] where
> there is no delay like right now with java.net
>
>
> On 11-09-19 7:48 AM, digsim wrote:
>> Hi,
>> I'm developing a REST application and would add some WebSocket to it.
>> I did
>> my first tests (based on the provided samples with the atmosphere
>> framework)
>> and finally got running everyting with Jetty 8.0.0.M3 and atmosphere
>> 0.8-SNAPSHOT.
>>
>> However when i started developing my own applications I figure the
>> following
>> problem:
>>
>> I define a url-pattern in my web.xml:
>> <servlet-mapping>
>> <servlet-name>wstest</servlet-name>
>> <url-pattern>/work/*</url-pattern>
>> </servlet-mapping>
>>
>> The final application is deployed under "wstest".
>>
>> I have a first REST class like:
>>
>> @Path("/myresource")
>> public class MyResource {
>>
>>      @GET
>>      @Produces("text/plain")
>>      public String getIt() {
>>          return "Hello"
>>      }
>>   }
>>
>> which I can address fine under
>> http://localhost:9090/wstest/work/myresource
>>
>> Besides, I have another class (the WebSocket) like:
>>
>> @Path("/status")
>> public class MyOtherResource {
>>
>>
>>      @GET
>>      @Suspend
>>      public SuspendResponse<String>  subscribe() {
>>          Broadcaster topic =
>> BroadcasterFactory.getDefault().lookup(JerseyBroadcaster.class, "5",
>> true);
>>          return new SuspendResponse.SuspendResponseBuilder<String>()
>>                  .broadcaster(topic)
>>                  .outputComments(true)
>>                  .addListener(new WSEventListener())
>>                  .build();
>>      }
>>
>>
>> }
>>
>> (and of course the class WSEventListener which just does some logging).
>>
>> Yet, I am unable to make a WebSocket connection (I use chromium togheter
>> with the "Dark WebSocket Terminal"). When I connect to
>> ws://localhost:9090/wstest/work/status/ I get in the Jetty log:
>>
>> 14505 [qtp491187868-24] INFO org.atmosphere.cpr.AtmosphereServlet -
>> WebSocket upgrade requested
>> 14520 [qtp491187868-24] INFO org.atmosphere.cpr.WebSocketProcessor -
>> Atmosphere detected WebSocketSupport:
>> org.atmosphere.websocket.container.JettyWebSocketSupport
>>
>> and in the browser:
>> 16:11:19    system:    connection established,
>> ws://localhost:9090/wstest/work/status
>> 16:11:19    system:    connection closed,
>> ws://localhost:9090/wstest/work/status
>>
>> so no error occurs.
>> When i change the @Path annotation to @Path("/work/status")
>> everything works
>> fine.
>>
>> After some digging around I found out why it behaves like this. If I
>> set a
>> breakpoint in my MyOtherResource class I can see that
>> in the JettyWebSocketHandler class the Request object contains the
>> following:
>> *) _contextPath is null
>> *) _pathInfo is "/wstest/work/status/"
>> *) _requestURI is "/wstest/work/status/"
>> *) _servletPath is ""
>> which IMHO is not correct.
>>
>> I further found out that when the constructor of the
>> JettyWebSocketHandler
>> class is called everything is initialized well:
>> *) _contextPath is "/wstest"
>> *) _pathInfo is "/status"
>> *) _requestURI is "/wstest/work/status/"
>> *) _servletPath is "/work"
>> but later when the onConnect() function is called _contextPath,
>> _pathInfo
>> and _servletPath values are changed. If I change these variables by hand
>> (during debugging in JettyWebSocketHandler.onConnect() just before
>> executing
>> webSocketProcessor.connect(new JettyRequestFix(request));) everything
>> seems
>> to work.
>>
>> Though, my question: is this behaviour normal (REST classes use
>> @Path("/abc") whereas WebSocket classes use @Path(/work/abc) "/work"
>> beeing
>> the servletPath)?
>>
>> Jetty: 8.0.0.M3
>> Atmosphere: 0.8-SNAPSHOT
>> Google Chrome: 12.0.742.112 (90304) Ubuntu 11.04
>> OS: Ubuntu
>>
>> BTW: you can find a simple Maven project showing the problem at
>> http://atmosphere-users-mailling-list.2493822.n2.nabble.com/file/n6808645/websocket-test-webapp.tar.bz2 
>>
>> websocket-test-webapp.tar.bz2  or
>> http://diuf.unifr.ch/people/ruppena/websocket-test-webapp.tar.bz2
>>
>> --
>> View this message in context:
>> http://atmosphere-users-mailling-list.2493822.n2.nabble.com/missing-servletPath-and-contextPath-with-WebSockets-tp6808645p6808645.html
>> Sent from the Atmosphere users mailling list mailing list archive at
>> Nabble.com.
Reply | Threaded
Open this post in threaded view
|

[atmosphere-users] Re: {fixed} Re: missing servletPath and contextPath with WebSockets

Jeanfrancois Arcand-4
Hum, I can't upload the SNAPSHOT from here. So you will need to build
the workspace :-)

Thanks!

-- Jeanfrancois

On 11-09-19 6:49 PM, Jeanfrancois Arcand wrote:

> Salut,
>
> I've implemented a workaround and uploaded the SNAPSHOT.
>
> BTW note that I've found a regression (confirmed by the Jetty dev)
> with 7.5.1 and 8.0.1, so stick with M3 for now.
>
> Let me know how it goes.
>
> A+
>
> -- Jeanfrancois
>
>
> On 11-09-19 11:45 AM, Jeanfrancois Arcand wrote:
>>
>> Salut,
>>
>> I recall with early version of Jetty I was experiencing issue with
>> the path value, but I think that has been fixed. I will work on it
>> and push the fix in 0.8-SNAPSHOT.
>>
>> Thanks!
>>
>> -- Jeanfrancois
>>
>> P.S Let continue the on [hidden email] where
>> there is no delay like right now with java.net
>>
>>
>> On 11-09-19 7:48 AM, digsim wrote:
>>> Hi,
>>> I'm developing a REST application and would add some WebSocket to
>>> it. I did
>>> my first tests (based on the provided samples with the atmosphere
>>> framework)
>>> and finally got running everyting with Jetty 8.0.0.M3 and atmosphere
>>> 0.8-SNAPSHOT.
>>>
>>> However when i started developing my own applications I figure the
>>> following
>>> problem:
>>>
>>> I define a url-pattern in my web.xml:
>>> <servlet-mapping>
>>> <servlet-name>wstest</servlet-name>
>>> <url-pattern>/work/*</url-pattern>
>>> </servlet-mapping>
>>>
>>> The final application is deployed under "wstest".
>>>
>>> I have a first REST class like:
>>>
>>> @Path("/myresource")
>>> public class MyResource {
>>>
>>>      @GET
>>>      @Produces("text/plain")
>>>      public String getIt() {
>>>          return "Hello"
>>>      }
>>>   }
>>>
>>> which I can address fine under
>>> http://localhost:9090/wstest/work/myresource
>>>
>>> Besides, I have another class (the WebSocket) like:
>>>
>>> @Path("/status")
>>> public class MyOtherResource {
>>>
>>>
>>>      @GET
>>>      @Suspend
>>>      public SuspendResponse<String>  subscribe() {
>>>          Broadcaster topic =
>>> BroadcasterFactory.getDefault().lookup(JerseyBroadcaster.class, "5",
>>> true);
>>>          return new SuspendResponse.SuspendResponseBuilder<String>()
>>>                  .broadcaster(topic)
>>>                  .outputComments(true)
>>>                  .addListener(new WSEventListener())
>>>                  .build();
>>>      }
>>>
>>>
>>> }
>>>
>>> (and of course the class WSEventListener which just does some logging).
>>>
>>> Yet, I am unable to make a WebSocket connection (I use chromium
>>> togheter
>>> with the "Dark WebSocket Terminal"). When I connect to
>>> ws://localhost:9090/wstest/work/status/ I get in the Jetty log:
>>>
>>> 14505 [qtp491187868-24] INFO org.atmosphere.cpr.AtmosphereServlet -
>>> WebSocket upgrade requested
>>> 14520 [qtp491187868-24] INFO org.atmosphere.cpr.WebSocketProcessor -
>>> Atmosphere detected WebSocketSupport:
>>> org.atmosphere.websocket.container.JettyWebSocketSupport
>>>
>>> and in the browser:
>>> 16:11:19    system:    connection established,
>>> ws://localhost:9090/wstest/work/status
>>> 16:11:19    system:    connection closed,
>>> ws://localhost:9090/wstest/work/status
>>>
>>> so no error occurs.
>>> When i change the @Path annotation to @Path("/work/status")
>>> everything works
>>> fine.
>>>
>>> After some digging around I found out why it behaves like this. If I
>>> set a
>>> breakpoint in my MyOtherResource class I can see that
>>> in the JettyWebSocketHandler class the Request object contains the
>>> following:
>>> *) _contextPath is null
>>> *) _pathInfo is "/wstest/work/status/"
>>> *) _requestURI is "/wstest/work/status/"
>>> *) _servletPath is ""
>>> which IMHO is not correct.
>>>
>>> I further found out that when the constructor of the
>>> JettyWebSocketHandler
>>> class is called everything is initialized well:
>>> *) _contextPath is "/wstest"
>>> *) _pathInfo is "/status"
>>> *) _requestURI is "/wstest/work/status/"
>>> *) _servletPath is "/work"
>>> but later when the onConnect() function is called _contextPath,
>>> _pathInfo
>>> and _servletPath values are changed. If I change these variables by
>>> hand
>>> (during debugging in JettyWebSocketHandler.onConnect() just before
>>> executing
>>> webSocketProcessor.connect(new JettyRequestFix(request));)
>>> everything seems
>>> to work.
>>>
>>> Though, my question: is this behaviour normal (REST classes use
>>> @Path("/abc") whereas WebSocket classes use @Path(/work/abc) "/work"
>>> beeing
>>> the servletPath)?
>>>
>>> Jetty: 8.0.0.M3
>>> Atmosphere: 0.8-SNAPSHOT
>>> Google Chrome: 12.0.742.112 (90304) Ubuntu 11.04
>>> OS: Ubuntu
>>>
>>> BTW: you can find a simple Maven project showing the problem at
>>> http://atmosphere-users-mailling-list.2493822.n2.nabble.com/file/n6808645/websocket-test-webapp.tar.bz2 
>>>
>>> websocket-test-webapp.tar.bz2  or
>>> http://diuf.unifr.ch/people/ruppena/websocket-test-webapp.tar.bz2
>>>
>>> --
>>> View this message in context:
>>> http://atmosphere-users-mailling-list.2493822.n2.nabble.com/missing-servletPath-and-contextPath-with-WebSockets-tp6808645p6808645.html
>>> Sent from the Atmosphere users mailling list mailing list archive at
>>> Nabble.com.
Reply | Threaded
Open this post in threaded view
|

[atmosphere-users] Re: {fixed} Re: missing servletPath and contextPath with WebSockets

Stuart Roebuck-2
In reply to this post by Jeanfrancois Arcand-4
Thank you digsim and Jeanfrancois, that sounds like one of my other problems.  Will try that out shortly.

Stuart

On 20 Sep 2011, at 02:49 AM, Jeanfrancois Arcand <[hidden email]> wrote:

> Salut,
>
> I've implemented a workaround and uploaded the SNAPSHOT.
>
> BTW note that I've found a regression (confirmed by the Jetty dev) with 7.5.1 and 8.0.1, so stick with M3 for now.
>
> Let me know how it goes.
>
> A+
>
> -- Jeanfrancois
>
>
> On 11-09-19 11:45 AM, Jeanfrancois Arcand wrote:
>>
>> Salut,
>>
>> I recall with early version of Jetty I was experiencing issue with the path value, but I think that has been fixed. I will work on it and push the fix in 0.8-SNAPSHOT.
>>
>> Thanks!
>>
>> -- Jeanfrancois
>>
>> P.S Let continue the on [hidden email] where there is no delay like right now with java.net
>>
>>
>> On 11-09-19 7:48 AM, digsim wrote:
>>> Hi,
>>> I'm developing a REST application and would add some WebSocket to it. I did
>>> my first tests (based on the provided samples with the atmosphere framework)
>>> and finally got running everyting with Jetty 8.0.0.M3 and atmosphere
>>> 0.8-SNAPSHOT.
>>>
>>> However when i started developing my own applications I figure the following
>>> problem:
>>>
>>> I define a url-pattern in my web.xml:
>>> <servlet-mapping>
>>> <servlet-name>wstest</servlet-name>
>>> <url-pattern>/work/*</url-pattern>
>>> </servlet-mapping>
>>>
>>> The final application is deployed under "wstest".
>>>
>>> I have a first REST class like:
>>>
>>> @Path("/myresource")
>>> public class MyResource {
>>>
>>>     @GET
>>>     @Produces("text/plain")
>>>     public String getIt() {
>>>         return "Hello"
>>>     }
>>>  }
>>>
>>> which I can address fine under http://localhost:9090/wstest/work/myresource
>>>
>>> Besides, I have another class (the WebSocket) like:
>>>
>>> @Path("/status")
>>> public class MyOtherResource {
>>>
>>>
>>>     @GET
>>>     @Suspend
>>>     public SuspendResponse<String>  subscribe() {
>>>         Broadcaster topic =
>>> BroadcasterFactory.getDefault().lookup(JerseyBroadcaster.class, "5", true);
>>>         return new SuspendResponse.SuspendResponseBuilder<String>()
>>>                 .broadcaster(topic)
>>>                 .outputComments(true)
>>>                 .addListener(new WSEventListener())
>>>                 .build();
>>>     }
>>>
>>>
>>> }
>>>
>>> (and of course the class WSEventListener which just does some logging).
>>>
>>> Yet, I am unable to make a WebSocket connection (I use chromium togheter
>>> with the "Dark WebSocket Terminal"). When I connect to
>>> ws://localhost:9090/wstest/work/status/ I get in the Jetty log:
>>>
>>> 14505 [qtp491187868-24] INFO org.atmosphere.cpr.AtmosphereServlet -
>>> WebSocket upgrade requested
>>> 14520 [qtp491187868-24] INFO org.atmosphere.cpr.WebSocketProcessor -
>>> Atmosphere detected WebSocketSupport:
>>> org.atmosphere.websocket.container.JettyWebSocketSupport
>>>
>>> and in the browser:
>>> 16:11:19    system:    connection established,
>>> ws://localhost:9090/wstest/work/status
>>> 16:11:19    system:    connection closed, ws://localhost:9090/wstest/work/status
>>>
>>> so no error occurs.
>>> When i change the @Path annotation to @Path("/work/status") everything works
>>> fine.
>>>
>>> After some digging around I found out why it behaves like this. If I set a
>>> breakpoint in my MyOtherResource class I can see that
>>> in the JettyWebSocketHandler class the Request object contains the
>>> following:
>>> *) _contextPath is null
>>> *) _pathInfo is "/wstest/work/status/"
>>> *) _requestURI is "/wstest/work/status/"
>>> *) _servletPath is ""
>>> which IMHO is not correct.
>>>
>>> I further found out that when the constructor of the JettyWebSocketHandler
>>> class is called everything is initialized well:
>>> *) _contextPath is "/wstest"
>>> *) _pathInfo is "/status"
>>> *) _requestURI is "/wstest/work/status/"
>>> *) _servletPath is "/work"
>>> but later when the onConnect() function is called _contextPath, _pathInfo
>>> and _servletPath values are changed. If I change these variables by hand
>>> (during debugging in JettyWebSocketHandler.onConnect() just before executing
>>> webSocketProcessor.connect(new JettyRequestFix(request));) everything seems
>>> to work.
>>>
>>> Though, my question: is this behaviour normal (REST classes use
>>> @Path("/abc") whereas WebSocket classes use @Path(/work/abc) "/work" beeing
>>> the servletPath)?
>>>
>>> Jetty: 8.0.0.M3
>>> Atmosphere: 0.8-SNAPSHOT
>>> Google Chrome: 12.0.742.112 (90304) Ubuntu 11.04
>>> OS: Ubuntu
>>>
>>> BTW: you can find a simple Maven project showing the problem at
>>> http://atmosphere-users-mailling-list.2493822.n2.nabble.com/file/n6808645/websocket-test-webapp.tar.bz2 
>>> websocket-test-webapp.tar.bz2  or
>>> http://diuf.unifr.ch/people/ruppena/websocket-test-webapp.tar.bz2
>>>
>>> --
>>> View this message in context: http://atmosphere-users-mailling-list.2493822.n2.nabble.com/missing-servletPath-and-contextPath-with-WebSockets-tp6808645p6808645.html
>>> Sent from the Atmosphere users mailling list mailing list archive at Nabble.com.
Reply | Threaded
Open this post in threaded view
|

Re: [atmosphere-users] {fixed} Re: missing servletPath and contextPath with WebSockets

digsim
Salut,
sorry for the late replay, I was stuck in meetings all the day.

Thank your for the quick fix. I downloaded the new code from git, compiled it and tried it against my sample application which now works as expected. I also quickly did a debug of the application and now everything seems fine to me.

à+
Andreas

Le 20 sept. 2011 à 18:56, Stuart Roebuck-2 [via Atmosphere users mailling list] a écrit :

> Thank you digsim and Jeanfrancois, that sounds like one of my other problems.  Will try that out shortly.
>
> Stuart
>
> On 20 Sep 2011, at 02:49 AM, Jeanfrancois Arcand <[hidden email]> wrote:
>
> > Salut,
> >
> > I've implemented a workaround and uploaded the SNAPSHOT.
> >
> > BTW note that I've found a regression (confirmed by the Jetty dev) with 7.5.1 and 8.0.1, so stick with M3 for now.
> >
> > Let me know how it goes.
> >
> > A+
> >
> > -- Jeanfrancois
> >
> >
> > On 11-09-19 11:45 AM, Jeanfrancois Arcand wrote:
> >>
> >> Salut,
> >>
> >> I recall with early version of Jetty I was experiencing issue with the path value, but I think that has been fixed. I will work on it and push the fix in 0.8-SNAPSHOT.
> >>
> >> Thanks!
> >>
> >> -- Jeanfrancois
> >>
> >> P.S Let continue the on [hidden email] where there is no delay like right now with java.net
> >>
> >>
> >> On 11-09-19 7:48 AM, digsim wrote:
> >>> Hi,
> >>> I'm developing a REST application and would add some WebSocket to it. I did
> >>> my first tests (based on the provided samples with the atmosphere framework)
> >>> and finally got running everyting with Jetty 8.0.0.M3 and atmosphere
> >>> 0.8-SNAPSHOT.
> >>>
> >>> However when i started developing my own applications I figure the following
> >>> problem:
> >>>
> >>> I define a url-pattern in my web.xml:
> >>> <servlet-mapping>
> >>> <servlet-name>wstest</servlet-name>
> >>> <url-pattern>/work/*</url-pattern>
> >>> </servlet-mapping>
> >>>
> >>> The final application is deployed under "wstest".
> >>>
> >>> I have a first REST class like:
> >>>
> >>> @Path("/myresource")
> >>> public class MyResource {
> >>>
> >>>     @GET
> >>>     @Produces("text/plain")
> >>>     public String getIt() {
> >>>         return "Hello"
> >>>     }
> >>>  }
> >>>
> >>> which I can address fine under http://localhost:9090/wstest/work/myresource
> >>>
> >>> Besides, I have another class (the WebSocket) like:
> >>>
> >>> @Path("/status")
> >>> public class MyOtherResource {
> >>>
> >>>
> >>>     @GET
> >>>     @Suspend
> >>>     public SuspendResponse<String>  subscribe() {
> >>>         Broadcaster topic =
> >>> BroadcasterFactory.getDefault().lookup(JerseyBroadcaster.class, "5", true);
> >>>         return new SuspendResponse.SuspendResponseBuilder<String>()
> >>>                 .broadcaster(topic)
> >>>                 .outputComments(true)
> >>>                 .addListener(new WSEventListener())
> >>>                 .build();
> >>>     }
> >>>
> >>>
> >>> }
> >>>
> >>> (and of course the class WSEventListener which just does some logging).
> >>>
> >>> Yet, I am unable to make a WebSocket connection (I use chromium togheter
> >>> with the "Dark WebSocket Terminal"). When I connect to
> >>> ws://localhost:9090/wstest/work/status/ I get in the Jetty log:
> >>>
> >>> 14505 [qtp491187868-24] INFO org.atmosphere.cpr.AtmosphereServlet -
> >>> WebSocket upgrade requested
> >>> 14520 [qtp491187868-24] INFO org.atmosphere.cpr.WebSocketProcessor -
> >>> Atmosphere detected WebSocketSupport:
> >>> org.atmosphere.websocket.container.JettyWebSocketSupport
> >>>
> >>> and in the browser:
> >>> 16:11:19    system:    connection established,
> >>> ws://localhost:9090/wstest/work/status
> >>> 16:11:19    system:    connection closed, ws://localhost:9090/wstest/work/status
> >>>
> >>> so no error occurs.
> >>> When i change the @Path annotation to @Path("/work/status") everything works
> >>> fine.
> >>>
> >>> After some digging around I found out why it behaves like this. If I set a
> >>> breakpoint in my MyOtherResource class I can see that
> >>> in the JettyWebSocketHandler class the Request object contains the
> >>> following:
> >>> *) _contextPath is null
> >>> *) _pathInfo is "/wstest/work/status/"
> >>> *) _requestURI is "/wstest/work/status/"
> >>> *) _servletPath is ""
> >>> which IMHO is not correct.
> >>>
> >>> I further found out that when the constructor of the JettyWebSocketHandler
> >>> class is called everything is initialized well:
> >>> *) _contextPath is "/wstest"
> >>> *) _pathInfo is "/status"
> >>> *) _requestURI is "/wstest/work/status/"
> >>> *) _servletPath is "/work"
> >>> but later when the onConnect() function is called _contextPath, _pathInfo
> >>> and _servletPath values are changed. If I change these variables by hand
> >>> (during debugging in JettyWebSocketHandler.onConnect() just before executing
> >>> webSocketProcessor.connect(new JettyRequestFix(request));) everything seems
> >>> to work.
> >>>
> >>> Though, my question: is this behaviour normal (REST classes use
> >>> @Path("/abc") whereas WebSocket classes use @Path(/work/abc) "/work" beeing
> >>> the servletPath)?
> >>>
> >>> Jetty: 8.0.0.M3
> >>> Atmosphere: 0.8-SNAPSHOT
> >>> Google Chrome: 12.0.742.112 (90304) Ubuntu 11.04
> >>> OS: Ubuntu
> >>>
> >>> BTW: you can find a simple Maven project showing the problem at
> >>> http://atmosphere-users-mailling-list.2493822.n2.nabble.com/file/n6808645/websocket-test-webapp.tar.bz2 
> >>> websocket-test-webapp.tar.bz2  or
> >>> http://diuf.unifr.ch/people/ruppena/websocket-test-webapp.tar.bz2
> >>>
> >>> --
> >>> View this message in context: http://atmosphere-users-mailling-list.2493822.n2.nabble.com/missing-servletPath-and-contextPath-with-WebSockets-tp6808645p6808645.html
> >>> Sent from the Atmosphere users mailling list mailing list archive at Nabble.com.
>
>
> If you reply to this email, your message will be added to the discussion below:
> http://atmosphere-users-mailling-list.2493822.n2.nabble.com/missing-servletPath-and-contextPath-with-WebSockets-tp6808645p6812997.html
> To unsubscribe from missing servletPath and contextPath with WebSockets, click here.