Kirill Linnik [
https://community.jboss.org/people/kirillica] created the discussion
"@Stateless bean is not initialized when using Spring"
To view the discussion, visit:
https://community.jboss.org/message/723788#723788
--------------------------------------------------------------
Hi there,
One module of our application is made by third party company and it's Spring-based.
That's should be OK, since Spring has enabled EJB injection and vice-versa. Injecting
EJBs in Spring works fine, but if I follow manual (
http://refcardz.dzone.com/refcardz/dependency-injection-in-ejb3
http://refcardz.dzone.com/refcardz/dependency-injection-in-ejb3) and do like this:@Local
public interface MyDAO {
public void test();
}
and:
@Stateless
public class MyDAOImpl extends AbstractStatelessSessionBean implements
MyDAO {
private static final long serialVersionUID = 4738436066552146052L;
private MySpringService mySpringServiceService;
@Override
protected void onEjbCreate() throws CreateException {
mySpringServiceService = (MySpringService) getBeanFactory()
.getBean("mySpringService");
}
@Override
public void test() {
...
}
}
where:
@Service("mySpringService")
and inject this EJB in another EJB like:
@EJB
private MyDAO myDAO;
On server startup I see:
Caused by: java.lang.RuntimeException:
Could not resolve @EJB reference:
[EJB Reference: beanInterface 'MyDAO', beanName 'null', mappedName
'null', lookupName 'null', owning unit
'ComponentDeploymentContext@726473212
{org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData.AnotherDAOImpl}']
for environment entry: env/AnotherDAOImpl/myDAO
in unit
ComponentDeploymentContext(a)726473212{org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData.AnotherDAOImpl}
It means, AFAIK, MyDAO is not an EJB and cannot be injected.
Well, where I am wrong?
--------------------------------------------------------------
Reply to this message by going to Community
[
https://community.jboss.org/message/723788#723788]
Start a new discussion in EJB3 at Community
[
https://community.jboss.org/choose-container!input.jspa?contentType=1&...]