I am trying to introduce EJB into the Spring service (3.1.2) (as in different WARs) Both are very simple (methods removed to simplify the example):
EJB:
@Remote public interface MyBean { } @Singleton public class MyBeanImpl implements MyBean{ }
Services:
@Service public class MyServiceImpl implements MyService{ }
At first glance, the thing is very simple, but I tried:
@EJB(lookup = "java:global/ejbApp/MyBeanImpl!com.my.MyBean") private MyBean myBean;
and he did not work. Then I also tried:
@EJB(mappedName = "java:global/ejbApp/MyBeanImpl!com.my.MyBean") private MyBean myBean;
and
@Resource(mappedName = "java:global/ejbApp/MyBeanImpl!com.my.MyBean") private MyBean myBean;
but not one of them worked.
I managed to introduce EJB using:
<jee:jndi-lookup id="myBean" jndi-name="java:global/ejbApp/MyBeanImpl!com.my.MyBean" />
in my Spring configuration and in the service:
@Autowired private MyBean myBean;
But I really don't like this solution. I would like my JNDI path to be in some annotation in order to be able to do, for example:
@EJB(lookup = MyBean.JNDI_NAME) private MyBean myBean;
Michaล Margiel
source share