views:

41

answers:

1

Hi all.

I am having a problem with weld-wicket. When @Inject-ing an EJB that inherits from an abstract class, if I attempt to call a method from the abstract class I get an ejb-ref error. However if I call a method from the concrete class it works perfectly. I can override methods and call them, and I can delegate an overridden method to the abstract class (having the overridden method call super.method()) and that works. Is there some sort of configuration I have to do to the abstract class?

Thanks.

+1  A: 

This is a guess based on my experience with Seam. Weld injects a proxy that wraps your bean. The proxy only intercepts public methods and delegates those to the underlying bean (EJB in your case). When you call a protected method on the proxy or a package-private method from a class in the same package that method is not intercepted and is invoked directly on the proxy which causes your error. To make the story short, only call public methods or back all your dependencies by an interface and inject that.

igor.vaynberg
Thanks for the response, adding a public interface works in the same way that overriding the method works, however the public interface cannot extend any other interfaces which doesn't really help all that much since I still have to duplicate code...
kgrad
I changed from @Inject to @EJB and it works perfectly, if someone wants to write up that answer I will accept it.
kgrad