EJB3.1远程客户端代码无法与Jboss-eap-6.1.0

时间:2017-11-03 15:33:56

标签: ejb ejb-3.1 jboss-eap-6 ejb-3.2

我正在使用以下软件列表:

  • JDK1.7
  • JBoss的EAP-6.1.0
  • EJB3.1

我正在尝试调用EJB3会话bean方法但获得异常:

  

20:36:38,249 ERROR [org.jboss.remoting.remote.connection](远程处理“d-441003044”read-1)JBREM000200:远程连接失败:java.io.IOException:强制关闭现有连接远程主机

服务器控制台和类如下

20:44:42,196 INFO  [org.jboss.modules] (main) JBoss Modules version 1.2.0.Final-redhat-1
20:44:42,853 INFO  [org.jboss.msc] (main) JBoss MSC version 1.0.4.GA-redhat-1
20:44:42,963 INFO  [org.jboss.as] (MSC service thread 1-7) JBAS015899: JBoss EAP 6.1.0.GA (AS 7.2.0.Final-redhat-8) starting
20:44:44,447 INFO  [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS015003: Found EJBTest2.jar in deployment directory. To trigger deployment create a file called EJBTest2.jar.dodeploy
20:44:44,621 INFO  [org.xnio] (MSC service thread 1-4) XNIO Version 3.0.7.GA-redhat-1
20:44:45,265 INFO  [org.jboss.as.server] (Controller Boot Thread) JBAS015888: Creating http management service using socket-binding (management-http)
20:44:45,280 INFO  [org.xnio.nio] (MSC service thread 1-4) XNIO NIO Implementation Version 3.0.7.GA-redhat-1
20:44:46,934 INFO  [org.jboss.remoting] (MSC service thread 1-4) JBoss Remoting version 3.2.16.GA-redhat-1
20:44:47,047 INFO  [org.jboss.as.webservices] (ServerService Thread Pool -- 46) JBAS015537: Activating WebServices Extension
20:44:47,063 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 29) JBAS010280: Activating Infinispan subsystem.
20:44:47,063 INFO  [org.jboss.as.jsf] (ServerService Thread Pool -- 35) JBAS012605: Activated the following JSF Implementations: [main, 1.2]
20:44:47,063 INFO  [org.jboss.as.naming] (ServerService Thread Pool -- 37) JBAS011800: Activating Naming Subsystem
20:44:47,526 INFO  [org.jboss.as.security] (ServerService Thread Pool -- 42) JBAS013171: Activating Security Subsystem
20:44:47,557 INFO  [org.jboss.as.security] (MSC service thread 1-5) JBAS013170: Current PicketBox version=4.0.17.Final-redhat-1
20:44:47,557 INFO  [org.jboss.as.connector.logging] (MSC service thread 1-6) JBAS010408: Starting JCA Subsystem (IronJacamar 1.0.17.Final-redhat-1)
20:44:50,103 INFO  [org.jboss.ws.common.management] (MSC service thread 1-8) JBWS022052: Starting JBoss Web Services - Stack CXF Server 4.1.3.Final-redhat-3
20:44:50,370 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 25) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
20:44:50,402 INFO  [org.jboss.as.naming] (MSC service thread 1-5) JBAS011802: Starting Naming Service
20:44:50,402 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-2) JBAS015400: Bound mail session [java:jboss/mail/Default]
20:44:50,730 INFO  [org.apache.coyote.http11] (MSC service thread 1-8) JBWEB003001: Coyote HTTP/1.1 initializing on : http-localhost/127.0.0.1:8080
20:44:50,745 INFO  [org.apache.coyote.http11] (MSC service thread 1-8) JBWEB003000: Coyote HTTP/1.1 starting on: http-localhost/127.0.0.1:8080
20:44:50,792 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-1) JBAS015012: Started FileSystemDeploymentService for directory D:\Installation\Jboss-eap-6.1.0\EAP-6.1.0\jboss-eap-6.1\standalone\deployments
20:44:50,808 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015876: Starting deployment of "EJBTest2.jar" (runtime-name: "EJBTest2.jar")
20:44:50,889 INFO  [org.jboss.as.remoting] (MSC service thread 1-7) JBAS017100: Listening on 127.0.0.1:9999
20:44:50,889 INFO  [org.jboss.as.remoting] (MSC service thread 1-8) JBAS017100: Listening on 127.0.0.1:4447
20:44:51,061 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-3) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]
20:44:51,170 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-1)

部署单元部署“EJBTest2.jar”中名为Test2的会话bean的JNDI绑定:

java:global/EJBTest2/Test2!com.Test2
java:app/EJBTest2/Test2!com.Test2
java:module/Test2!com.Test2
java:global/EJBTest2/Test2!com.Test2Remote
java:app/EJBTest2/Test2!com.Test2Remote
java:module/Test2!com.Test2Remote
java:jboss/exported/EJBTest2/Test2!com.Test2Remote

20:44:51,524 INFO  [org.jboss.as.server] (ServerService Thread Pool -- 26) JBAS018559: Deployed "EJBTest2.jar" (runtime-name : "EJBTest2.jar")
20:44:51,712 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015961: Http management interface listening on http://127.0.0.1:9990/management
20:44:51,712 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:9990
20:44:51,712 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015874: JBoss EAP 6.1.0.GA (AS 7.2.0.Final-redhat-8) started in 11531ms - Started 166 of 222 services (55 services are passive or on-demand)

Test2.java

package com;

import javax.ejb.LocalBean;
import javax.ejb.Stateless;

@Stateless(name="Test2" ,mappedName="Test2")
@LocalBean
public class Test2 implements Test2Remote {

    /**
     * Default constructor. 
     */
    public Test2() 
    {
        // TODO Auto-generated constructor stub
    }

    @Override
    public String getName(String name) 
    {
        // TODO Auto-generated method stub
        return "Hello :"+name;
    }

}

Test2Remote.java

package com;

import javax.ejb.Remote;

@Remote
public interface Test2Remote
{
    public String getName(String name);
}

Test2Client.java

package com;
import java.util.Properties;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
public class Test2Client 
{

    public static void main(String[] args) throws Exception
    {

         Context ctx = getInitialContext();



        //  Ejb3BeanRemote hello =(Ejb3BeanRemote) ctx.lookup("java:app/TEST/Ejb3Bean!com.ejb3.Ejb3BeanRemote");
            Test2Remote hello =(Test2Remote) ctx.lookup("ejb:/EJBTest2/Test2!com.Test2Remote");
        //  Test2Remote hello = (Test2Remote) ctx.lookup(" java:module/Test2!com.Test2Remote");
            System.out.println(hello.getName("TEST"));
    }

        private static Context getInitialContext() throws NamingException 
        {
            Properties p = new Properties();
            p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
            p.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
            p.put(Context.PROVIDER_URL, "localhost:4447");
            p.put(Context.SECURITY_PRINCIPAL, "test");
            p.put(Context.SECURITY_CREDENTIALS, "test123");
            System.out.println(p);

        //  Context ctx = new InitialContext(jndiProps);
            return new javax.naming.InitialContext(p);
        }


}

如何编写远程客户端代码?

0 个答案:

没有答案