EJB客户端中的通信失败

时间:2018-06-11 07:13:09

标签: java eclipse jndi ejb-3.0 weblogic12c

我正在尝试在应用程序服务器之外构建EJB客户端以访问WebLogic Server中的EJB,但是当我运行客户端应用程序时,我遇到了通信故障。尝试谷歌这个问题,但有关此问题的细节很少,大多数建议是检查WLS是否已启动并运行但似乎我的问题不同,因为即使我的应用程序服务器正在运行,我仍然遇到通信问题。< / p>

我希望你能帮我。请参阅下面我在运行EJB应用程序时遇到的异常以及我的Java代码。

遇到异常:

jake@JAKE-ASUS-K55A MINGW64 ~/Desktop
$ java -jar test.jar
Jun 11, 2018 1:10:49 PM com.sun.corba.se.impl.legacy.connection.SocketFactoryConnectionImpl <init>
WARNING: "IOP00410201: (COMM_FAILURE) Connection failure: socketType: IIOP_CLEAR_TEXT; hostname: 127.0.0.1; port: 7001"
org.omg.CORBA.COMM_FAILURE:   vmcid: SUN  minor code: 201  completed: No
        at com.sun.corba.se.impl.logging.ORBUtilSystemException.connectFailure(ORBUtilSystemException.java:2200)
        at com.sun.corba.se.impl.logging.ORBUtilSystemException.connectFailure(ORBUtilSystemException.java:2221)
        at com.sun.corba.se.impl.legacy.connection.SocketFactoryConnectionImpl.<init>(SocketFactoryConnectionImpl.java:91)
        at com.sun.corba.se.impl.legacy.connection.SocketFactoryContactInfoImpl.createConnection(SocketFactoryContactInfoImpl.java:92)
        at com.sun.corba.se.impl.protocol.CorbaClientRequestDispatcherImpl.beginRequest(CorbaClientRequestDispatcherImpl.java:187)
        at com.sun.corba.se.impl.protocol.CorbaClientDelegateImpl.request(CorbaClientDelegateImpl.java:137)
        at com.sun.corba.se.impl.resolver.BootstrapResolverImpl.invoke(BootstrapResolverImpl.java:99)
        at com.sun.corba.se.impl.resolver.BootstrapResolverImpl.resolve(BootstrapResolverImpl.java:132)
        at com.sun.corba.se.impl.resolver.CompositeResolverImpl.resolve(CompositeResolverImpl.java:47)
        at com.sun.corba.se.impl.resolver.CompositeResolverImpl.resolve(CompositeResolverImpl.java:47)
        at com.sun.corba.se.impl.resolver.CompositeResolverImpl.resolve(CompositeResolverImpl.java:47)
        at com.sun.corba.se.impl.orb.ORBImpl.resolve_initial_references(ORBImpl.java:1169)
        at weblogic.corba.j2ee.naming.ORBHelper$InitialReferenceResolution.getInitialReference(ORBHelper.java:582)
        at weblogic.corba.j2ee.naming.ORBHelper$InitialReferenceResolution.getInitialReferenceForNewOrb(ORBHelper.java:577)
        at weblogic.corba.j2ee.naming.ORBHelper$InitialReferenceResolution.getInitialReferenceForEndPoint(ORBHelper.java:564)
        at weblogic.corba.j2ee.naming.ORBHelper$InitialReferenceResolution.invoke(ORBHelper.java:546)
        at weblogic.corba.j2ee.naming.ORBHelper.getORBInitialReference(ORBHelper.java:410)
        at weblogic.corba.j2ee.naming.InitialContextFactoryImpl.getRemoteNameService(InitialContextFactoryImpl.java:105)
        at weblogic.corba.j2ee.naming.InitialContextFactoryImpl.getInitialContext(InitialContextFactoryImpl.java:68)
        at weblogic.corba.j2ee.naming.InitialContextFactoryImpl.getInitialContext(InitialContextFactoryImpl.java:32)
        at weblogic.jndi.WLInitialContextFactory.getInitialContext(WLInitialContextFactory.java:46)
        at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:684)
        at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:313)
        at javax.naming.InitialContext.init(InitialContext.java:244)
        at javax.naming.InitialContext.<init>(InitialContext.java:216)
        at com.jake.bagain.TestEJB.main(TestEJB.java:16)
Caused by: java.net.ProtocolException: Tunneling result unspecified - is the HTTP server at host: '127.0.0.1' and port: '7001' a WebLogic Server?
        at weblogic.corba.client.http.TunneledSocketImpl.throwProtocolException(TunneledSocketImpl.java:525)
        at weblogic.corba.client.http.TunneledSocketImpl.connectInternal(TunneledSocketImpl.java:245)
        at weblogic.corba.client.iiop.BiDirSocketImpl.connect(BiDirSocketImpl.java:355)
        at weblogic.corba.client.iiop.BiDirSocketImpl.connect(BiDirSocketImpl.java:139)
        at weblogic.corba.client.http.TunneledSocketImpl.connect(TunneledSocketImpl.java:338)
        at java.net.Socket.connect(Socket.java:589)
        at java.net.Socket.connect(Socket.java:538)
        at weblogic.corba.client.iiop.BiDirSocket.<init>(BiDirSocket.java:22)
        at weblogic.corba.client.http.TunneledSocket.<init>(TunneledSocket.java:20)
        at weblogic.corba.client.http.TunneledSocketFactory.createSocket(TunneledSocketFactory.java:95)
        at weblogic.corba.client.jdkorb.JdkBiDirORBSocketFactory.createSocket(JdkBiDirORBSocketFactory.java:41)
        at com.sun.corba.se.impl.legacy.connection.SocketFactoryConnectionImpl.<init>(SocketFactoryConnectionImpl.java:74)
        ... 23 more

远程接口:

package com.jake.mine;

import javax.ejb.Remote;

@Remote
public interface CalculatorRemote {

    int add(int x, int y);
}

实施班级:

package com.jake.bagain;

import javax.ejb.Stateless;

@Stateless(mappedName="ejb/calc")
public class CalculatorRemoteImpl implements CalculatorRemote {

    public int add(int x, int y) {
        return x + y;
    }
}

测试类:

package com.jake.mine;

import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.InitialContext;

public class TestEJB {

   public static void main(String[] args)  {
        try {
            Hashtable ht = new Hashtable();
            ht.put(Context.INITIAL_CONTEXT_FACTORY, 
"weblogic.jndi.WLInitialContextFactory");
            ht.put(Context.PROVIDER_URL, "http://localhost:7001");

            Context context = new InitialContext(ht);
            CalculatorRemote remote = 
(CalculatorRemote)context.lookup("ejb.calc#com.jake.mine.CalculatorRemote");
            System.out.println(remote.add(100, 100));
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}

这是我在Eclipse中的项目构建路径:

Java Build Path

这是我的WLS JNDI树看起来像:

WLS JNDI

0 个答案:

没有答案