You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Amit <ad...@amitinside.com> on 2019/03/08 12:20:49 UTC

HTTP Whiteboard HttpSessionListener Problem

Hi,

I am currently struggling with HTTP Whiteboard Session Listener. I have 2 servlets that use their own ServletContextHelpers and ServletFilters which are registered for both the aforementioned Servlet Contexts. The filters and servlets are working as expected but the custom HttpSessionListener callbacks are never getting triggered when HttpRequest#getSession() is invoked in one of the servlets.

As an example,

@Component
@HttpWhiteboardListener
public final class ApplicationSession implements HttpSessionListener {

    private final AtomicInteger activeSessions = new AtomicInteger();

    @Override
    public void sessionCreated(final HttpSessionEvent sessionEvent) {
        activeSessions.incrementAndGet();
    }

    @Override
    public void sessionDestroyed(final HttpSessionEvent sessionEvent) {
        activeSessions.decrementAndGet();
    }

    public boolean isSessionValid() {
        return activeSessions.get() != 0;
    }

}

This is the custom listener I registered with the HTTP Whiteboard and it never gets invoked when I call HttpRequest#getSession().

Is there anything I am missing? I would really appreciate further help on this regard. For your information, I am currently using the latest version of Felix Jetty Bundle (4.0.6).

Thanks and Regards,

Amit Kumar Mondal
Phone: +49 160 9100 3436  Email: amit@amitinside.com
Skype: arsenalnerk   GitHub: amitjoy
Blog: blog.amitinside.com

Re[2]: HTTP Whiteboard HttpSessionListener Problem

Posted by Thomas Driessen <th...@gmail.com>.
Hi Amit,

sorry but I don't think I can help you with that :( Your first error 
just sounded very similar to what I experienced. If You think it is a 
bug then you should file one in Felix's bug tracking system: 
https://issues.apache.org/jira/projects/FELIX/issues/

Maybe add a minimal example that showcases what you are trying to do.

Kind regards,
Thomas

------ Originalnachricht ------
Von: "Amit" <ad...@amitinside.com>
An: "Thomas Driessen" <th...@gmail.com>; 
users@felix.apache.org
Gesendet: 08.03.2019 14:07:58
Betreff: Re: HTTP Whiteboard HttpSessionListener Problem

>Hi Thomas,
>
>Thanks for the quick response. The HttpSessionListener component was in 
>SATISFIED state since no other client consumed it (lazy component). I 
>had set the component property type to string and the 
>HttpSessionListener became ACTIVE. Unfortunately the 
>HttpSessionListener is still not getting triggered when session gets 
>created. I also switched to the latest version of Felix Jetty Bundle 
>(4.0.8) and it is still the same.
>
>Do you have any further idea?
>
>Thanks and Regards,
>
>Amit Kumar Mondal
>Phone: +49 160 9100 3436  Email: amit@amitinside.com 
><ma...@amitinside.com>
>Skype: arsenalnerk   GitHub: a <http://blog.amitinside.com/>mitjoy
>Blog: blog.amitinside.com <http://www.amitinside.com/>
>
>Am 8. März 2019 um 13:52:46, Thomas Driessen 
>(thomas.driessen.td@gmail.com) schrieb:
>
>>Hi Amit,
>>
>>maybe this is a similar issue as the one I had with
>>ServletContextListeners? See here:
>>https://issues.apache.org/jira/browse/FELIX-6049
>>
>>In order to rule that out maybe you could try to register your
>>HttpSessionListener not via the ComponentPropertyType annotation but
>>with a plain property like this:
>>
>>@Component(property= {HttpWhiteboardConstants.HTTP_WHITEBOARD_LISTENER 
>>+
>>"=true"})
>>
>>
>>Be aware that the property value has to be of type String and not of
>>type boolean!
>>If this solves your problem then you should update your dependencies 
>>as
>>in the new versions of Felix Jetty this bug should be fixed.
>>
>>Kind regards,
>>Thomas
>>------ Originalnachricht ------
>>Von: "Amit" <ad...@amitinside.com>
>>An: users@felix.apache.org
>>Gesendet: 08.03.2019 13:20:49
>>Betreff: HTTP Whiteboard HttpSessionListener Problem
>>
>> >Hi,
>> >
>> >I am currently struggling with HTTP Whiteboard Session Listener. I 
>>have 2 servlets that use their own ServletContextHelpers and 
>>ServletFilters which are registered for both the aforementioned 
>>Servlet Contexts. The filters and servlets are working as expected but 
>>the custom HttpSessionListener callbacks are never getting triggered 
>>when HttpRequest#getSession() is invoked in one of the servlets.
>> >
>> >As an example,
>> >
>> >@Component
>> >@HttpWhiteboardListener
>> >public final class ApplicationSession implements HttpSessionListener 
>>{
>> >
>> > private final AtomicInteger activeSessions = new AtomicInteger();
>> >
>> > @Override
>> > public void sessionCreated(final HttpSessionEvent sessionEvent) {
>> > activeSessions.incrementAndGet();
>> > }
>> >
>> > @Override
>> > public void sessionDestroyed(final HttpSessionEvent sessionEvent) {
>> > activeSessions.decrementAndGet();
>> > }
>> >
>> > public boolean isSessionValid() {
>> > return activeSessions.get() != 0;
>> > }
>> >
>> >}
>> >
>> >This is the custom listener I registered with the HTTP Whiteboard and 
>>it never gets invoked when I call HttpRequest#getSession().
>> >
>> >Is there anything I am missing? I would really appreciate further 
>>help on this regard. For your information, I am currently using the 
>>latest version of Felix Jetty Bundle (4.0.6).
>> >
>> >Thanks and Regards,
>> >
>> >Amit Kumar Mondal
>> >Phone: +49 160 9100 3436 Email: amit@amitinside.com
>> >Skype: arsenalnerk GitHub: amitjoy
>> >Blog: blog.amitinside.com

