6 Replies Latest reply on Jun 5, 2006 5:06 PM by iradix

    Interception of subclass methods

    iradix

      I'm having a problem with SFSB inheritence that seems very odd to me. I have an abstract class/interface which is extended by a concrete implementation. The superclass defines an abstract getEntityManager() method which returns an EntityManager that has been injected using seam managed persistence in the subclass. Now, the problem is if I access any of the methods defined in the subclass and it's interface, the EntityManager is injected and everything works fine, but if I call a method defined in the superclass/interface it does not appear to be intercepted, no injection occurs and I get a NullPointerException. I have @Intercept(InterceptionType.ALWAYS) set on all the relevent classes and I can't imagine this would be considered a feature. Can anybody tell me what's going on?

        • 1. Re: Interception of subclass methods

          I can hazard a guess. Seam injects at the Seam component level. Your abstract class isn't a Seam component because you can't have abstract Seam components. Your Seam component can extend an abstract class, and the Seam annotations on this class are properly recognized. However, once you make a call on a method that isn't part of your component SFSB's business interface this call isn't intercepted, you don't have a valid context and get the error.

          Have you tried adding these parent methods to the SFSB's interface (extended the child interface from the parent interface)?

          • 2. Re: Interception of subclass methods
            iradix

            I appreciate your feedback but not only have I tried it that way, I haven't tried it any other way. I'm actually injecting the component into a field of the local interface type, so just calling the method proves that it's available as part of the SFSB. I've also checked the logs to make sure the component is deployed as a conversation scoped SFSB at startup.

            I'm in the process of upgrading to CR3 at the moment and I think that might have fixed the problem. After taking a look through the Seam source (Beta 2) I didn't see any reason it would have preferentially intercepted some methods and not others so my theory is that it was a bug in how interceptors were applied in the EJB embedded server that came with that release.

            • 3. Re: Interception of subclass methods
              gavin.king

              What kind of EntityManager is it? @PersistenceContext, or @In?

              • 4. Re: Interception of subclass methods
                iradix

                It's seam managed, @In(create = true) and it works like a charm as long as the method being called isn't part of the super-class/interface.

                • 5. Re: Interception of subclass methods
                  gavin.king

                  OK, well let me know if it is fixed by the latest EJB3 release.

                  • 6. Re: Interception of subclass methods
                    iradix

                    It does seem to have fixed the problem. I'm surprised no one has run across that before.