Hello,

Thank you for your time.

As for integration tests, I haven’t checked – which module is that? I’ll have a 
look.

I’ve got generally issues getting that thing to compile. Issuing ‘mvn install’ 
in project root did not work, because some modules are referenced, but not 
listed in root pom (pax-web-tomcat AFAIR). It should be easy to replicate via 
build against clean local maven repository with non-modified settings.xml 
(Gitlab CI build, for example). I don’t know if it’s by-design or not… I’ve got 
to run mvn install to install parent pom, and then do mvn install for 
individual modules to get things to work.

I’ll take a look on the samples, but as I see, those are separate modules. Are 
there any tests for many modules cooperating (for example, separate WebService 
servlet, separate authentication filter)?

As for your path, I’ve tried to apply it via ‘git apply PAXWEB-1105.diff’ both 
on master and my branch 
(https://github.com/llech/org.ops4j.pax.web/tree/PAXWEB-1105) but I’ve failed 
with following error message:

D:\Projects\libs\org.ops4j.pax.web>git apply ..\..\PAXWEB-1105_improved.diff
..\..\PAXWEB-1105_improved.diff:12: space before tab in indent.
        String PROPERTY_SESSION_COOKIE_SECURE = PID + ".session.cookie.secure";
..\..\PAXWEB-1105_improved.diff:13: space before tab in indent.
        String PROPERTY_SESSION_LAZY_LOAD = PID + ".session.lazyload";
..\..\PAXWEB-1105_improved.diff:14: space before tab in indent.
        String PROPERTY_SESSION_STORE_DIRECTORY = PID + 
".session.storedirectory";
..\..\PAXWEB-1105_improved.diff:16: trailing whitespace.

..\..\PAXWEB-1105_improved.diff:17: space before tab in indent.
        String PROPERTY_TEMP_DIR = "javax.servlet.context.tempdir";
error: patch failed: 
pax-web-api/src/main/java/org/ops4j/pax/web/service/WebContainerConstants.java:118
error: 
pax-web-api/src/main/java/org/ops4j/pax/web/service/WebContainerConstants.java: 
patch does not apply
error: patch failed: 
pax-web-runtime/src/main/java/org/ops4j/pax/web/service/internal/ConfigurationImpl.java:49
error: 
pax-web-runtime/src/main/java/org/ops4j/pax/web/service/internal/ConfigurationImpl.java:
 patch does not apply
error: patch failed: 
pax-web-runtime/src/main/java/org/ops4j/pax/web/service/internal/HttpServiceStarted.java:323
error: 
pax-web-runtime/src/main/java/org/ops4j/pax/web/service/internal/HttpServiceStarted.java:
 patch does not apply
error: patch failed: 
pax-web-spi/src/main/java/org/ops4j/pax/web/service/spi/Configuration.java:129
error: 
pax-web-spi/src/main/java/org/ops4j/pax/web/service/spi/Configuration.java: 
patch does not apply

Sorry, I’m not very advanced git user.

As for DefaultSharedWebContainerContext, I was debugging a bit and I’ve found a 
place where the HttpContext was used as a key in HashMap: 
org.ops4j.pax.web.service.jetty.internal.JettyServerWrapper (contexts). Because 
the class had no equals/hashCode, even If after my patch, 
createDefaultHttpContext has created SharedContext, for this map those were 
distinct keys, so different ServletContextInfo was returned.

However, adding equals/hashCode has not solved my issue. Apart for error 
because of HttpServiceStarted (line 1161, instanceof should be called for 
context, not httpContext?), it seems that BundleContext is used much deeper as 
a key.

My all attempts, anyway, are in my fork of repository on GitHub.

Best regards,
Lukasz Lech

From: 'Achim Nierbeck' via OPS4J [mailto:[email protected]]
Sent: Sonntag, 2. Juli 2017 15:12
To: [email protected]
Subject: Re: Pax-Web session listener

Hi Lukasz,

I checked your diff, with some changes everything regarding the versions is 
running fine now. :)
Take a look at the attached patch.
All integration tests are failing though, so it seems your changes aren't 
complete. Might that be the reason your own tests aren't working correctly?