Re: Re[2]: HTTP Whiteboard HttpSessionListener Problem

Posted by Amit <ad...@amitinside.com>.
Hi Thomas,

Thanks for your support. I just created a bug with a small GitHub repo replicating the issue. https://issues.apache.org/jira/browse/FELIX-6080

Best Regards,

Amit Kumar Mondal
Phone: +49 160 9100 3436  Email: amit@amitinside.com
Skype: arsenalnerk   GitHub: amitjoy
Blog: blog.amitinside.com

Am 8. März 2019 um 14:11:54, Thomas Driessen (thomas.driessen.td@gmail.com) schrieb:

Hi Amit,  

sorry but I don't think I can help you with that :( Your first error  
just sounded very similar to what I experienced. If You think it is a  
bug then you should file one in Felix's bug tracking system:  
https://issues.apache.org/jira/projects/FELIX/issues/  

Maybe add a minimal example that showcases what you are trying to do.  

Kind regards,  
Thomas  

------ Originalnachricht ------  
Von: "Amit" <ad...@amitinside.com>  
An: "Thomas Driessen" <th...@gmail.com>;  
users@felix.apache.org  
Gesendet: 08.03.2019 14:07:58  
Betreff: Re: HTTP Whiteboard HttpSessionListener Problem  

>Hi Thomas,  
>  
>Thanks for the quick response. The HttpSessionListener component was in  
>SATISFIED state since no other client consumed it (lazy component). I  
>had set the component property type to string and the  
>HttpSessionListener became ACTIVE. Unfortunately the  
>HttpSessionListener is still not getting triggered when session gets  
>created. I also switched to the latest version of Felix Jetty Bundle  
>(4.0.8) and it is still the same.  
>  
>Do you have any further idea?  
>  
>Thanks and Regards,  
>  
>Amit Kumar Mondal  
>Phone: +49 160 9100 3436 Email: amit@amitinside.com  
><ma...@amitinside.com>  
>Skype: arsenalnerk GitHub: a <http://blog.amitinside.com/>mitjoy  
>Blog: blog.amitinside.com <http://www.amitinside.com/>  
>  
>Am 8. März 2019 um 13:52:46, Thomas Driessen  
>(thomas.driessen.td@gmail.com) schrieb:  
>  
>>Hi Amit,  
>>  
>>maybe this is a similar issue as the one I had with  
>>ServletContextListeners? See here:  
>>https://issues.apache.org/jira/browse/FELIX-6049  
>>  
>>In order to rule that out maybe you could try to register your  
>>HttpSessionListener not via the ComponentPropertyType annotation but  
>>with a plain property like this:  
>>  
>>@Component(property= {HttpWhiteboardConstants.HTTP_WHITEBOARD_LISTENER  
>>+  
>>"=true"})  
>>  
>>  
>>Be aware that the property value has to be of type String and not of  
>>type boolean!  
>>If this solves your problem then you should update your dependencies  
>>as  
>>in the new versions of Felix Jetty this bug should be fixed.  
>>  
>>Kind regards,  
>>Thomas  
>>------ Originalnachricht ------  
>>Von: "Amit" <ad...@amitinside.com>  
>>An: users@felix.apache.org  
>>Gesendet: 08.03.2019 13:20:49  
>>Betreff: HTTP Whiteboard HttpSessionListener Problem  
>>  
>> >Hi,  
>> >  
>> >I am currently struggling with HTTP Whiteboard Session Listener. I  
>>have 2 servlets that use their own ServletContextHelpers and  
>>ServletFilters which are registered for both the aforementioned  
>>Servlet Contexts. The filters and servlets are working as expected but  
>>the custom HttpSessionListener callbacks are never getting triggered  
>>when HttpRequest#getSession() is invoked in one of the servlets.  
>> >  
>> >As an example,  
>> >  
>> >@Component  
>> >@HttpWhiteboardListener  
>> >public final class ApplicationSession implements HttpSessionListener  
>>{  
>> >  
>> > private final AtomicInteger activeSessions = new AtomicInteger();  
>> >  
>> > @Override  
>> > public void sessionCreated(final HttpSessionEvent sessionEvent) {  
>> > activeSessions.incrementAndGet();  
>> > }  
>> >  
>> > @Override  
>> > public void sessionDestroyed(final HttpSessionEvent sessionEvent) {  
>> > activeSessions.decrementAndGet();  
>> > }  
>> >  
>> > public boolean isSessionValid() {  
>> > return activeSessions.get() != 0;  
>> > }  
>> >  
>> >}  
>> >  
>> >This is the custom listener I registered with the HTTP Whiteboard and  
>>it never gets invoked when I call HttpRequest#getSession().  
>> >  
>> >Is there anything I am missing? I would really appreciate further  
>>help on this regard. For your information, I am currently using the  
>>latest version of Felix Jetty Bundle (4.0.6).  
>> >  
>> >Thanks and Regards,  
>> >  
>> >Amit Kumar Mondal  
>> >Phone: +49 160 9100 3436 Email: amit@amitinside.com  
>> >Skype: arsenalnerk GitHub: amitjoy  
>> >Blog: blog.amitinside.com

