问题
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:
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.
来源:https://stackoverflow.com/questions/3401821/weld-injection-failing-when-calling-a-method-from-an-super-abstract-class-with-w