I'm progressing...
Here is a test where the ServletContextListener (GuiceManager) declares
itself on a static member of LocalGuiceProviderFactory.
I've added a static {} block inside the LocalGuiceProviderFactory to see
when the class was loaded and by which ClassLoader.
The ClassLoader is good, but the class is loaded twice :
I'm loaded (LGPF)
WebappClassLoader
context: /portletswar
delegate: false
repositories:
/WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@c5a67c9
java.lang.Exception
at
test.lifecycle.LocalGuiceProviderFactory.<clinit>(LocalGuiceProviderFactory.java:19)
at test.lifecycle.GuiceManager.forceNew(GuiceManager.java:54)
at
test.lifecycle.GuiceManager.contextInitialized(GuiceManager.java:28)
at
org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4205)
I'm loaded (LGPF)
WebappClassLoader
context: /portletswar
delegate: false
repositories:
/WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@c5a67c9
java.lang.Exception
at
test.lifecycle.LocalGuiceProviderFactory.<clinit>(LocalGuiceProviderFactory:19)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at
java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:345)
at java.util.ServiceLoader$1.next(ServiceLoader.java:421)
at juzu.impl.common.Tools.list(Tools.java:575)
at juzu.impl.common.Tools.list(Tools.java:569)
at
juzu.impl.plugin.binding.BindingPlugin.init(BindingPlugin.java:47)
at
juzu.impl.plugin.application.Application.start(Application.java:119)
at
juzu.impl.runtime.ApplicationRuntime.start(ApplicationRuntime.java:154)
at
juzu.impl.runtime.ApplicationRuntime.refresh(ApplicationRuntime.java:129)
at
juzu.impl.bridge.module.ApplicationBridge.refresh(ApplicationBridge.java:106)
at juzu.impl.bridge.Bridge.refresh(Bridge.java:65)
at juzu.bridge.portlet.JuzuPortlet.render(JuzuPortlet.java:298)
at
org.gatein.pc.portlet.impl.jsr168.PortletContainerImpl$Invoker.doFilter(PortletContainerImpl.java:569)
Since nothing points on the LocalGuiceProviderFactory, the class can be
unloaded and garbage collected, so it doesn't seem that abnormal.
So back to the previous attempt : LocalGuiceProviderFactory fetches it's
context from GuiceManager (a ServletContextListener) which has a static
member.
I'm loaded (GM)
WebappClassLoader
context: /portletswar
delegate: false
repositories:
/WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@151ca803
java.lang.Exception
at test.lifecycle.GuiceManager.<clinit>(GuiceManager.java:22)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at
org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4149)
I'm loaded (LGPF)
WebappClassLoader
context: /portletswar
delegate: false
repositories:
/WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@151ca803
java.lang.Exception
at
test.lifecycle.LocalGuiceProviderFactory.<clinit>(LocalGuiceProviderFactory:19)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at
java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:345)
at java.util.ServiceLoader$1.next(ServiceLoader.java:421)
at juzu.impl.common.Tools.list(Tools.java:575)
at juzu.impl.common.Tools.list(Tools.java:569)
at
juzu.impl.plugin.binding.BindingPlugin.init(BindingPlugin.java:47)
at
juzu.impl.plugin.application.Application.start(Application.java:119)
at
juzu.impl.runtime.ApplicationRuntime.start(ApplicationRuntime.java:154)
at
juzu.impl.runtime.ApplicationRuntime.refresh(ApplicationRuntime.java:129)
at
juzu.impl.bridge.module.ApplicationBridge.refresh(ApplicationBridge.java:106)
at juzu.impl.bridge.Bridge.refresh(Bridge.java:65)
at juzu.bridge.portlet.JuzuPortlet.render(JuzuPortlet.java:298)
at
org.gatein.pc.portlet.impl.jsr168.PortletContainerImpl$Invoker.doFilter(PortletContainerImpl.java:569)
I'm loaded (GM)
WebappClassLoader
context: /portletswar
delegate: false
repositories:
/WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@151ca803
java.lang.Exception
at test.lifecycle.GuiceManager.<clinit>(GuiceManager:22)
at
test.lifecycle.LocalGuiceProviderFactory.getProvider(LocalGuiceProviderFactory:27)
at
juzu.impl.plugin.binding.BindingPlugin.init(BindingPlugin.java:79)
at
juzu.impl.plugin.application.Application.start(Application.java:119)
at
juzu.impl.runtime.ApplicationRuntime.start(ApplicationRuntime.java:154)
at
juzu.impl.runtime.ApplicationRuntime.refresh(ApplicationRuntime.java:129)
at
juzu.impl.bridge.module.ApplicationBridge.refresh(ApplicationBridge.java:106)
at juzu.impl.bridge.Bridge.refresh(Bridge.java:65)
at juzu.bridge.portlet.JuzuPortlet.render(JuzuPortlet.java:298)
at
org.gatein.pc.portlet.impl.jsr168.PortletContainerImpl$Invoker.doFilter(PortletContainerImpl.java:569)
So here it's the GuiceManager class, which is the
ServletContextListener, which is loaded twice by the same classloader,
and thus loses its static members.
And that I can not explain ^^;
To be sure, I've run with -verbose:class, and...
[Loaded test.lifecycle.GuiceManager from
file:/C:/shared/tools/GateIn-3.4.0.Final-tomcat6/webapps/portletswar/WEB-INF/classes/test/lifecycle/GuiceManager.class]
Before the first loading, and then before the second loading:
[Loaded test.GuiceManager from juzu:/]
And for now, I've no analysis to give.
Damien
Le 07/10/2013 11:39, Julien Viet a �crit :
> ok so this seems to be executed from your Provider implementation returned by the ProviderFactory (test.lifecycle.LocalGuiceProviderFactory$1)
>
> can you do the same in the ProviderFactory#getProvider method ?
>
> On Oct 7, 2013, at 11:25 AM, Damien B <
night...@gmail.com> wrote:
>
>> Re and thanks for the answers,
>> here is a partial stacktrace, the remaining is 190 lines of Catalina + GateIn 3.4:
>>
>> => System.out.println("Renvoie d'une impl�mentation pour " + implementationType);
>> Renvoie d'une impl�mentation pour interface test.portlet.portlet1.services.TestService
>> Le 07/10/2013 10:29, Julien Viet a �crit :