简体   繁体   English

从Tomcat Web应用程序调用在Weblogic上部署的远程Ejb bean

[英]Remote Ejb bean deployed on Weblogic called from Tomcat web application

I have created an remote EJB bean using EJB 3.1 and deployed it on web logic 12c. 我已经使用EJB 3.1创建了一个远程EJB bean,并将其部署在Web逻辑12c上。 Now through a simple java client I am able to access the remote bean. 现在,通过一个简单的Java客户端,我可以访问远程bean。 It is working fine. 一切正常。

Java Client Code: Java客户端代码:

Context ctx = null;
          Hashtable ht = new Hashtable();
          ht.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory"); 
          ht.put(Context.PROVIDER_URL, "t3://localhost:7001");
        try {
            InitialContext ic = new InitialContext(ht);

}

My next approach is to call this remote bean in a web application that is deployed in Tomcat 7. But it is throwing exception 我的下一个方法是在Tomcat 7中部署的Web应用程序中调用此远程bean。

Caused by: java.lang.ClassNotFoundException: weblogic.jndi.WLInitialContextFactory. 引起原因:java.lang.ClassNotFoundException:weblogic.jndi.WLInitialContextFactory。

I am using the following code to call the ejb bean : Properties properties = new Properties(); 我正在使用以下代码来调用ejb bean:Properties properties = new Properties();

        properties.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
        properties.put("java.naming.factory.url.pkgs", "weblogic.jndi.factories:weblogic.corba.j2ee.naming.url");
        properties.put(Context.PROVIDER_URL, "t3://localhost:7001");
        properties.put( Context.SECURITY_PRINCIPAL, "weblogic");  
        properties.put( Context.SECURITY_CREDENTIALS, "weblogic1");
        try {
          Context ic = new InitialContext(properties); 
}

What to do to make it work. 如何使其正常工作。

Thanks 谢谢

You should have either the wlthint3client.jar or the wlfullclient.jar on your web application classpath. 您应该在Web应用程序类路径上具有wlthint3client.jar或wlfullclient.jar。 Both are available from weblogic distributions. 两者都可以从weblogic发行版中获得。

More information on their usage can be found here 有关其用法的更多信息,请参见此处

Work for me adding wlclient.jar and wlthint3client.jar (in this order) on classpath. 为我工作,在类路径上添加wlclient.jar wlthint3client.jar(按此顺序)。

In my case I was trying to invoke EJB from the test class. 就我而言,我试图从测试类中调用EJB。 To get the instance I did this way: 为了获得实例,我这样做:

weblogic.ejb.spi.BusinessObject obj = (weblogic.ejb.spi.BusinessObject) context.lookup("MyEJBRemoteMappedName#br.com.ejbclient.MyEJBRemote");
br.com.ejbclient.MyEJBRemote myEJB = (br.com.ejbclient.MyEJBRemote) obj._WL_getBusinessObjectHandle().getBusinessObject();

I'm using wls12130. 我正在使用wls12130。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM