I have a legacy project with EJBs, where they are configured in ejb-jar.xml, like so:
<ejb-jar xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.1">
<session>
<ejb-name>MyBean</ejb-name>
<home>com.abby.api.RemoteBeanHome</home>
<remote>com.abby.api.RemoteBean</remote>
<ejb-class>com.abby.api.MyBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
....
This works by means of looking up the JNDI tree. However, the server was upgraded to Weblogic 12.2, where Java EE 7 is supported. So when injecting new local EJB to the remote session bean, MyBean, I am thinking of using merely the annotation, @EJB, without touching the existing XML deployment descriptor.
However, I get the following error:
The ejb-ref does not have an ejb-link and the JNDI name of the target bean has
not been specified. Attempts to automatically link the ejb-ref to its target
bean failed because no EJBs in the application were found to implement the
"com.abby.api.NewBean" interface. Link or map this ejb-ref to its target EJB
and ensure the interfaces declared in the ejb-ref are correct.
The new local stateless ejb code is the following:
@Stateless
public class TestEJB {
public void test() {
LOGGER.debug("I am the first EJB injected with CDI");
}
}
My question is: In this case, is it still possible to add new EJBs with annotations instead of ejb-jar.xml?