Stateless EJB implements interface injection failed

后端 未结 2 1046
情深已故
情深已故 2021-01-16 06:29

Wildfly 8.2.0

I have a Stateless EJB and an interface.

@Local
@Stateless
public class Bean implements IBean{
...
}

@Local
public interf         


        
相关标签:
2条回答
  • 2021-01-16 06:47

    You need to remove @Local from Bean.

    @Stateless
    public class Bean implements IBean{
    ...
    }
    

    Because you define 2 possible Local WELD doesn't know which one to use.

    The oracle documentation show this too with @Remote interface:

    @Remote
    public interface Foo { . . . }
    
    @Stateless
    public class Bean implements Foo, Bar {
        . . .
    }
    
    0 讨论(0)
  • 2021-01-16 07:14

    When you want to inject a bean whether by EJB (using @EJB) or CDI (using @Inject) container you declare a variable with interface type. Concrete implementation of declared interface is found by a container during application deployment. In your example the problem is not with annotations but with a declared type being injected (Bean instead of IBean).

    0 讨论(0)
提交回复
热议问题