WebLogic上不同JVM / Server上的远程EJB注入

时间:2014-02-28 07:31:22

标签: java-ee weblogic ejb-3.0 java-ee-6

不同的WebLogic服务器上有两个ear应用程序:

1)app1.ear

2)app2.ear

问题是如何将app2.ear中定义的bean注入app1.ear中定义的bean? 我应该在ejb-jar.xml和weblogic-jar.xml中编写配置吗?如果是,怎么样?

我在app1部分写了这样的东西(UserService在app2中定义):

<weblogic-enterprise-bean>
    <ejb-name>UserManagementServiceRemote</ejb-name>
    <ejb-reference-description>
        <ejb-ref-name>tadUserService</ejb-ref-name>
        <jndi-name>t3://192.168.137.99:7001/UserService#com.abc.remote.UserService</jndi-name>
    </ejb-reference-description>
</weblogic-enterprise-bean>

在app1中它以这种方式注入:

@Stateless(name = "UserManagementService", mappedName = "UserManagementService")
public class UserManagementServiceImpl implements UserManagementServiceLocal, UserManagementServiceRemote, Serializable {

@EJB(name = "tadUserService")
private UserService tadUserService;
.
.
.

但它不起作用。 WebLogic说:

Caused By: weblogic.application.naming.ReferenceResolutionException: [J2EE:160200]Error resolving ejb-ref "tadUserService" from module "tps-business-14.1.2.jar" of application "_appsdir_tps-ear-14.1.2_ear". 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.transwide.twadmin.business.uma.remote.UserService" interface. Link or map this ejb-ref to its target EJB and ensure the interfaces declared in the ejb-ref are correct.

任何帮助都将不胜感激。

1 个答案:

答案 0 :(得分:0)

您可以使用服务 - &gt;外部JNDI提供程序菜单项到WebLogic控制台中,用于将远程服务器JNDI区域添加到WebLogic中。然后,您可以从该服务器查找远程bean作为本地bean。尝试使用JNDI查找,而不是@EJB注入。