6 Replies Latest reply on Apr 6, 2007 3:27 PM by pmuir

    Injected SLSB not getting interceptors sometimes


      I'm running Seam 1.2.1, and these symptoms appear in SeamTest.

      I have SLSB A which is injected via @In with SLSB B. A seems to have all appropriate interceptors, and @Logger injection works fine. A calls B. B blows up upon writing to the log because the log is never initialized. I've tried having B declare @Logger Log log explicitly and (in the example I'll post here) by extending EntityController.

      Here's relevant bits of A:

      public class IngestServiceImpl implements IngestService
       @Logger static Log log;
       @In CsvIngest ingestUtil;
      .... (in a method)
       ingestResult = ingestUtil.ingest(feedFile, feedDefinition, previousFeedItems);

      B will throw NullPointerException when it tries to log. What I found odd is that A has all indications of receiving the interceptors, which do the injection. B looks like a direct invocation (no sign of interceptors). And I can's see a meaningful difference between A and B - so I'm stuck.

      Anyway, here's the relevant bits from B:

      public class CsvIngestUtil extends EntityController implements CsvIngest
      ... below from the throwing method - last line is 135 referenced from stacktrace
       // I put this here to test if the em was injected - it is because the assert doesn't throw
       assert getEntityManager() != null : "null entity manager!";
       System.out.println("EntityManager is not null. [" + getEntityManager().getClass().getName() + "]");
       debug("Scheduling item [" + item.getUniqueInternalCode() + "] for insert"); // throws here

      The stacktrace showing the (to me) unexpected presence/absence of interceptors is:

      aused by: java.lang.NullPointerException
       at org.jboss.seam.framework.Controller.debug(Controller.java:183)
       at com.fb.core.business.ingest.CsvIngestUtil.updateItemFromPreviousData(CsvIngestUtil.java:135)
       at com.fb.core.business.ingest.CsvIngestUtil.ingest(CsvIngestUtil.java:85)
       at com.fb.core.business.IngestServiceImpl.processFeedImportNoPersistance(IngestServiceImpl.java:76)
       at com.fb.core.business.IngestServiceImpl.processFeedImport(IngestServiceImpl.java:52)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:109)
       at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
       at org.jboss.seam.intercept.EJBInvocationContext.proceed(EJBInvocationContext.java:37)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:57)
       at org.jboss.seam.interceptors.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:47)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
       at org.jboss.seam.interceptors.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:27)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
       at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:103)
       at org.jboss.seam.intercept.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:53)
       at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:118)
       at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
       at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
       at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
       at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:126)

      Any idea what I'm doing wrong here? Any more info I could provide if not?

      I confess I'm a bit confused by when I should expect interception. I'm using SLSB more often than I would otherwise because I want @Logger and other interceptor services to work, but I realize this is because I don't understand enough yet.



        • 1. Re: Injected SLSB not getting interceptors sometimes

          Instead of using the Logger annotation, you could try looking up the Log using one of the Logging static methods.

          • 2. Re: Injected SLSB not getting interceptors sometimes

            True, and that does work of course. But the @Logger annotation should cause Seam to inject this, and I would like to understand why it doesn't so when other interceptor-related problems come up I can figure them out.

            • 3. Re: Injected SLSB not getting interceptors sometimes

              I'm exploring this in the debugger, but admit it's a bit of a mystery to me where injection takes place (Interceptor driven and via the Component class I think).

              Here's what I'm seeing.

              In this case, IngestService is a SLSB injected into a SFSB. This is injected and initialized properly. Looking at the instance of ingestService from the SFSB shows this:

              ingestService Object_$$_javassist_1 (id=3251)
               handler ClientSideInterceptor (id=3250)

              Got it. ClientSideInterceptor adds all of the Seamy goodness.

              Step down into ingestService itself, which contains the SLSB ingestUtil. This SLSB is injected by Seam, just like the above. But ingestUtil isn't intercepted at all. This is how ingestUtil looks as seen from the SLSB bean owning it:

              ingestUtil CsvIngestUtil (id=3213)

              It's the naked SLSB.

              I'd like to figure out why this is, but interceptors are subtle. If anyone on the Seam team or otherwise could give me a pointer here I'd appreciate it.


              • 4. Re: Injected SLSB not getting interceptors sometimes

                Here's what I see as these two SLSB are initialized by Seam when debug is on:

                10:49:19,760 INFO [Component] Component: ingestService, scope: STATELESS, type: STATELESS_SESSION_BEAN, class: com.fb.core.business.IngestServiceImpl, JNDI: IngestServiceImpl/local
                10:49:19,762 DEBUG [Component] interceptor stack: [Interceptor(org.jboss.seam.interceptors.MethodContextInterceptor), Interceptor(org.jboss.seam.interceptors.BijectionInterceptor)]
                10:49:19,762 DEBUG [Component] seam component not found: org.jboss.seam.core.events
                10:49:19,762 DEBUG [Component] seam component not found: org.jboss.seam.core.events
                10:49:19,762 INFO [Component] Component: ingestUtil, scope: STATELESS, type: STATELESS_SESSION_BEAN, class: com.fb.core.business.ingest.CsvIngestUtil, JNDI: CsvIngestUtil/local
                10:49:19,767 DEBUG [Component] interceptor stack: [Interceptor(org.jboss.seam.interceptors.MethodContextInterceptor)]
                10:49:19,767 DEBUG [Component] seam component not found: org.jboss.seam.core.events
                10:49:19,767 DEBUG [Component] seam component not found: org.jboss.seam.core.events

                So ingestUtil isn't intercepted by the BiInjectionInterceptor. I could add it explicitly, but am confused as to why one SLSB would get it and another would not.

                • 5. Re: Injected SLSB not getting interceptors sometimes

                  Any suggestions on this one? I'm fine with doing investigation myself, but I'm not sure where to look. Something tells me the Seam team is in overdrive right now with the new 1.3 featureset, which is pretty exciting.



                  • 6. Re: Injected SLSB not getting interceptors sometimes

                    @Logger is a special case, not Bijected. Anyway, I guess you could create a JIRA issue and attach a testcase if you feel it's a bug...

                    What you are doing looks right to me, but I'm not up on test stuff, you'll probably have to wait til Gavin gets back