[jira] Created: (OWB-351) OWB picks up @SessionScoped contextual instances from expired sessions
OWB picks up @SessionScoped contextual instances from expired sessions -- Key: OWB-351 URL: https://issues.apache.org/jira/browse/OWB-351 Project: OpenWebBeans Issue Type: Bug Components: Context and Scopes Affects Versions: M4 Reporter: Mark Struberg Assignee: Mark Struberg Priority: Critical Fix For: 1.0.0 We currently store the CreationalContext instance from creating time inside the NormalScopedBeanInterceptorHandler. This leads to the fact that we pickup the contextual instance stored in that very CreationalContext even if the context itself is long time gone (e.g. if the session expired. This also leads to the side effect that we currently pickup contextual instances from the wrong session if the proxy gets injected into a wider scoped instance (e.g. an @ApplicationScoped bean). Thus, we must drop the CreationalContext from all our NormalScoped proxies and create a new CreationalContext each time we create a new contextual instance. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
ContextsService for standalone applications
Hi! I am developing a standalone Swing Application and trying to make use of CDI (using openwebbeans). Also for being more fit when discussing Orchestra related things :-) Naturally a Swing Application consists of multiple threads. At least the main thread and the so called Event Dispatcher Thread (EDT) for UI handling. Beside this you will find a lot of other short-time threads handling actions triggered by the user through the UI. The problem I have is the org.apache.webbeans.spi.se.DefaultContextsService class which uses ThreadLocals to store all the contexts. I think this is not right, at least not for all the contexts provided. For example the ApplicationContext, SessionContext, SingletonContext and DependentContext should be a simple member of the class. Not sure about (CDI like) ConversationContext. The RequestContext might be arguable to life with the Thread - however, the developer need to take care to destroy the RequestContext manually somehow - or something we can implment into the Swing Application Framework. For now I solved that by providing my own ContextsService impl through openwebbeans.properties. Also, like in Weld, I'd love to see some utility class to startup CDI in an standalone app. Once you figured out it is easy already, but it can be even more easy, and we can provide some predefined events like ContainerInitialized [1]. Said that (and given my observations are correct), what do you think about starting up a webbeans-se module where we put these things together? It won't grow to a huge project, though. Ciao, Mario [1] http://www.jarvana.com/jarvana/view/org/jboss/weld/weld-se/1.0.0-CR2/weld-se-1.0.0-CR2-javadoc.jar!/org/jboss/weld/environment/se/events/ContainerInitialized.html smime.p7s Description: S/MIME cryptographic signature
AW: svn commit: r933198 - in /openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/session: common/AppScopedBean.java common/PersonalDataBean.java tests/SessionContextT
Hi! I now added a really simple test which shows the problems with OWB-351. Please be aware that this will currently break the build! But since this is a blocker, we should get rid of those problems really soon. Thus, the more pain the more quickly we will fix it ;) If you like to build OWB, you have to comment out the @Test from SessionContextTest#testInstanceCreation() LieGrue, strub --- strub...@apache.org strub...@apache.org schrieb am Mo, 12.4.2010: Von: strub...@apache.org strub...@apache.org Betreff: svn commit: r933198 - in /openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/session: common/AppScopedBean.java common/PersonalDataBean.java tests/SessionContextTest.java An: comm...@openwebbeans.apache.org Datum: Montag, 12. April, 2010 13:44 Uhr Author: struberg Date: Mon Apr 12 11:44:22 2010 New Revision: 933198 URL: http://svn.apache.org/viewvc?rev=933198view=rev Log: OWB-351 this simple test shows the problems with our CreationalContexts The test takes an @ApplicationScoped bean which got a proxy for a @SessionScoped bean injected, and verifies that we get different @SessionScoped contextual instances for different sessions. Attention: this currently breaks the build, but this is a real blocker! Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/session/common/AppScopedBean.java Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/session/common/PersonalDataBean.java openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/session/tests/SessionContextTest.java Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/session/common/AppScopedBean.java URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/session/common/AppScopedBean.java?rev=933198view=auto == --- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/session/common/AppScopedBean.java (added) +++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/session/common/AppScopedBean.java Mon Apr 12 11:44:22 2010 @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * License); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.webbeans.newtests.contexts.session.common; + +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Inject; + +...@applicationscoped +public class AppScopedBean { + + private @Inject PersonalDataBean pdb; + + public PersonalDataBean getPdb() { + return pdb; + } +} Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/session/common/PersonalDataBean.java URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/session/common/PersonalDataBean.java?rev=933198r1=933197r2=933198view=diff == --- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/session/common/PersonalDataBean.java (original) +++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/session/common/PersonalDataBean.java Mon Apr 12 11:44:22 2010 @@ -1,15 +1,20 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with this - * work for additional information regarding copyright ownership. The ASF - * licenses this file to You under the Apache License, Version 2.0 (the - * License); you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law - * or agreed to in writing, software distributed under the License is - * distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or
EE-Integration Question: How does one do CDI injection on Java EE component classes ?
Team, OpenWebBeans provides the ResourceInjectionService API for injection of Java EE injectable resources into CDI managed beans. This works well and we have integrated the ResourceInjectionService API in our EE container. We need guidance on how OWB handles CDI managed bean injection into EE components. Are we to follow the WELD approach of achieving this through the CDI defined InjectionTarget SPI. Should an EE container extend/compose the BeanManager and expose a fireProcessInjectionTarget(Class) utility method ? How does this integrate with the OpenWebBeansEjbPlugin. ? I am looking for a high level overview of how this will work in OWB and the code that currently supports this feature and what is yet to be written ? --Thanks, Rohit Kelapure
Re: EE-Integration Question: How does one do CDI injection on Java EE component classes ?
Hello Rohit; Could you look at the OWBInjector utility class? This is responsible for injecting into EE components instances. When EE container destroys EE component, you will also destroy creational contexts via OWBInjector. OWBInjector injector = new OWBInjector(); injector.inject(instance, creational); injector.release(); //on ee component destroying For EJB case, I have updated OpenWebBeansEJBInterceptor. Please look at it. Basically, you will add it to every EJB Beans that is contained in JSR299 module. Thanks; --Gurkan 2010/4/12 Rohit Kelapure kelap...@gmail.com Team, OpenWebBeans provides the ResourceInjectionService API for injection of Java EE injectable resources into CDI managed beans. This works well and we have integrated the ResourceInjectionService API in our EE container. We need guidance on how OWB handles CDI managed bean injection into EE components. Are we to follow the WELD approach of achieving this through the CDI defined InjectionTarget SPI. Should an EE container extend/compose the BeanManager and expose a fireProcessInjectionTarget(Class) utility method ? How does this integrate with the OpenWebBeansEjbPlugin. ? I am looking for a high level overview of how this will work in OWB and the code that currently supports this feature and what is yet to be written ? --Thanks, Rohit Kelapure -- Gurkan Erdogdu http://gurkanerdogdu.blogspot.com
Re: ContextsService for standalone applications
Hello; That is great news, creating a maven module with webbeans-se. In the mean time, could you look at org.apache.webbeans.boot.Bootstrap class. Also there is a Java Swing sample, maybe you could want to look at it, it is located in the samples/standalone-sample. Thanks; --Gurkan 2010/4/12 Mario Ivankovits ma...@ops.co.at Hi! I am developing a standalone Swing Application and trying to make use of CDI (using openwebbeans). Also for being more fit when discussing Orchestra related things :-) Naturally a Swing Application consists of multiple threads. At least the main thread and the so called Event Dispatcher Thread (EDT) for UI handling. Beside this you will find a lot of other short-time threads handling actions triggered by the user through the UI. The problem I have is the org.apache.webbeans.spi.se.DefaultContextsService class which uses ThreadLocals to store all the contexts. I think this is not right, at least not for all the contexts provided. For example the ApplicationContext, SessionContext, SingletonContext and DependentContext should be a simple member of the class. Not sure about (CDI like) ConversationContext. The RequestContext might be arguable to life with the Thread - however, the developer need to take care to destroy the RequestContext manually somehow - or something we can implment into the Swing Application Framework. For now I solved that by providing my own ContextsService impl through openwebbeans.properties. Also, like in Weld, I'd love to see some utility class to startup CDI in an standalone app. Once you figured out it is easy already, but it can be even more easy, and we can provide some predefined events like ContainerInitialized [1]. Said that (and given my observations are correct), what do you think about starting up a webbeans-se module where we put these things together? It won't grow to a huge project, though. Ciao, Mario [1] http://www.jarvana.com/jarvana/view/org/jboss/weld/weld-se/1.0.0-CR2/weld-se-1.0.0-CR2-javadoc.jar!/org/jboss/weld/environment/se/events/ContainerInitialized.htmlhttp://www.jarvana.com/jarvana/view/org/jboss/weld/weld-se/1.0.0-CR2/weld-se-1.0.0-CR2-javadoc.jar%21/org/jboss/weld/environment/se/events/ContainerInitialized.html -- Gurkan Erdogdu http://gurkanerdogdu.blogspot.com
[jira] Commented: (OWB-351) OWB picks up @SessionScoped contextual instances from expired sessions
[ https://issues.apache.org/jira/browse/OWB-351?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=12855985#action_12855985 ] Gurkan Erdogdu commented on OWB-351: In session destruction, we destroy context and creational context. How could you get a wrong creational context? Could you look at WebBeansConfigurationListener#sessionDestroyed. If proxy is in ApplicationScopedBean, then instance is recreated on invoking this bean because old context is already destroyed. COuld you attach a code to this issue? OWB picks up @SessionScoped contextual instances from expired sessions -- Key: OWB-351 URL: https://issues.apache.org/jira/browse/OWB-351 Project: OpenWebBeans Issue Type: Bug Components: Context and Scopes Affects Versions: M4 Reporter: Mark Struberg Assignee: Mark Struberg Priority: Blocker Fix For: 1.0.0 We currently store the CreationalContext instance from creating time inside the NormalScopedBeanInterceptorHandler. This leads to the fact that we pickup the contextual instance stored in that very CreationalContext even if the context itself is long time gone (e.g. if the session expired. This also leads to the side effect that we currently pickup contextual instances from the wrong session if the proxy gets injected into a wider scoped instance (e.g. an @ApplicationScoped bean). Thus, we must drop the CreationalContext from all our NormalScoped proxies and create a new CreationalContext each time we create a new contextual instance. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Commented: (OWB-351) OWB picks up @SessionScoped contextual instances from expired sessions
[ https://issues.apache.org/jira/browse/OWB-351?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=12855987#action_12855987 ] Mark Struberg commented on OWB-351: --- In fact the Context is really destroyed, but our proxy still holds the original CreationalContext. And there the 'old' contextual instance is stored. I've commited the unit test which shows the problem. OWB picks up @SessionScoped contextual instances from expired sessions -- Key: OWB-351 URL: https://issues.apache.org/jira/browse/OWB-351 Project: OpenWebBeans Issue Type: Bug Components: Context and Scopes Affects Versions: M4 Reporter: Mark Struberg Assignee: Mark Struberg Priority: Blocker Fix For: 1.0.0 We currently store the CreationalContext instance from creating time inside the NormalScopedBeanInterceptorHandler. This leads to the fact that we pickup the contextual instance stored in that very CreationalContext even if the context itself is long time gone (e.g. if the session expired. This also leads to the side effect that we currently pickup contextual instances from the wrong session if the proxy gets injected into a wider scoped instance (e.g. an @ApplicationScoped bean). Thus, we must drop the CreationalContext from all our NormalScoped proxies and create a new CreationalContext each time we create a new contextual instance. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Commented: (OWB-351) OWB picks up @SessionScoped contextual instances from expired sessions
[ https://issues.apache.org/jira/browse/OWB-351?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=12855994#action_12855994 ] Gurkan Erdogdu commented on OWB-351: This is problem because of not clearing CreationalContextImpl enough. I will update it OWB picks up @SessionScoped contextual instances from expired sessions -- Key: OWB-351 URL: https://issues.apache.org/jira/browse/OWB-351 Project: OpenWebBeans Issue Type: Bug Components: Context and Scopes Affects Versions: M4 Reporter: Mark Struberg Assignee: Mark Struberg Priority: Blocker Fix For: 1.0.0 We currently store the CreationalContext instance from creating time inside the NormalScopedBeanInterceptorHandler. This leads to the fact that we pickup the contextual instance stored in that very CreationalContext even if the context itself is long time gone (e.g. if the session expired. This also leads to the side effect that we currently pickup contextual instances from the wrong session if the proxy gets injected into a wider scoped instance (e.g. an @ApplicationScoped bean). Thus, we must drop the CreationalContext from all our NormalScoped proxies and create a new CreationalContext each time we create a new contextual instance. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Commented: (OWB-351) OWB picks up @SessionScoped contextual instances from expired sessions
[ https://issues.apache.org/jira/browse/OWB-351?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=12856000#action_12856000 ] Gurkan Erdogdu commented on OWB-351: I have update, now test is working OWB picks up @SessionScoped contextual instances from expired sessions -- Key: OWB-351 URL: https://issues.apache.org/jira/browse/OWB-351 Project: OpenWebBeans Issue Type: Bug Components: Context and Scopes Affects Versions: M4 Reporter: Mark Struberg Assignee: Mark Struberg Priority: Blocker Fix For: 1.0.0 We currently store the CreationalContext instance from creating time inside the NormalScopedBeanInterceptorHandler. This leads to the fact that we pickup the contextual instance stored in that very CreationalContext even if the context itself is long time gone (e.g. if the session expired. This also leads to the side effect that we currently pickup contextual instances from the wrong session if the proxy gets injected into a wider scoped instance (e.g. an @ApplicationScoped bean). Thus, we must drop the CreationalContext from all our NormalScoped proxies and create a new CreationalContext each time we create a new contextual instance. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Resolved: (OWB-351) OWB picks up @SessionScoped contextual instances from expired sessions
[ https://issues.apache.org/jira/browse/OWB-351?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Mark Struberg resolved OWB-351. --- Resolution: Fixed OWB picks up @SessionScoped contextual instances from expired sessions -- Key: OWB-351 URL: https://issues.apache.org/jira/browse/OWB-351 Project: OpenWebBeans Issue Type: Bug Components: Context and Scopes Affects Versions: M4 Reporter: Mark Struberg Assignee: Mark Struberg Priority: Blocker Fix For: 1.0.0 We currently store the CreationalContext instance from creating time inside the NormalScopedBeanInterceptorHandler. This leads to the fact that we pickup the contextual instance stored in that very CreationalContext even if the context itself is long time gone (e.g. if the session expired. This also leads to the side effect that we currently pickup contextual instances from the wrong session if the proxy gets injected into a wider scoped instance (e.g. an @ApplicationScoped bean). Thus, we must drop the CreationalContext from all our NormalScoped proxies and create a new CreationalContext each time we create a new contextual instance. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Commented: (OWB-351) OWB picks up @SessionScoped contextual instances from expired sessions
[ https://issues.apache.org/jira/browse/OWB-351?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=12856075#action_12856075 ] Mark Struberg commented on OWB-351: --- There is currently a discussion ongoing if cyclic references in @PostConstruct methods are allowed for JSR-299 (they are forbidden in JSR-250 afaik): https://jira.jboss.org/jira/browse/CDITCK-140 OWB picks up @SessionScoped contextual instances from expired sessions -- Key: OWB-351 URL: https://issues.apache.org/jira/browse/OWB-351 Project: OpenWebBeans Issue Type: Bug Components: Context and Scopes Affects Versions: M4 Reporter: Mark Struberg Assignee: Mark Struberg Priority: Blocker Fix For: 1.0.0 We currently store the CreationalContext instance from creating time inside the NormalScopedBeanInterceptorHandler. This leads to the fact that we pickup the contextual instance stored in that very CreationalContext even if the context itself is long time gone (e.g. if the session expired. This also leads to the side effect that we currently pickup contextual instances from the wrong session if the proxy gets injected into a wider scoped instance (e.g. an @ApplicationScoped bean). Thus, we must drop the CreationalContext from all our NormalScoped proxies and create a new CreationalContext each time we create a new contextual instance. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Commented: (OWB-351) OWB picks up @SessionScoped contextual instances from expired sessions
[ https://issues.apache.org/jira/browse/OWB-351?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=12856083#action_12856083 ] Gurkan Erdogdu commented on OWB-351: Commits on interceptor handlers eat the client provided CreationalContext in the BeanManager#getReference(...CreationalContext) OWB picks up @SessionScoped contextual instances from expired sessions -- Key: OWB-351 URL: https://issues.apache.org/jira/browse/OWB-351 Project: OpenWebBeans Issue Type: Bug Components: Context and Scopes Affects Versions: M4 Reporter: Mark Struberg Assignee: Mark Struberg Priority: Blocker Fix For: 1.0.0 We currently store the CreationalContext instance from creating time inside the NormalScopedBeanInterceptorHandler. This leads to the fact that we pickup the contextual instance stored in that very CreationalContext even if the context itself is long time gone (e.g. if the session expired. This also leads to the side effect that we currently pickup contextual instances from the wrong session if the proxy gets injected into a wider scoped instance (e.g. an @ApplicationScoped bean). Thus, we must drop the CreationalContext from all our NormalScoped proxies and create a new CreationalContext each time we create a new contextual instance. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Commented: (OWB-351) OWB picks up @SessionScoped contextual instances from expired sessions
[ https://issues.apache.org/jira/browse/OWB-351?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=12856094#action_12856094 ] Mark Struberg commented on OWB-351: --- this got removed intentionally because it is usually not necessary and had problematic side effects like picking up the wrong contextual instance if used in multithreaded scenarios. If cyclic @PostConstruct and @Inject methods must not occur (as defined in JSR-250), we can either drop it completely. If not we must only use this very CreationalContext until we leave ContextualT#create() and must not use it later if the application uses the proxy! OWB picks up @SessionScoped contextual instances from expired sessions -- Key: OWB-351 URL: https://issues.apache.org/jira/browse/OWB-351 Project: OpenWebBeans Issue Type: Bug Components: Context and Scopes Affects Versions: M4 Reporter: Mark Struberg Assignee: Mark Struberg Priority: Blocker Fix For: 1.0.0 We currently store the CreationalContext instance from creating time inside the NormalScopedBeanInterceptorHandler. This leads to the fact that we pickup the contextual instance stored in that very CreationalContext even if the context itself is long time gone (e.g. if the session expired. This also leads to the side effect that we currently pickup contextual instances from the wrong session if the proxy gets injected into a wider scoped instance (e.g. an @ApplicationScoped bean). Thus, we must drop the CreationalContext from all our NormalScoped proxies and create a new CreationalContext each time we create a new contextual instance. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
AW: svn commit: r933348 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept: ApplicationScopedBeanIntereptorHandler.java DependentScopedBeanInterceptorHandler.java Inter
Sorry, I think we need to rollback the rollback, since this re-introduces really heavy concurrency problems. @SessionScoped public class User [ public String getEmail().. } @ApplicationScoped class MailService { private @Inject User usr; public void sendMail(String content) { sendInternal(user.getEmail(), content); } } now, with this change whenever 2 threads (from 2 sessions of a webserver) invoke sendMail and hit the user.getEmail() the NormalScopedBeanInterceptorHandler gets called and those 2 threads override each other the private transient WeakReferenceCreationalContext? creationalContext = null; because there is only one single proxy instance being used by those 2 threads. Got me? LieGrue, strub --- gerdo...@apache.org gerdo...@apache.org schrieb am Mo, 12.4.2010: Von: gerdo...@apache.org gerdo...@apache.org Betreff: svn commit: r933348 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept: ApplicationScopedBeanIntereptorHandler.java DependentScopedBeanInterceptorHandler.java InterceptorHandler.java NormalScopedBeanInterceptorHandler.java An: comm...@openwebbeans.apache.org Datum: Montag, 12. April, 2010 20:20 Uhr Author: gerdogdu Date: Mon Apr 12 18:20:06 2010 New Revision: 933348 URL: http://svn.apache.org/viewvc?rev=933348view=rev Log: [OWB-351] OWB picks up @SessionScoped contextual instances from expired sessions. Corrects eating client provided creational context via BeanManager#getReference Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/ApplicationScopedBeanIntereptorHandler.java openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/DependentScopedBeanInterceptorHandler.java openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/NormalScopedBeanInterceptorHandler.java Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/ApplicationScopedBeanIntereptorHandler.java URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/ApplicationScopedBeanIntereptorHandler.java?rev=933348r1=933347r2=933348view=diff == --- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/ApplicationScopedBeanIntereptorHandler.java (original) +++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/ApplicationScopedBeanIntereptorHandler.java Mon Apr 12 18:20:06 2010 @@ -21,7 +21,6 @@ package org.apache.webbeans.intercept; import javax.enterprise.context.spi.CreationalContext; import org.apache.webbeans.component.OwbBean; -import org.apache.webbeans.context.creational.CreationalContextImpl; /** @@ -43,7 +42,7 @@ public class ApplicationScopedBeanIntere /** * Creates a new handler. * @param bean bean - * @param creationalContext creational context + * @param creationalContext creaitonal context */ public ApplicationScopedBeanIntereptorHandler(OwbBean? bean, CreationalContext? creationalContext) { @@ -53,11 +52,11 @@ public class ApplicationScopedBeanIntere /** * {...@inheritdoc} */ - protected Object getContextualInstance(OwbBeanObject bean, CreationalContextImpl? creationalContext) + protected Object getContextualInstance(OwbBeanObject bean) { if (cachedInstance == null) { - cachedInstance = super.getContextualInstance(bean, creationalContext); + cachedInstance = super.getContextualInstance(bean); } return cachedInstance; Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/DependentScopedBeanInterceptorHandler.java URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/DependentScopedBeanInterceptorHandler.java?rev=933348r1=933347r2=933348view=diff == --- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/DependentScopedBeanInterceptorHandler.java (original) +++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/DependentScopedBeanInterceptorHandler.java Mon Apr 12 18:20:06 2010 @@ -67,12 +67,10 @@ public class DependentScopedBeanIntercep /** * {...@inheritdoc} */ - protected Object callAroundInvokes(Method proceed, Object[] arguments, ListInterceptorData stack, - CreationalContextImpl? cc) - throws Exception + protected Object callAroundInvokes(Method proceed, Object[] arguments, ListInterceptorData stack) throws Exception
AW: svn commit: r933376 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: container/InjectionResolver.java context/AbstractContext.java context/creational/CreationalContextImpl
I'm not sure if the incompleteInstance needs to be volatile, since the creation should only get called from one thread. In fact, we must make sure that the Context for must allow creating a bean at a time by calling Contextual#create(). At least for @ApplicationScoped, @Singleton, @SessionScoped and @ConversationScoped beans of the same context. And another thing: the incompleteInstance can get set to null at the end of Contextual#create(). Because this is really only needed for preventing cyclic references (if no proxy gets applied) _at_creation_time_. LieGrue, strub --- gerdo...@apache.org gerdo...@apache.org schrieb am Mo, 12.4.2010: Von: gerdo...@apache.org gerdo...@apache.org Betreff: svn commit: r933376 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: container/InjectionResolver.java context/AbstractContext.java context/creational/CreationalContextImpl.java lifecycle/AbstractLifeCycle.java An: comm...@openwebbeans.apache.org Datum: Montag, 12. April, 2010 21:33 Uhr Author: gerdogdu Date: Mon Apr 12 19:33:37 2010 New Revision: 933376 URL: http://svn.apache.org/viewvc?rev=933376view=rev Log: more sync issue and some tweaking Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/AbstractContext.java openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextImpl.java openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/AbstractLifeCycle.java Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java?rev=933376r1=933375r2=933376view=diff == --- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java (original) +++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java Mon Apr 12 19:33:37 2010 @@ -82,6 +82,15 @@ public class InjectionResolver this.manager = manager; } + + /** + * Clear caches. + */ + public void clearCaches() + { + this.resolvedBeansByName.clear(); + this.resolvedBeansByType.clear(); + } /** * Returns bean manager injection resolver. Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/AbstractContext.java URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/AbstractContext.java?rev=933376r1=933375r2=933376view=diff == --- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/AbstractContext.java (original) +++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/AbstractContext.java Mon Apr 12 19:33:37 2010 @@ -14,12 +14,12 @@ package org.apache.webbeans.context; import java.lang.annotation.Annotation; -import java.util.Collections; import java.util.Iterator; import java.util.Map; import java.util.Set; -import java.util.WeakHashMap; import java.util.Map.Entry; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; import javax.enterprise.context.ApplicationScoped; import javax.enterprise.context.ContextNotActiveException; @@ -48,7 +48,7 @@ import org.apache.webbeans.util.Asserts; public abstract class AbstractContext implements WebBeansContext { /**Context status, active or not*/ - protected boolean active; + protected volatile boolean active; /**Context type*/ protected ContextTypes type; @@ -60,8 +60,9 @@ public abstract class AbstractContext im protected Class? extends Annotation scopeType; /**Contextual to CreationalContext Map*/ - protected final MapContextual?, CreationalContext? creationalContextMap = - Collections.synchronizedMap(new WeakHashMapContextual?, CreationalContext?()); + protected final ConcurrentMapContextual?, CreationalContext? creationalContextMap = + new ConcurrentHashMapContextual?, CreationalContext?(); + /** * Creates a new context instance @@ -195,8 +196,21 @@ public abstract class AbstractContext im if (instance != null) { - this.componentInstanceMap.put(component, instance); - this.creationalContextMap.put(component, creationalContext); + if(this.componentInstanceMap instanceof ConcurrentMap) + { +
Re: svn commit: r933348 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept: ApplicationScopedBeanIntereptorHandler.java DependentScopedBeanInterceptorHandler.java Int
This makes no difference, really. The problem is that we store a CreationalContext as a member in NormalScopedBeanInterceptorHandler. And subsequent function calls rely on it. But if in the meantime _another_ thread overwrites this NormalScopedBeanInterceptorHandler.creationalContext (by using the same proxy instance), then we get into troubles. Tbis is hard to debug and write tests for, but this is really obvious from looking at the code. And I already had this problem in my apps. It's not funny to randomly pickup instances from other sessions... LieGrue, strub --- Gurkan Erdogdu cgurkanerdo...@gmail.com schrieb am Mo, 12.4.2010: Von: Gurkan Erdogdu cgurkanerdo...@gmail.com Betreff: Re: svn commit: r933348 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept: ApplicationScopedBeanIntereptorHandler.java DependentScopedBeanInterceptorHandler.java InterceptorHandler.java NormalScopedBeanInterceptorHand An: dev@openwebbeans.apache.org Datum: Montag, 12. April, 2010 22:29 Uhr Please look at AbstractContext, creationalContextMap#putIfAbsent call 2010/4/12 Mark Struberg strub...@yahoo.de Sorry, I think we need to rollback the rollback, since this re-introduces really heavy concurrency problems. @SessionScoped public class User [ public String getEmail().. } @ApplicationScoped class MailService { private @Inject User usr; public void sendMail(String content) { sendInternal(user.getEmail(), content); } } now, with this change whenever 2 threads (from 2 sessions of a webserver) invoke sendMail and hit the user.getEmail() the NormalScopedBeanInterceptorHandler gets called and those 2 threads override each other the private transient WeakReferenceCreationalContext? creationalContext = null; because there is only one single proxy instance being used by those 2 threads. Got me? LieGrue, strub --- gerdo...@apache.org gerdo...@apache.org schrieb am Mo, 12.4.2010: Von: gerdo...@apache.org gerdo...@apache.org Betreff: svn commit: r933348 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept: ApplicationScopedBeanIntereptorHandler.java DependentScopedBeanInterceptorHandler.java InterceptorHandler.java NormalScopedBeanInterceptorHandler.java An: comm...@openwebbeans.apache.org Datum: Montag, 12. April, 2010 20:20 Uhr Author: gerdogdu Date: Mon Apr 12 18:20:06 2010 New Revision: 933348 URL: http://svn.apache.org/viewvc?rev=933348view=rev Log: [OWB-351] OWB picks up @SessionScoped contextual instances from expired sessions. Corrects eating client provided creational context via BeanManager#getReference Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/ApplicationScopedBeanIntereptorHandler.java openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/DependentScopedBeanInterceptorHandler.java openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/NormalScopedBeanInterceptorHandler.java Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/ApplicationScopedBeanIntereptorHandler.java URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/ApplicationScopedBeanIntereptorHandler.java?rev=933348r1=933347r2=933348view=diff == --- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/ApplicationScopedBeanIntereptorHandler.java (original) +++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/ApplicationScopedBeanIntereptorHandler.java Mon Apr 12 18:20:06 2010 @@ -21,7 +21,6 @@ package org.apache.webbeans.intercept; import javax.enterprise.context.spi.CreationalContext; import org.apache.webbeans.component.OwbBean; -import org.apache.webbeans.context.creational.CreationalContextImpl; /** @@ -43,7 +42,7 @@ public class ApplicationScopedBeanIntere /** * Creates a new handler. * @param bean bean - * @param creationalContext creational context + * @param creationalContext creaitonal context */ public ApplicationScopedBeanIntereptorHandler(OwbBean? bean, CreationalContext? creationalContext) { @@ -53,11 +52,11 @@ public class ApplicationScopedBeanIntere /** * {...@inheritdoc} */ - protected Object getContextualInstance(OwbBeanObject bean, CreationalContextImpl? creationalContext) + protected Object getContextualInstance(OwbBeanObject bean) { if
Re: svn commit: r933348 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept: ApplicationScopedBeanIntereptorHandler.java DependentScopedBeanInterceptorHandler.java Int
Please attach a small web application code that shows your issue. Without it, it is very hard to visualize your siutation. As a side note, serialization issues always a problem in Java Web Applications. You have to manage this via synchoronization blocks or third party other libs, for example Spring serializes framerwork etc. For us, creationalContext is created by any proxy instance and saved in the context until context is destroyed. I really do not understand how you get instance from other sessions, but it may that you have a problem with your code. And our code is written as a thread-safe. So, please attach a small web app that shows the problem therefore we can solve more rational than intuitively. Thanks; --Gurkan 2010/4/13 Mark Struberg strub...@yahoo.de This makes no difference, really. The problem is that we store a CreationalContext as a member in NormalScopedBeanInterceptorHandler. And subsequent function calls rely on it. But if in the meantime _another_ thread overwrites this NormalScopedBeanInterceptorHandler.creationalContext (by using the same proxy instance), then we get into troubles. Tbis is hard to debug and write tests for, but this is really obvious from looking at the code. And I already had this problem in my apps. It's not funny to randomly pickup instances from other sessions... LieGrue, strub --- Gurkan Erdogdu cgurkanerdo...@gmail.com schrieb am Mo, 12.4.2010: Von: Gurkan Erdogdu cgurkanerdo...@gmail.com Betreff: Re: svn commit: r933348 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept: ApplicationScopedBeanIntereptorHandler.java DependentScopedBeanInterceptorHandler.java InterceptorHandler.java NormalScopedBeanInterceptorHand An: dev@openwebbeans.apache.org Datum: Montag, 12. April, 2010 22:29 Uhr Please look at AbstractContext, creationalContextMap#putIfAbsent call 2010/4/12 Mark Struberg strub...@yahoo.de Sorry, I think we need to rollback the rollback, since this re-introduces really heavy concurrency problems. @SessionScoped public class User [ public String getEmail().. } @ApplicationScoped class MailService { private @Inject User usr; public void sendMail(String content) { sendInternal(user.getEmail(), content); } } now, with this change whenever 2 threads (from 2 sessions of a webserver) invoke sendMail and hit the user.getEmail() the NormalScopedBeanInterceptorHandler gets called and those 2 threads override each other the private transient WeakReferenceCreationalContext? creationalContext = null; because there is only one single proxy instance being used by those 2 threads. Got me? LieGrue, strub --- gerdo...@apache.org gerdo...@apache.org schrieb am Mo, 12.4.2010: Von: gerdo...@apache.org gerdo...@apache.org Betreff: svn commit: r933348 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept: ApplicationScopedBeanIntereptorHandler.java DependentScopedBeanInterceptorHandler.java InterceptorHandler.java NormalScopedBeanInterceptorHandler.java An: comm...@openwebbeans.apache.org Datum: Montag, 12. April, 2010 20:20 Uhr Author: gerdogdu Date: Mon Apr 12 18:20:06 2010 New Revision: 933348 URL: http://svn.apache.org/viewvc?rev=933348view=rev Log: [OWB-351] OWB picks up @SessionScoped contextual instances from expired sessions. Corrects eating client provided creational context via BeanManager#getReference Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/ApplicationScopedBeanIntereptorHandler.java openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/DependentScopedBeanInterceptorHandler.java openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/NormalScopedBeanInterceptorHandler.java Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/ApplicationScopedBeanIntereptorHandler.java URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/ApplicationScopedBeanIntereptorHandler.java?rev=933348r1=933347r2=933348view=diff == --- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/ApplicationScopedBeanIntereptorHandler.java (original) +++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/ApplicationScopedBeanIntereptorHandler.java Mon Apr 12 18:20:06 2010 @@ -21,7 +21,6 @@ package org.apache.webbeans.intercept; import