0

I have a stateless DAO-EJB with a no interface view, which is inherited from a generic abstract DAO class with an additional method readAll(); So the tree is FooDAOBean <- extends GenericDAOImpl <- implements GenericDAOInterface (click here to see GenericDAO implementation - in the link it isn't an abstract class):

@Stateless
public class FooDAOBean extends GenericDAOImpl<ENodeFocus, Serializable>{

    @Override   
    public List<Foo> readAll() {
        // do something...
    }
}

and i have an initialization bean, which should configure the application with some entries:

@Singleton
@Startup
public class InitializationBean {

    @EJB
    FooDAOBean dao;

    @PostConstruct
    public void initialize() {
      // do something
    }
}

On deploying i'm getting the errors:

WFLYNAM0059: Resource lookup for injection failed: env/shitstorm.beans.InitializationBean/dao

WFLYEE0046: Failed to instantiate component view

When i implement a remote interface and annotate FooDAOBean with @Remote(<RemoteInterface>.class) it is working correctly. But i don't want to allow remote access. For me it is important, that FooDAOBean's methods are only accessible in the same JVM (local). FooDAOBean and InitializationBean are in the same EAR-Project, so it should be work or do i miss something here? Has it to do with the singleton or whats happening here? Do i have to implement a local interface? I thought since EJB 3.0 i don't need it anymore. Thanks a lot! :)

Community
  • 1
  • 1
Andy
  • 169
  • 4
  • 15

1 Answers1

1

Be aware that your FooDAOBean is implementing a business interface via its superclass.

The Oracle Java EE tutorial states:

If the bean class implements a single interface, that interface is assumed to the business interface. The business interface is a local interface unless it is annotated with the javax.ejb.Remote annotation; the javax.ejb.Local annotation is optional in this case.

Thus your FooDAOBean actually has a Local interface view instead of the no-interface view which you are expecting.

I would suggest to rename your Bean to sth like FooDAOBeanImpl. Then create a interface FooDAOBean which inherits from GenericDAOInterface. Let your Session Bean FooDAOBeanImpl now imeplent the new interface and annotate the class with @Local(FooDAOBean.class) to get a clearly defined @Local interface view. Now you able to inject FooDAOBean as expected.

stg
  • 2,757
  • 2
  • 28
  • 55