8 Replies Latest reply on Feb 22, 2012 8:53 PM by Stephen Coy

    JBoss 7 SessionContext problem with method getBusinessObject

    Björn Wahl Newbie

      Hello together,

       

      I have a problem with the migration from JBoss 5.1 to JBoss 7.1.

       

      I used the JBoss version 7.1 Snapshot from 10.02.2012 because in version JBoss 7.1 CR1 the SessionContext doesn´t implements Serializable.

      In this nightly build version from 10.02.2012 is was fixed.

       

      In our Project we have for a Bean different interfaces, two local interfaces and two remote interfaces.

       

      With JBoss 5 we serialized and saved the SessionContext from the Bean in a additional Object and get later on with the method getBusinessObject the Internal Bean. That's not work anymore with JBoss 7. Here are the error message:

       

      14:08:29,216 ERROR [com.l1id.abis.im.web.application.facade.WebApplicationFacade] (MSC service thread 1-3) Fail to cleanup server resource: com.l1id.abis.im.api.base.IMException: Unspecified runtime exception.(3)[Instance 78-2B-CB-97-10-27]: Runtime exception.  Could not find SFSB RequestContextBean with {[-120, -117, -128, 121, -80, 115, 79, 30, -124, 5, -77, -89, 75, 116, -18, -117]}

          at com.l1id.abis.im.api.internal.beans.IdentityManagerBean.dismiss(IdentityManagerBean.java:1634) [L1_IM_Server.jar:]

          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.6.0_25]

          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [rt.jar:1.6.0_25]

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [rt.jar:1.6.0_25]

          at java.lang.reflect.Method.invoke(Method.java:597) [rt.jar:1.6.0_25]

          at org.jboss.as.ee.component.ManagedReferenceMethodInterceptorFactory$ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptorFactory.java:72) [jboss-as-ee-7.1.0.Final-SNAPSHOT.jar:7.1.0.Final-SNAPSHOT]

          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

          at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

          at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:36) [jboss-as-ee-7.1.0.Final-SNAPSHOT.jar:7.1.0.Final-SNAPSHOT]

          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

          at org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:47)

          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

          at org.jboss.as.jpa.interceptor.SFSBInvocationInterceptor.processInvocation(SFSBInvocationInterceptor.java:58)

          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

          at org.jboss.as.ejb3.tx.StatefulBMTInterceptor.handleInvocation(StatefulBMTInterceptor.java:102) [jboss-as-ejb3-7.1.0.Final-SNAPSHOT.jar:7.1.0.Final-SNAPSHOT]

          at org.jboss.as.ejb3.tx.BMTInterceptor.processInvocation(BMTInterceptor.java:56) [jboss-as-ejb3-7.1.0.Final-SNAPSHOT.jar:7.1.0.Final-SNAPSHOT]

          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

          at org.jboss.as.ejb3.component.stateful.StatefulSessionSynchronizationInterceptor.processInvocation(StatefulSessionSynchronizationInterceptor.java:156) [jboss-as-ejb3-7.1.0.Final-SNAPSHOT.jar:7.1.0.Final-SNAPSHOT]

          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

          at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

          at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

          at org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:53) [jboss-as-ee-7.1.0.Final-SNAPSHOT.jar:7.1.0.Final-SNAPSHOT]

          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

          at org.jboss.as.ejb3.component.stateful.StatefulRemoveInterceptor.processInvocation(StatefulRemoveInterceptor.java:82) [jboss-as-ejb3-7.1.0.Final-SNAPSHOT.jar:7.1.0.Final-SNAPSHOT]

          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

          at org.jboss.as.ejb3.component.stateful.StatefulComponentInstanceInterceptor.processInvocation(StatefulComponentInstanceInterceptor.java:70) [jboss-as-ejb3-7.1.0.Final-SNAPSHOT.jar:7.1.0.Final-SNAPSHOT]

          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

          at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41) [jboss-as-ejb3-7.1.0.Final-SNAPSHOT.jar:7.1.0.Final-SNAPSHOT]

          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

          at org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:59) [jboss-as-ejb3-7.1.0.Final-SNAPSHOT.jar:7.1.0.Final-SNAPSHOT]

          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

          at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50) [jboss-as-ee-7.1.0.Final-SNAPSHOT.jar:7.1.0.Final-SNAPSHOT]

          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

          at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45) [jboss-as-ee-7.1.0.Final-SNAPSHOT.jar:7.1.0.Final-SNAPSHOT]

          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

          at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

          at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:165) [jboss-as-ee-7.1.0.Final-SNAPSHOT.jar:7.1.0.Final-SNAPSHOT]

          at org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:173) [jboss-as-ee-7.1.0.Final-SNAPSHOT.jar:7.1.0.Final-SNAPSHOT]

          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

          at org.jboss.as.ejb3.component.stateful.StatefulComponentIdInterceptor.processInvocation(StatefulComponentIdInterceptor.java:52) [jboss-as-ejb3-7.1.0.Final-SNAPSHOT.jar:7.1.0.Final-SNAPSHOT]

          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

          at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

          at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:72) [jboss-as-ee-7.1.0.Final-SNAPSHOT.jar:7.1.0.Final-SNAPSHOT]

          at com.l1id.abis.im.api.interfaces.IIdentityManagerLocal$$$view37.dismiss(Unknown Source) [L1_IM_Server.jar:]

          at com.l1id.abis.im.web.application.facade.WebApplicationFacade.cleanup(WebApplicationFacade.java:245) [L1_IM_WebApplication.jar:]

          at com.l1id.abis.im.web.application.cfg.SearchCriteriaAndResultCfg.getImFieldDescriptorMap(SearchCriteriaAndResultCfg.java:1071) [L1_IM_WebApplication.jar:]

          at com.l1id.abis.im.web.application.cfg.SearchCriteriaAndResultCfg.getType2DemoQueryList(SearchCriteriaAndResultCfg.java:1142) [L1_IM_WebApplication.jar:]

          at com.l1id.abis.im.web.application.cfg.SearchCriteriaAndResultCfg.initilize(SearchCriteriaAndResultCfg.java:247) [L1_IM_WebApplication.jar:]

          at com.l1id.abis.im.web.application.cfg.SearchCriteriaAndResultCfg.setInit(SearchCriteriaAndResultCfg.java:317) [L1_IM_WebApplication.jar:]

          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.6.0_25]

          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [rt.jar:1.6.0_25]

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [rt.jar:1.6.0_25]

          at java.lang.reflect.Method.invoke(Method.java:597) [rt.jar:1.6.0_25]

          at org.jboss.seam.util.Reflections.invoke(Reflections.java:22) [jboss-seam.jar:2.2.2.EAP5]

          at org.jboss.seam.Component.setPropertyValue(Component.java:1914) [jboss-seam.jar:2.2.2.EAP5]

          at org.jboss.seam.Component.initialize(Component.java:1531) [jboss-seam.jar:2.2.2.EAP5]

          at org.jboss.seam.Component.postConstructJavaBean(Component.java:1456) [jboss-seam.jar:2.2.2.EAP5]

          at org.jboss.seam.Component.postConstruct(Component.java:1379) [jboss-seam.jar:2.2.2.EAP5]

          at org.jboss.seam.Component.newInstance(Component.java:2155) [jboss-seam.jar:2.2.2.EAP5]

          at org.jboss.seam.contexts.Contexts.startup(Contexts.java:305) [jboss-seam.jar:2.2.2.EAP5]

          at org.jboss.seam.contexts.Contexts.startup(Contexts.java:279) [jboss-seam.jar:2.2.2.EAP5]

          at org.jboss.seam.contexts.ServletLifecycle.endInitialization(ServletLifecycle.java:142) [jboss-seam.jar:2.2.2.EAP5]

          at org.jboss.seam.init.Initialization.init(Initialization.java:744) [jboss-seam.jar:2.2.2.EAP5]

          at org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:36) [jboss-seam.jar:2.2.2.EAP5]

          at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3392) [jbossweb-7.0.10.Final.jar:]

          at org.apache.catalina.core.StandardContext.start(StandardContext.java:3850) [jbossweb-7.0.10.Final.jar:]

          at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.0.Final-SNAPSHOT.jar:7.1.0.Final-SNAPSHOT]

          at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)

          at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)

          at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_25]

          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_25]

          at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_25]

      Caused by: javax.ejb.NoSuchEJBException: Could not find SFSB RequestContextBean with {[-120, -117, -128, 121, -80, 115, 79, 30, -124, 5, -77, -89, 75, 116, -18, -117]}

          at org.jboss.as.ejb3.component.stateful.StatefulComponentInstanceInterceptor.processInvocation(StatefulComponentInstanceInterceptor.java:66) [jboss-as-ejb3-7.1.0.Final-SNAPSHOT.jar:7.1.0.Final-SNAPSHOT]

          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

          at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41) [jboss-as-ejb3-7.1.0.Final-SNAPSHOT.jar:7.1.0.Final-SNAPSHOT]

          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

          at org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:59) [jboss-as-ejb3-7.1.0.Final-SNAPSHOT.jar:7.1.0.Final-SNAPSHOT]

          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

          at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50) [jboss-as-ee-7.1.0.Final-SNAPSHOT.jar:7.1.0.Final-SNAPSHOT]

          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

          at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45) [jboss-as-ee-7.1.0.Final-SNAPSHOT.jar:7.1.0.Final-SNAPSHOT]

          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

          at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

          at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:165) [jboss-as-ee-7.1.0.Final-SNAPSHOT.jar:7.1.0.Final-SNAPSHOT]

          at org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:173) [jboss-as-ee-7.1.0.Final-SNAPSHOT.jar:7.1.0.Final-SNAPSHOT]

          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

          at org.jboss.as.ejb3.component.stateful.StatefulComponentIdInterceptor.processInvocation(StatefulComponentIdInterceptor.java:52) [jboss-as-ejb3-7.1.0.Final-SNAPSHOT.jar:7.1.0.Final-SNAPSHOT]

          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

          at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

          at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:72) [jboss-as-ee-7.1.0.Final-SNAPSHOT.jar:7.1.0.Final-SNAPSHOT]

          at com.l1id.abis.im.api.internal.interfaces.IRequestContextIntLocal$$$view20.cloneInternalLocal(Unknown Source) [L1_IM_Server.jar:]

          at com.l1id.abis.im.api.internal.beans.RequestContextBean.makeInternalLocal(RequestContextBean.java:149) [L1_IM_Server.jar:]

          at com.l1id.abis.im.api.internal.beans.SCInterface.getInternalInterface(SCInterface.java:584) [L1_IM_Server.jar:]

          at com.l1id.abis.im.api.internal.beans.IdentityManagerBean.dismiss(IdentityManagerBean.java:1623) [L1_IM_Server.jar:]

          ... 72 more

       

      Did anyone have an idea why or a explanation?

        • 1. Re: JBoss 7 SessionContext problem with method getBusinessObject
          Stephen Coy Master

          I think you've been fortunate so far, given that javax.ejb.SessionContext objects are not required to be serializable in any case.

           

          SessionContext objects are also only required to be accessible from a session bean's business methods or other well defined lifecycle methods (and any associated interceptors).

           

          If you give us a better idea of what you're trying to do we may be able to suggest a more portable solution.

          • 2. Re: JBoss 7 SessionContext problem with method getBusinessObject
            Björn Wahl Newbie

            Thanks for response,

             

            we create for our Project a client.jar. In this jar only one local and remote interface with restricted functionality exist. In the application we use extended local and remote interfaces for that bean to become more functionality. To get that extended local and remote interface we  used the serialised Session Context before. That's only for security reason.

             

            Thanks,

            Björn

            • 3. Re: JBoss 7 SessionContext problem with method getBusinessObject
              Stephen Coy Master

              Can you provide some sample code so that we can see what you're doing?

               

              It sounds like your client jar contains interfaces that are simply subsets of the real interfaces?

              • 4. Re: JBoss 7 SessionContext problem with method getBusinessObject
                Björn Wahl Newbie

                Yes that's right. It is only a subset of the real interface.

                 

                This is the method where I try to get the Internal Local Interface:

                 

                static IRequestContextInt getInternalInterface (IRequestContext interfaceA, boolean convertToLocalA)

                try

                        {

                            IMSerializableBlob    sbL                = interfaceA.getSCBlob(); //In this Object is the serializedSessionContext included as a byte[].

                           

                            if ( sbL == null )

                            {

                                // POJO object, we can do a simple cast

                                return (IRequestContextInt) interfaceA;

                            }

                           

                             SessionContext        sessionContextL = null;

                               

                            // Get session context

                            if(sbL.getDataBlob() != null)

                            {

                                ObjectInputStream    inL             = new ObjectInputStream( new ByteArrayInputStream(sbL.getDataBlob()));

                                sessionContextL = (SessionContext) inL.readObject();

                                inL.close();

                            }

                 

                            IRequestContextInt    intInterfaceL    = null;

                           

                            try

                            {

                                //can´t do it in AS 7 with getBusinessObject Method.

                                intInterfaceL    = sessionContextL.getBusinessObject(IRequestContextIntLocal.class);// This works fine but if i try to access a method from the bean the error message above appears.

                            }

                            catch ( Throwable xcpA )

                            {

                                //ToBeDone check sketchy exception handling: OK

                                //can´t do it in AS 7 with getBusinessObject Method.

                                intInterfaceL    = sessionContextL.getBusinessObject(IRequestContextIntRemote.class);

                 

                            }

                           

                            if ( convertToLocalA )

                            {

                                IRequestContextInt        internalLocalContextL    = RequestContextBean.makeInternalLocal(intInterfaceL); //In this method i try to call a method from the bean.

                 

                                // Unlock the object so that it can be used

                                internalLocalContextL.unlock( IMConstants.RecordType.class.hashCode());

                               

                                return internalLocalContextL;

                            }

                            else

                            {

                                return intInterfaceL;

                            }

                 

                 

                In the method makeInternalLocal() i try to call a method from the internalLocal Bean but this fails with the above message.

                 

                I must update now to JBoss 7.1 Final.

                • 5. Re: JBoss 7 SessionContext problem with method getBusinessObject
                  Stephen Coy Master

                  WebApplicationFacade.cleanup

                        -> IIdentityManagerLocal$$$view37.dismiss

                        -> IdentityManagerBean.dismiss

                        -> SCInterface.getInternalInterface

                        -> RequestContextBean.makeInternalLocal

                   

                  where RequestContextBean is a stateful session bean?

                   

                  You're keeping a reference to the serialized SessionContext, instead of the original SFSB? Where is the serialized SessionContext held and why do you not just keep a reference to the SFSB instead?

                   

                  In any event, if you want to follow this general pattern, you should be serializing the result of:

                   

                  {code:java}sessionContext.getEJBObject().getHandle();{code}

                   

                  (because that what the javax.ejb.Handle is for...)

                   

                  Later on, after you have deserialized the Handle, you can recover the javax.ejb.EJBObject and invoke your business method via the remote interface.

                   

                  But really, there's probably better ways of securing access to these methods.

                  • 6. Re: JBoss 7 SessionContext problem with method getBusinessObject
                    Stephen Coy Master

                    In fact, this line worries me too:

                     

                    {code:java}IMSerializableBlob    sbL                = interfaceA.getSCBlob(); //In this Object is the serializedSessionContext included as a byte[].{code}

                     

                     

                    This could easily be:

                     

                    {code:java}IRequestContextInt intInterfaceL = interfaceA.getInternalInterface(){code}

                     

                    the implementation of which is trivial (and will always work).

                     

                    This is not much less secure than accessing the blob and deserializing it, which is just security with a bit of obscurity (which is not security at all).

                     

                    (Actually, its completely secure right now isn't it? )

                    1 of 1 people found this helpful
                    • 7. Re: JBoss 7 SessionContext problem with method getBusinessObject
                      Björn Wahl Newbie

                      Thanks a lot for all the response.

                       

                      That's right. It is a bit of obscurity. If you know what to do then you become the internal Interface. Maybe i must refactor that part .

                       

                      With getInternalInterface() it works. The client local interface normally doesn't have this method.

                      • 8. Re: JBoss 7 SessionContext problem with method getBusinessObject
                        Stephen Coy Master

                        I just encountered this article HOW TO SELF-INVOKE EJB 3.X WITH(OUT) "THIS" on Adam Bien's weblog which sounded like it would be of interest to you regarding what you're trying to do here.