regards, Achim


2017-06-30 22:57 GMT+02:00 Achim Nierbeck 
<[email protected]<mailto:[email protected]>>:
Hi Lukasz,

this is definitely the right list to ask for.
Right now I don't have much time or energy to look at your issue in a closer 
detail.
If in doubt about how a shared context is about to work, please take a look at 
the samples and / or the integration tests.
There are some available and I hope they make some of your questions clearer. 
If not I might have some more free cycles and a clearer mind about that next 
week ...

regards, Achim


2017-06-30 11:23 GMT+02:00 Lukasz Lech 
<[email protected]<mailto:[email protected]>>:
Hello,

I hope this group is appropriate for asking this question, if not, my apologize 
and please suggest if there is appropriate place to ask.

I’ve submitted the issue https://ops4j1.jira.com/browse/PAXWEB-1105 because I 
need to register session listener for WebServices created by JaxrsPublisher.

I’ve added parameter doing what is described in the issue, and after deploying 
and modifying configuration file, the shared http context instance is returned 
upon createDefaultHttpContext() call. (I’ve included the git diff of changes 
I’ve made locally).

2 bundles: jaxrs publisher and my session listener registrator are connected to 
http service:
2017-06-30T10:46:18,768 | INFO  | pool-3-thread-1  | HttpServiceFactoryImpl     
      | 199 - org.ops4j.pax.web.pax-web-runtime - 6.1.0.SNAPSHOT | Binding 
bundle: [com.eclipsesource.jaxrs.publisher [14]] to http service
2017-06-30T10:46:20,644 | INFO  | pool-3-thread-1  | HttpServiceFactoryImpl     
      | 199 - org.ops4j.pax.web.pax-web-runtime - 6.1.0.SNAPSHOT | Binding 
bundle: [pax-web-configurator [204]] to http service

Jaxrs publisher registers servlet:
2017-06-30T10:46:20,010 | INFO  | pool-3-thread-1  | HttpServiceStarted         
      | 199 - org.ops4j.pax.web.pax-web-runtime - 6.1.0.SNAPSHOT | Register 
servlet (alias=/services). Using context 
[ContextModel{id=org.ops4j.pax.web.service.spi.model.ContextModel-5,name=,httpContext=org.ops4j.pax.web.service.internal.DefaultSharedWebContainerContext@f7bb2fe,contextParams={},virtualHosts={},connectors={}}]

My stuff registers session listener and session attribute listener:
2017-06-30T10:46:20,645 | INFO  | pool-3-thread-1  | HttpServiceStarted         
      | 199 - org.ops4j.pax.web.pax-web-runtime - 6.1.0.SNAPSHOT | Register 
event listener 
(listener=com.riag.taxcloud.datamodel.channel.DatamodelSessionListener@18b607f1<mailto:listener=com.riag.taxcloud.datamodel.channel.DatamodelSessionListener@18b607f1>).
 Using context 
[ContextModel{id=org.ops4j.pax.web.service.spi.model.ContextModel-11,name=,httpContext=org.ops4j.pax.web.service.internal.DefaultSharedWebContainerContext@4f5b090a,contextParams={},virtualHosts={},connectors={}}]
2017-06-30T10:46:20,655 | INFO  | pool-3-thread-1  | HttpServiceStarted         
      | 199 - org.ops4j.pax.web.pax-web-runtime - 6.1.0.SNAPSHOT | Register 
event listener 
(listener=com.riag.taxcloud.datamodel.channel.DatamodelSessionAttributeListener@7e902b64<mailto:listener=com.riag.taxcloud.datamodel.channel.DatamodelSessionAttributeListener@7e902b64>).
 Using context 
[ContextModel{id=org.ops4j.pax.web.service.spi.model.ContextModel-13,name=,httpContext=org.ops4j.pax.web.service.internal.DefaultSharedWebContainerContext@56ba6785,contextParams={},virtualHosts={},connectors={}}]

