Please excuse this beginner's question but what bothers me last few days is:
I have ejb project. In the same package i have plain Java class as well as session bean, which uses JPA entityManager to persist data.
Now my question is, is it possible to call that session bean inside of "plain" Java class? I know i can't use annotation. Trying to get bean with context lookup method has gave me headacke only so far...Please any suggestions would be appreciated.
If you are outside of the container (or create an object yourself) then the only way is the JNDI lookup. In EJB 3.x it shouldn't be that painful since the JNDI names have been standardized under java:global namespace.
I suppose the method mentioned by Hebert Coelho would work for JSF ManagedBeans but not for EJBs.
Thank you both for fast replies. I have some questions tough.
How do i know my bean's JNDI name?
Does it matter that i use WebSphere application server?
Do i have to call bean by remote interface?
I have no problem in calling this bean from managed bean in JSF project, it has defined ej-local-ref in web.xml.
In a lookup i use java:comp/env
Do i need to define something similar in ejb-jar? Because i have no problem at current configuration to inject beans in one another.
If i try global lookup i get error
javax.naming.NameNotFoundException: Name global not found in context "java:"