1

hello world 示例工作,我可以做些什么tleilax来允许doge连接到本地运行的 OpenEJB 服务器?我已经阅读了有关如何启动 OpenEJB 的文档,但必须从手册中遗漏一个步骤。

tleilax,部署Hello.jar

thufir@tleilax:~$ openejb deploy Hello.jar 
Mar 07, 2015 10:34:30 PM org.apache.openejb.client.EventLogger log
INFO: RemoteInitialContextCreated{providerUri=ejbd://localhost:4201}
Mar 07, 2015 10:34:31 PM org.apache.openejb.client.EventLogger log
INFO: ConnectionOpened{uri=ejbd://localhost:4201}
Mar 07, 2015 10:34:31 PM org.apache.openejb.client.EventLogger log
INFO: ServerAdded{server=ejbds://127.0.0.1:4203} ClusterMetaDataUpdated{provider=ejbd://localhost:4201, version=1425796337772, uris=2}
Mar 07, 2015 10:34:31 PM org.apache.openejb.client.EventLogger log
INFO: ServerAdded{server=ejbd://127.0.0.1:4201} ClusterMetaDataUpdated{provider=ejbd://localhost:4201, version=1425796337772, uris=2}
Mar 07, 2015 10:34:31 PM org.apache.openejb.client.EventLogger log
INFO: ServerRemoved{server=ejbd://localhost:4201} ClusterMetaDataUpdated{provider=ejbd://localhost:4201, version=1425796337772, uris=2}
Application deployed successfully at "Hello.jar"
App(id=/home/thufir/apache-openejb-4.7.1/apps/Hello.jar)
    EjbJar(id=Hello, path=/home/thufir/apache-openejb-4.7.1/apps/Hello.jar)
        Ejb(ejb-name=HelloBean, id=HelloBean)
            Jndi(name=HelloBeanRemote)
            Jndi(name=global/Hello/HelloBean!org.acme.Hello)
            Jndi(name=global/Hello/HelloBean)

tleilaxopenejb 的一些输出显示了部署:

INFO: OpenWebBeans Container has started, it took 241 ms.
Mar 07, 2015 10:34:32 PM org.apache.openejb.assembler.classic.Assembler startEjbs
INFO: Created Ejb(deployment-id=HelloBean, ejb-name=HelloBean, container=My Stateless Container)
Mar 07, 2015 10:34:32 PM org.apache.openejb.assembler.classic.Assembler startEjbs
INFO: Started Ejb(deployment-id=HelloBean, ejb-name=HelloBean, container=My Stateless Container)
Mar 07, 2015 10:34:32 PM org.apache.openejb.assembler.classic.Assembler createApplication
INFO: Deployed Application(path=/home/thufir/apache-openejb-4.7.1/apps/Hello.jar)

扫描tleilax开放端口:

thufir@doge:~$ 
thufir@doge:~$ nmap 192.168.1.3

Starting Nmap 6.46 ( http://nmap.org ) at 2015-03-07 22:42 PST
Nmap scan report for 192.168.1.3
Host is up (0.00092s latency).
Not shown: 998 closed ports
PORT    STATE SERVICE
22/tcp  open  ssh
119/tcp open  nntp

Nmap done: 1 IP address (1 host up) scanned in 0.06 seconds
thufir@doge:~$ 

绑定服务tleilax

Mar 07, 2015 10:32:17 PM org.apache.openejb.server.SimpleServiceManager start
INFO:   ** Bound Services **
Mar 07, 2015 10:32:17 PM org.apache.openejb.server.SimpleServiceManager printRow
INFO:   NAME                 IP              PORT  
Mar 07, 2015 10:32:17 PM org.apache.openejb.server.SimpleServiceManager printRow
INFO:   httpejbd             127.0.0.1       4204  
Mar 07, 2015 10:32:17 PM org.apache.openejb.server.SimpleServiceManager printRow
INFO:   multipoint           127.0.0.1       4212  
Mar 07, 2015 10:32:17 PM org.apache.openejb.server.SimpleServiceManager printRow
INFO:   admin                127.0.0.1       4200  
Mar 07, 2015 10:32:17 PM org.apache.openejb.server.SimpleServiceManager printRow
INFO:   ejbd                 127.0.0.1       4201  
Mar 07, 2015 10:32:17 PM org.apache.openejb.server.SimpleServiceManager printRow
INFO:   multicast            239.255.2.3     6142  
Mar 07, 2015 10:32:17 PM org.apache.openejb.server.SimpleServiceManager printRow
INFO:   ejbds                127.0.0.1       4203  
Mar 07, 2015 10:32:17 PM org.apache.openejb.server.SimpleServiceManager printRow
INFO:   multipulse           239.255.2.3     6142  
Mar 07, 2015 10:32:17 PM org.apache.openejb.server.SimpleServiceManager start
INFO: -------
Mar 07, 2015 10:32:17 PM org.apache.openejb.server.SimpleServiceManager start
INFO: Ready!

因此,服务器已准备就绪tleilax。为什么客户端无法正常连接?

thufir@doge:~$ 
thufir@doge:~$ java -classpath .:NetBeansProjects/HelloClient/dist/HelloClient.jar:apache-openejb-4.7.1/lib/openejb-client-4.7.1.jar:netbeans-8.0.2/enterprise/modules/ext/javaee-api-7.0.jar org.acme.HelloClient 
Mar 07, 2015 10:49:46 PM org.apache.openejb.client.EventLogger log
INFO: RemoteInitialContextCreated{providerUri=ejbd://192.168.1.3:4201}
Mar 07, 2015 10:49:46 PM org.apache.openejb.client.EventLogger log
WARNING: ConnectionFailed{uri=ejbd://192.168.1.3:4201 cause=java.io.IOException: Cannot connect to server 'ejbd://192.168.1.3:4201'.  Check that the server is started and that the specified serverURL is correct.}
Mar 07, 2015 10:49:46 PM org.apache.openejb.client.EventLogger log
WARNING: BootstrappingConnection{provider=ejbd://192.168.1.3:4201}
Mar 07, 2015 10:49:46 PM org.apache.openejb.client.EventLogger log
WARNING: ConnectionFailed{uri=ejbd://192.168.1.3:4201 cause=java.io.IOException: Cannot connect to server 'ejbd://192.168.1.3:4201'.  Check that the server is started and that the specified serverURL is correct.}
Mar 07, 2015 10:49:46 PM org.apache.openejb.client.EventLogger log
SEVERE: ConnectionStrategyFailed{strategy=StickyConnectionStrategy, cluster=org.apache.openejb.client.ClusterMetaData@7d261f7f, server=ejbd://192.168.1.3:4201}
Exception in thread "main" javax.naming.NamingException: Cannot lookup '/HelloBeanRemote'. [Root exception is java.rmi.RemoteException: Unable to connect; nested exception is: 
    java.io.IOException: Cannot connect to server 'ejbd://192.168.1.3:4201'.  Check that the server is started and that the specified serverURL is correct.]
    at org.apache.openejb.client.JNDIContext.lookup(JNDIContext.java:405)
    at javax.naming.InitialContext.lookup(InitialContext.java:411)
    at org.acme.HelloClient.main(HelloClient.java:16)
Caused by: java.rmi.RemoteException: Unable to connect; nested exception is: 
    java.io.IOException: Cannot connect to server 'ejbd://192.168.1.3:4201'.  Check that the server is started and that the specified serverURL is correct.
    at org.apache.openejb.client.Client.processRequest(Client.java:167)
    at org.apache.openejb.client.Client.request(Client.java:141)
    at org.apache.openejb.client.JNDIContext.request(JNDIContext.java:211)
    at org.apache.openejb.client.JNDIContext.lookup(JNDIContext.java:399)
    ... 2 more
Caused by: java.io.IOException: Cannot connect to server 'ejbd://192.168.1.3:4201'.  Check that the server is started and that the specified serverURL is correct.
    at org.apache.openejb.client.SocketConnectionFactory$SocketConnection.failure(SocketConnectionFactory.java:334)
    at org.apache.openejb.client.SocketConnectionFactory$SocketConnection.open(SocketConnectionFactory.java:308)
    at org.apache.openejb.client.SocketConnectionFactory.getConnection(SocketConnectionFactory.java:162)
    at org.apache.openejb.client.ConnectionManager.getConnection(ConnectionManager.java:112)
    at org.apache.openejb.client.AbstractConnectionStrategy.connect(AbstractConnectionStrategy.java:105)
    at org.apache.openejb.client.AbstractConnectionStrategy.connect(AbstractConnectionStrategy.java:81)
    at org.apache.openejb.client.ConnectionManager.getConnection(ConnectionManager.java:88)
    at org.apache.openejb.client.Client.processRequest(Client.java:165)
    ... 5 more
Caused by: java.net.ConnectException: Connection refused
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:579)
    at org.apache.openejb.client.SocketConnectionFactory$SocketConnection.open(SocketConnectionFactory.java:300)
    ... 11 more
thufir@doge:~$ 
thufir@doge:~$ 

对于它的价值,我检查了HelloClient本地运行是否tleilax正常:

thufir@tleilax:~$ 
thufir@tleilax:~$ java -classpath .:HelloClient.jar:apache-openejb-4.7.1/lib/openejb-client-4.7.1.jar:netbeans-8.0.2/enterprise/modules/ext/javaee-api-7.0.jar org.acme.HelloClient
Mar 07, 2015 10:56:46 PM org.apache.openejb.client.EventLogger log
INFO: RemoteInitialContextCreated{providerUri=ejbd://127.0.0.1:4201}
Mar 07, 2015 10:56:46 PM org.apache.openejb.client.EventLogger log
INFO: ConnectionOpened{uri=ejbd://127.0.0.1:4201}
Mar 07, 2015 10:56:46 PM org.apache.openejb.client.EventLogger log
INFO: ServerAdded{server=ejbds://127.0.0.1:4203} ClusterMetaDataUpdated{provider=ejbd://127.0.0.1:4201, version=1425796337772, uris=2}
Hello World!!!!
thufir@tleilax:~$ 

当然,本地运行的客户端tleilax连接到 127.0.0.1,而客户端doge连接或尝试连接到 tleilax 的 IP 地址:192.168.1.3;示例中的 IP 地址是硬编码的。

4

0 回答 0