Re: HTTP Whiteboard HttpSessionListener Problem

Posted by Amit <ad...@amitinside.com>.
Hi Thomas,

Thanks for the quick response. The HttpSessionListener component was in SATISFIED state since no other client consumed it (lazy component). I had set the component property type to string and the HttpSessionListener became ACTIVE. Unfortunately the HttpSessionListener is still not getting triggered when session gets created. I also switched to the latest version of Felix Jetty Bundle (4.0.8) and it is still the same.

Do you have any further idea?

Thanks and Regards,

Amit Kumar Mondal
Phone: +49 160 9100 3436  Email: amit@amitinside.com
Skype: arsenalnerk   GitHub: amitjoy
Blog: blog.amitinside.com

Am 8. März 2019 um 13:52:46, Thomas Driessen (thomas.driessen.td@gmail.com) schrieb:

Hi Amit,  

maybe this is a similar issue as the one I had with  
ServletContextListeners? See here:  
https://issues.apache.org/jira/browse/FELIX-6049  

In order to rule that out maybe you could try to register your  
HttpSessionListener not via the ComponentPropertyType annotation but  
with a plain property like this:  

@Component(property= {HttpWhiteboardConstants.HTTP_WHITEBOARD_LISTENER +  
"=true"})  


Be aware that the property value has to be of type String and not of  
type boolean!  
If this solves your problem then you should update your dependencies as  
in the new versions of Felix Jetty this bug should be fixed.  

