4 Replies Latest reply on Oct 19, 2006 10:33 AM by tterm

    interceptor metadata issue

    tterm

      Hello,

      There is a problem for me with the interceptors (adding some metadata) during an EJB3 method invocation. I thought it is an issue with the serialization framework so had a conversation with Clebert before in this forum: http://www.jboss.com/index.html?module=bb&op=viewtopic&t=89387.

      So I will give an abstract. The complete stacktrace and code snippets are given in the serialization forum.

      I created an clientside and an serverside interceptor. The clientside interceptor put a string in the SimpleMetaData with the default payload key MARSHALLED and the serverside interceptor should read this data. So if I do this I get allways a ClassCastException (shown in the other forum) with JBoss-4.0.4 and newer but not with JBoss-4.0.3SP1 (That works fine). If I set the payload key to AS_IS then it works fine with the newest version.

      I would like to know what I do wrong or understand wrong that I allways get this ClassCastException?

      If you need more information, testcases (I added a url where you can find a complete example) ore something please let me know.

      Thanks in advance,
      Thomas Termin

        • 1. Re: interceptor metadata issue
          clebert.suconic

          Can you provide a code snipped on how you set the String on PayLoad.


          Also... a question to EJB3 guys:

          is it legal (specwise) to use Payload on interceptors?

          If it is, what the semantic of doing so? I mean... we could set any object inside, or only MarshalledValues?


          Clebert

          • 2. Re: interceptor metadata issue
            tterm

            The interceptors (org.jboss.aop.advice.Interceptor) are requested during an ejb3 method call. The client side interceptor code is the following:

            public class ExampleClientInterceptor implements Interceptor, Serializable {
             private static Logger logger = Logger.getLogger(ExampleClientInterceptor.class);
            
             public String getName() {
             return "ExampleClientInterceptor";
             }
            
             public Object invoke(Invocation invocation) throws Throwable {
             logger.debug("Client: request");
             SimpleMetaData metaData = invocation.getMetaData();
             metaData.addMetaData("tag", "attr", "Hello JBoss;-)");
             Object obj = invocation.invokeNext();
             logger.debug("Client: response");
             return obj;
             }
            }


            If I do an EJB3 request I get allways this exception:

            java.lang.ClassCastException: org.jboss.serial.objectmetamodel.DataContainer$DataContainerOutput
             org.jboss.aop.util.MarshalledValue.writeExternal(MarshalledValue.java:190)
             org.jboss.serial.persister.ExternalizePersister.writeData(ExternalizePersister.java:58)
             org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.describeObject(ObjectDescriptorFactory.jav
            a:275)
             org.jboss.serial.objectmetamodel.DataContainer$DataContainerOutput.writeObject(DataContainer.java:3
            86)
             org.jboss.aop.metadata.SimpleMetaData.writeExternal(SimpleMetaData.java:226)
             org.jboss.serial.persister.ExternalizePersister.writeData(ExternalizePersister.java:58)
             org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.describeObject(ObjectDescriptorFactory.jav
            a:275)
             org.jboss.serial.objectmetamodel.DataContainer$DataContainerOutput.writeObject(DataContainer.java:3
            86)
             org.jboss.aop.joinpoint.MethodInvocation.writeExternal(MethodInvocation.java:321)
             org.jboss.serial.persister.ExternalizePersister.writeData(ExternalizePersister.java:58)
             org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.describeObject(ObjectDescriptorFactory.jav
            a:275)
             org.jboss.serial.objectmetamodel.DataContainer$DataContainerOutput.writeObject(DataContainer.java:3
            86)
             org.jboss.serial.io.MarshalledObjectForLocalCalls.<init>(MarshalledObjectForLocalCalls.java:38)
             org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:53)
             org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
             de.fh_wiesbaden.cs.vs.jboss_ejb3_instrumentation.interceptor.client.ARMRunningClient.invoke(ARMRunn
            ingClient.java:248)
             de.fh_wiesbaden.cs.vs.jboss_ejb3_instrumentation.interceptor.client.ClientARMInterceptor.invoke(Cli
            entARMInterceptor.java:94)
             org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
             de.fh_wiesbaden.cs.vs.jboss_ejb3_instrumentation.interceptor.client.ClientGetCorrelatorFromThreadLo
            calInterceptor.invoke(ClientGetCorrelatorFromThreadLocalInterceptor.java:43)
             org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
             org.jboss.ejb3.stateless.StatelessClusteredProxy.invoke(StatelessClusteredProxy.java:100)
             $Proxy92.getCategory(Unknown Source)
             de.fh_wiesbaden.cs.vs.xpetstore.web.struts.action.category.CategoryAction.doExecute(CategoryAction.
            java:48)
             de.fh_wiesbaden.cs.vs.xpetstore.web.struts.action.BaseAction.execute(BaseAction.java:78)
             org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:446)
             org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:266)
             org.apache.struts.action.ActionServlet.process(ActionServlet.java:1292)
             org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:492)
             javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
             javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
             de.fh_wiesbaden.cs.vs.xpetstore.web.filter.SignOnFilter.doFilter(SignOnFilter.java:128)
             com.opensymphony.module.sitemesh.filter.PageFilter.parsePage(Unknown Source)
             com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(Unknown Source)
             org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
            


            If I set the last parameter (Payload.KEY) for the addMetaData() method to 'AS_IS' then it works fine in jboss-4.0.4 and also 4.0.5. If the default payload key is MARSHALLED then it crashes with the ClassCastException.

            Regards,
            Thomas Termin

            • 3. Re: interceptor metadata issue
              tterm

              Hello,

              no answers until now. :-) Would be more information helpful? I can provide testcases and all that if necessary!

              Regards,
              Thomas Termin

              • 4. Re: interceptor metadata issue
                tterm

                Hello,

                I'm still interested in this problem. So could me at least somebody say why it works for JBoss-4.0.3SP1 but not for the later versions?

                The problem is if I have a remote ejb client and a local webapp and I would set the Payload key to MARSHALLED the it would be crash for the webapp. Otherwise if I would set it to AS_IS then my metadata would be ignored for the remote client.

                Regards,
                Thomas Termin