Announcement Announcement Module
No announcement yet.
Injecting Spring bean to EJB3 SLSB without @Autowired Annotation Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Injecting Spring bean to EJB3 SLSB without @Autowired Annotation

    I need to develop an EJB(SLSB), which has a DAO reference.

    class MyFirstEJB3 implements FirstEJB3Remote
       private MyDAO dao;
    Now i want to configure these beans in spring applicationContext.xml.

    As i am not using Annotations for all other beans(i am configuring using XML), to maintain consistency, i want to configure these beans also through XML.

    In spring-reference manual, i found that it can be done using @Interceptors(SpringBeanAutowiringInterceptor.clas s)on MyFirstEJB3 and @Autowired on MyDAO.

    Is there any other way to configure it, so that when i access my EJB, i should get the EJB with DAO has been set.

  • #2
    So first of all: EJBs are objects created by Ejb container and Spring can do nothing about it. it means that if ejbs are created spring can not postprocess them as it does for their own created beans.

    Till EJB 3 the only way to integrate EJB and Spring was to manually retrieve spring beans from Spring context in EJBs.
    Using EJB 3 Interceptor Spring can process @Autowired annotations and inject Spring dependencies to your EJBs.
    I do not know exactly which annotations you would like to avoid : Spring ones or EJBs ones ? or maybe both

    In the latter case the only soultion i can think of is using Spring EJB 2.1 support classes.