Kind regards,  
Thomas  
------ Originalnachricht ------  
Von: "Amit" <ad...@amitinside.com>  
An: users@felix.apache.org  
Gesendet: 08.03.2019 13:20:49  
Betreff: HTTP Whiteboard HttpSessionListener Problem  

>Hi,  
>  
>I am currently struggling with HTTP Whiteboard Session Listener. I have 2 servlets that use their own ServletContextHelpers and ServletFilters which are registered for both the aforementioned Servlet Contexts. The filters and servlets are working as expected but the custom HttpSessionListener callbacks are never getting triggered when HttpRequest#getSession() is invoked in one of the servlets.  
>  
>As an example,  
>  
>@Component  
>@HttpWhiteboardListener  
>public final class ApplicationSession implements HttpSessionListener {  
>  
> private final AtomicInteger activeSessions = new AtomicInteger();  
>  
> @Override  
> public void sessionCreated(final HttpSessionEvent sessionEvent) {  
> activeSessions.incrementAndGet();  
> }  
>  
> @Override  
> public void sessionDestroyed(final HttpSessionEvent sessionEvent) {  
> activeSessions.decrementAndGet();  
> }  
>  
> public boolean isSessionValid() {  
> return activeSessions.get() != 0;  
> }  
>  
>}  
>  
>This is the custom listener I registered with the HTTP Whiteboard and it never gets invoked when I call HttpRequest#getSession().  
>  
>Is there anything I am missing? I would really appreciate further help on this regard. For your information, I am currently using the latest version of Felix Jetty Bundle (4.0.6).  
>  
>Thanks and Regards,  
>  
>Amit Kumar Mondal  
>Phone: +49 160 9100 3436 Email: amit@amitinside.com  
>Skype: arsenalnerk GitHub: amitjoy  
>Blog: blog.amitinside.com

Re: HTTP Whiteboard HttpSessionListener Problem

Posted by Thomas Driessen <th...@gmail.com>.
Hi Amit,

maybe this is a similar issue as the one I had with 
ServletContextListeners? See here: 
https://issues.apache.org/jira/browse/FELIX-6049

In order to rule that out maybe you could try to register your 
HttpSessionListener not via the ComponentPropertyType annotation but 
with a plain property like this:

@Component(property= {HttpWhiteboardConstants.HTTP_WHITEBOARD_LISTENER + 
"=true"})


Be aware that the property value has to be of type String and not of 
type boolean!
If this solves your problem then you should update your dependencies as 
in the new versions of Felix Jetty this bug should be fixed.

Kind regards,
Thomas
------ Originalnachricht ------
Von: "Amit" <ad...@amitinside.com>
An: users@felix.apache.org
Gesendet: 08.03.2019 13:20:49
Betreff: HTTP Whiteboard HttpSessionListener Problem

>Hi,
>
>I am currently struggling with HTTP Whiteboard Session Listener. I have 2 servlets that use their own ServletContextHelpers and ServletFilters which are registered for both the aforementioned Servlet Contexts. The filters and servlets are working as expected but the custom HttpSessionListener callbacks are never getting triggered when HttpRequest#getSession() is invoked in one of the servlets.
>
>As an example,
>
>@Component
>@HttpWhiteboardListener
>public final class ApplicationSession implements HttpSessionListener {
>
>     private final AtomicInteger activeSessions = new AtomicInteger();
>
>     @Override
>     public void sessionCreated(final HttpSessionEvent sessionEvent) {
>         activeSessions.incrementAndGet();
>     }
>
>     @Override
>     public void sessionDestroyed(final HttpSessionEvent sessionEvent) {
>         activeSessions.decrementAndGet();
>     }
>
>     public boolean isSessionValid() {
>         return activeSessions.get() != 0;
>     }
>
>}
>
>This is the custom listener I registered with the HTTP Whiteboard and it never gets invoked when I call HttpRequest#getSession().
>
>Is there anything I am missing? I would really appreciate further help on this regard. For your information, I am currently using the latest version of Felix Jetty Bundle (4.0.6).
>
>Thanks and Regards,
>
>Amit Kumar Mondal
>Phone: +49 160 9100 3436  Email: amit@amitinside.com
>Skype: arsenalnerk   GitHub: amitjoy
>Blog: blog.amitinside.com