This is how I register/unregister listeners:
       public void bindSessionListener(HttpSessionListener listener) {
             LOGGER.info("bindSessionListener {}", listener);
             webContainer.registerEventListener(listener, null);
             //servletContext.addListener(listener); IllegalStateException
       }

       public void unbindSessionListener(HttpSessionListener listener) {
             LOGGER.info("unbindSessionListener {}", listener);
             if (listener == null)
                    return;
             webContainer.unregisterEventListener(listener);
       }


       public void bindSessionAttributeListener(HttpSessionAttributeListener 
listener) {
             LOGGER.info("bindSessionAttributeListener {}", listener);
             webContainer.registerEventListener(listener, null);
             // servletContext.addListener(listener); IllegalStateException
       }

       public void unbindSessionAttributeListener(HttpSessionAttributeListener 
listener) {
             LOGGER.info("unbindSessionAttributeListener {}", listener);
             if (listener == null)
                    return;
             webContainer.unregisterEventListener(listener);
       }

<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0";
             
xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0";
             
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0";>

       <bean id="paxWebConfigurator" 
class="com.riag.taxcloud.paxweb.configurator.PaxWebSessionConfigurator">
                    <property name="context" ref="blueprintBundleContext" />
                    <property name="webContainer" ref="webContainer"/>
                    <property name="servletConfiguration" 
ref="jaxRsServletConfiguration"/>
                    <property name="servletContext" ref="jaxbServletContext"/>
       </bean>

       <reference id="webContainer" 
interface="org.ops4j.pax.web.service.WebContainer"/>

       <reference-list id="sessionListeners" 
interface="javax.servlet.http.HttpSessionListener" availability="optional">
             <reference-listener bind-method="bindSessionListener" 
unbind-method="unbindSessionListener" ref="paxWebConfigurator" />
       </reference-list>

       <reference-list id="sessionAttributeListeners" 
interface="javax.servlet.http.HttpSessionAttributeListener" 
availability="optional">
             <reference-listener bind-method="bindSessionAttributeListener" 
unbind-method="unbindSessionAttributeListener" ref="paxWebConfigurator" />
       </reference-list>

</blueprint>

However, the session listener is not called when new session is created by 
WebService call. I’ve set a breakpoint within 
org.eclipse.jetty.server.session.AbstractSessionManager.addSession(AbstractSession,
 boolean) and _sessionListeners list is empty.

Do I get something conceptually wrong? I thought that if both bundles will 
register stuff using the same HttpContext, one of them could register listener 
that would listen to events for servlets created by the second one.
Is the concept of bundles working with different HttpContext somehow deeply 
build-in in pax-web so I can’t change that behavior with such simple ‘hack’?

Anyway, my patch (after cleanup – I’ve increased log level to see what happens 
and commented out the baselining so that I’m able to compile with maven) seems 
to solve the JIRA issue. However I’m not sure if the JIRA issue solves any 
issue, or I lack understanding the concept of ‘shared’ and ‘non-shared’ 
HttpContext in pax-web….

Best regards,
Lukasz Lech

--
--
------------------
OPS4J - http://www.ops4j.org - 
[email protected]<mailto:[email protected]>

---
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
[email protected]<mailto:[email protected]>.
For more options, visit https://groups.google.com/d/optout.



--

Apache Member
Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer & 
Project Lead
blog <http://notizblog.nierbeck.de/>
Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>

Software Architect / Project Manager / Scrum Master




--

Apache Member
Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer & 
Project Lead
blog <http://notizblog.nierbeck.de/>
Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>

Software Architect / Project Manager / Scrum Master

--
--
------------------
OPS4J - http://www.ops4j.org - 
[email protected]<mailto:[email protected]>

---
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
[email protected]<mailto:[email protected]>.
For more options, visit https://groups.google.com/d/optout.

-- 
-- 
------------------
OPS4J - http://www.ops4j.org - [email protected]

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to