有一个带有最旧 EJB 的遗留代码库,其中所有现有的 EJBS 都在ejb-jar.xml
<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>ABean</ejb-name>
<home>com.bla.api.RemoteBeanHome</home>
<remote>com.bla.api.RemoteBean</remote>
<ejb-class>com.bla.api.ABean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
....
这通过通过 JNDI 进行搜索来工作。但是,服务器已升级到支持Java EE 7的Weblogic 12.2。因此,当向远程会话 bean注入新的本地 EJB时,我想只使用注释,而不触及现有的 XML 部署描述符。ABean
@EJB
但是,有以下错误:
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.bla.api.NewBean" interface. Link or map this ejb-ref to its target EJB
and ensure the interfaces declared in the ejb-ref are correct.
新的本地无状态 ejb 代码如下:
@Stateless
public class TestEJB {
public void test() {
System.out.println("I am the first EJB injected with CDI");
}
}
问题:在这种情况下,是否仍然可以使用注释而不是添加新的 EJB ejb-jar.xml
?