2014-04-04 150 views
1

我目前有一個運行standalone-ha.xml的JBoss實例作爲配置文件。 JBoss 7.1.1 Final。我在稱爲ClusterTest的.ear內部的名爲ClusterTestEJB的.jar中部署了一個基本的HelloBean。JBoss集羣EJB Remoting

爲helloBean:

package com.sample; 

import javax.ejb.Remote; 
import javax.ejb.Stateless; 

import org.jboss.ejb3.annotation.Clustered; 

@Stateless 
@Clustered 
@Remote 
public class HelloBean implements HelloBeanItf { 
    int counter = 0; 
    public String doSomething() { 
    return "HelloBean Called"; 
    } 
} 

的HelloBeanItf如下:

package com.sample; 

public interface HelloBeanItf { 

    public String doSomething(); 

} 

我從一個教程,我下面的代碼。

所以我有一切似乎工作。我現在正在嘗試編寫一個Java客戶端來調用該EJB。下面是該代碼:

import java.util.Properties; 

import javax.naming.Context; 
import javax.naming.InitialContext; 
import javax.naming.NamingException; 

import com.sample.HelloBeanItf; 

public class Client { 
    public static void main(String[] args){ 

    Properties p = new Properties(); 
    p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory"); 
    p.put("jboss.naming.client.ejb.context", true); 
    p.put(Context.SECURITY_PRINCIPAL, "user"); 
    p.put(Context.SECURITY_CREDENTIALS, "password"); 
    p.put(Context.PROVIDER_URL, "remote://mynode:4447"); 

    InitialContext ctx; 
    try { 
     ctx = new InitialContext(p); 
    } catch (NamingException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
     return; 
    } 

    HelloBeanItf ejb = null; 
    try { 
     ejb = (HelloBeanItf) ctx.lookup("java:ClusterTest/ClusterTestEJB//HelloBean!com.sample.HelloBeanItf"); 
    } catch (NamingException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
     return; 
    } 

    for (int ii=0;ii<10;ii++) { 
     ejb.doSomething(); 
    } 
    System.out.println("Terminated"); 
    } 
} 

下面是客戶端的日誌輸出:

Bad level value for property: java.util.logging.ConsoleHandler.level 
Apr 03, 2014 10:49:30 PM org.jboss.logging.LoggerProviders find 
DEBUG: Logging Provider: org.jboss.logging.JDKLoggerProvider 
Apr 03, 2014 10:49:30 PM org.jboss.naming.remote.client.InitialContextFactory findClientProperties 
DEBUG: Looking for jboss-naming-client.properties using classloader [email protected] 
Apr 03, 2014 10:49:30 PM org.jboss.naming.remote.client.InitialContextFactory getOptionMapFromProperties 
DEBUG: jboss.naming.client.endpoint.create.options. has the following options {} 
Apr 03, 2014 10:49:30 PM org.jboss.naming.remote.client.InitialContextFactory getOptionMapFromProperties 
DEBUG: jboss.naming.client.remote.connectionprovider.create.options. has the following options {} 
Apr 03, 2014 10:49:30 PM org.xnio.Xnio <clinit> 
INFO: XNIO Version 3.0.3.GA 
Apr 03, 2014 10:49:30 PM org.xnio.nio.NioXnio <clinit> 
INFO: XNIO NIO Implementation Version 3.0.3.GA 
Apr 03, 2014 10:49:30 PM org.jboss.remoting3.EndpointImpl <clinit> 
INFO: JBoss Remoting version 3.2.3.GA 
Apr 03, 2014 10:49:30 PM org.xnio.nio.WorkerThread run 
DEBUG: Started channel thread 'Remoting "config-based-naming-client-endpoint" read-1', selector [email protected] 
Apr 03, 2014 10:49:30 PM org.xnio.nio.WorkerThread run 
DEBUG: Started channel thread 'Remoting "config-based-naming-client-endpoint" write-1', selector [email protected] 
Apr 03, 2014 10:49:30 PM org.jboss.naming.remote.client.InitialContextFactory getOptionMapFromProperties 
DEBUG: jboss.naming.client.connect.options. has the following options {} 
Apr 03, 2014 10:49:32 PM org.jboss.ejb.client.EJBClientPropertiesLoader loadEJBClientProperties 
DEBUG: Looking for jboss-ejb-client.properties using classloader [email protected] 
Apr 03, 2014 10:49:32 PM org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector <init> 
DEBUG: EJB client context [email protected] will have no EJB receivers associated with it since there was no EJB client configuration available to create the receivers 
Apr 03, 2014 10:49:32 PM org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver$1 handleDone 
DEBUG: Channel Channel ID 828f699b (outbound) of Remoting connection 0d818ff0 to node1-w7.wv-lab.mentorg.com/139.181.88.6:4447 opened for context EJBReceiverContext{[email protected], receiver=Remoting connection EJB receiver [connection=Remoting connection <6981170d>,channel=jboss.ejb,nodename=node1]} Waiting for version handshake message from server 
Apr 03, 2014 10:49:32 PM org.jboss.ejb.client.remoting.VersionReceiver handleMessage 
INFO: Received server version 1 and marshalling strategies [river] 
Apr 03, 2014 10:49:32 PM org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver associate 
INFO: Successful version handshake completed for receiver context EJBReceiverContext{[email protected], receiver=Remoting connection EJB receiver [connection=Remoting connection <6981170d>,channel=jboss.ejb,nodename=node1]} on channel Channel ID 828f699b (outbound) of Remoting connection 0d818ff0 to node1-w7.wv-lab.mentorg.com/139.181.88.6:4447 
Apr 03, 2014 10:49:32 PM org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver modulesAvailable 
DEBUG: Received module availability report for 3 modules 
Apr 03, 2014 10:49:32 PM org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver modulesAvailable 
DEBUG: Registering module EJBModuleIdentifier{appName='', moduleName='ClusterWebApp', distinctName=''} availability for receiver context EJBReceiverContext{[email protected], receiver=Remoting connection EJB receiver [connection=Remoting connection <6981170d>,channel=jboss.ejb,nodename=node1]} 
Apr 03, 2014 10:49:32 PM org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver modulesAvailable 
DEBUG: Registering module EJBModuleIdentifier{appName='ClusterTest', moduleName='ClusterTest', distinctName=''} availability for receiver context EJBReceiverContext{[email protected], receiver=Remoting connection EJB receiver [connection=Remoting connection <6981170d>,channel=jboss.ejb,nodename=node1]} 
Apr 03, 2014 10:49:32 PM org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver modulesAvailable 
DEBUG: Registering module EJBModuleIdentifier{appName='ClusterTest', moduleName='ClusterTestEJB', distinctName=''} availability for receiver context EJBReceiverContext{[email protected], receiver=Remoting connection EJB receiver [connection=Remoting connection <6981170d>,channel=jboss.ejb,nodename=node1]} 
Apr 03, 2014 10:49:32 PM org.jboss.ejb.client.remoting.ClusterNode resolveDestination 
DEBUG: Checking for a match of client address /fe80:0:0:0:0:5efe:ac1e:5010%14 with client mapping ClientMapping{sourceNetworkAddress=/0:0:0:0:0:0:0:0, sourceNetworkMaskBits=0, destinationAddress='139.181.88.6', destinationPort=4447} 
Apr 03, 2014 10:49:32 PM org.jboss.ejb.client.remoting.ClusterNode resolveDestination 
DEBUG: Client mapping ClientMapping{sourceNetworkAddress=/0:0:0:0:0:0:0:0, sourceNetworkMaskBits=0, destinationAddress='139.181.88.6', destinationPort=4447} matches client address /fe80:0:0:0:0:5efe:ac1e:5010%14 
Apr 03, 2014 10:49:32 PM org.jboss.ejb.client.remoting.ClusterTopologyMessageHandler processMessage 
DEBUG: Received a cluster node(s) addition message, for cluster named ejb with 1 nodes [ClusterNode{clusterName='ejb', nodeName='node1', clientMappings=[ClientMapping{sourceNetworkAddress=/0:0:0:0:0:0:0:0, sourceNetworkMaskBits=0, destinationAddress='139.181.88.6', destinationPort=4447}], resolvedDestination=[Destination address=139.181.88.6, destination port=4447]}] 
Apr 03, 2014 10:49:32 PM org.jboss.ejb.client.EJBClientContext getEJBReceiver 
DEBUG: [email protected] deployment node selector selected node1 node for appname=ClusterTest,modulename=ClusterTestEJB,distinctname= 
Apr 03, 2014 10:49:33 PM org.jboss.ejb.client.EJBClientContext getEJBReceiver 
DEBUG: [email protected] deployment node selector selected node1 node for appname=ClusterTest,modulename=ClusterTestEJB,distinctname= 
Apr 03, 2014 10:49:33 PM org.jboss.ejb.client.EJBClientContext getEJBReceiver 
DEBUG: [email protected] deployment node selector selected node1 node for appname=ClusterTest,modulename=ClusterTestEJB,distinctname= 
Apr 03, 2014 10:49:33 PM org.jboss.remoting3.remote.ClientConnectionOpenListener$Authentication$1 run 
DEBUG: Client authentication failed for mechanism DIGEST-MD5: javax.security.sasl.SaslException: DIGEST-MD5: Cannot perform callback to acquire realm, authentication ID or password [Caused by javax.security.auth.callback.UnsupportedCallbackException] 
Apr 03, 2014 10:49:33 PM org.jboss.ejb.client.EJBClientContext getEJBReceiver 
DEBUG: [email protected] deployment node selector selected node1 node for appname=ClusterTest,modulename=ClusterTestEJB,distinctname= 
Apr 03, 2014 10:49:33 PM org.jboss.remoting3.remote.RemoteConnection handleException 
ERROR: JBREM000200: Remote connection failed: javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed 
Apr 03, 2014 10:49:33 PM org.jboss.ejb.client.remoting.RemotingConnectionClusterNodeManager getEJBReceiver 
INFO: Could not create a connection for cluster node ClusterNode{clusterName='ejb', nodeName='node1', clientMappings=[ClientMapping{sourceNetworkAddress=/0:0:0:0:0:0:0:0, sourceNetworkMaskBits=0, destinationAddress='139.181.88.6', destinationPort=4447}], resolvedDestination=[Destination address=139.181.88.6, destination port=4447]} in cluster ejb 
java.lang.RuntimeException: javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed 
    at org.jboss.ejb.client.remoting.IoFutureHelper.get(IoFutureHelper.java:91) 
    at org.jboss.ejb.client.remoting.RemotingConnectionClusterNodeManager.getEJBReceiver(RemotingConnectionClusterNodeManager.java:117) 
    at org.jboss.ejb.client.ClusterContext$EJBReceiverAssociationTask.run(ClusterContext.java:333) 
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) 
    at java.util.concurrent.FutureTask.run(Unknown Source) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) 
    at java.lang.Thread.run(Unknown Source) 
Caused by: javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed 
    at org.jboss.remoting3.remote.ClientConnectionOpenListener$Capabilities.handleEvent(ClientConnectionOpenListener.java:365) 
    at org.jboss.remoting3.remote.ClientConnectionOpenListener$Capabilities.handleEvent(ClientConnectionOpenListener.java:214) 
    at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:72) 
    at org.xnio.channels.TranslatingSuspendableChannel.handleReadable(TranslatingSuspendableChannel.java:189) 
    at org.xnio.channels.TranslatingSuspendableChannel$1.handleEvent(TranslatingSuspendableChannel.java:103) 
    at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:72) 
    at org.xnio.nio.NioHandle.run(NioHandle.java:90) 
    at org.xnio.nio.WorkerThread.run(WorkerThread.java:184) 
    at ...asynchronous invocation...(Unknown Source) 
    at org.jboss.remoting3.EndpointImpl.doConnect(EndpointImpl.java:270) 
    at org.jboss.remoting3.EndpointImpl.doConnect(EndpointImpl.java:251) 
    at org.jboss.remoting3.EndpointImpl.connect(EndpointImpl.java:349) 
    at org.jboss.remoting3.EndpointImpl.connect(EndpointImpl.java:333) 
    at org.jboss.ejb.client.remoting.RemotingConnectionClusterNodeManager.getEJBReceiver(RemotingConnectionClusterNodeManager.java:115) 
    ... 6 more 

Apr 03, 2014 10:49:33 PM org.jboss.ejb.client.EJBClientContext getEJBReceiver 
DEBUG: [email protected] deployment node selector selected node1 node for appname=ClusterTest,modulename=ClusterTestEJB,distinctname= 
Apr 03, 2014 10:49:33 PM org.jboss.ejb.client.EJBClientContext getEJBReceiver 
DEBUG: [email protected] deployment node selector selected node1 node for appname=ClusterTest,modulename=ClusterTestEJB,distinctname= 
Apr 03, 2014 10:49:33 PM org.jboss.ejb.client.EJBClientContext getEJBReceiver 
DEBUG: [email protected] deployment node selector selected node1 node for appname=ClusterTest,modulename=ClusterTestEJB,distinctname= 
Apr 03, 2014 10:49:34 PM org.jboss.ejb.client.EJBClientContext getEJBReceiver 
DEBUG: [email protected] deployment node selector selected node1 node for appname=ClusterTest,modulename=ClusterTestEJB,distinctname= 
Apr 03, 2014 10:49:34 PM org.jboss.ejb.client.EJBClientContext getEJBReceiver 
DEBUG: [email protected] deployment node selector selected node1 node for appname=ClusterTest,modulename=ClusterTestEJB,distinctname= 
Apr 03, 2014 10:49:34 PM org.jboss.ejb.client.EJBClientContext getEJBReceiver 
DEBUG: [email protected] deployment node selector selected node1 node for appname=ClusterTest,modulename=ClusterTestEJB,distinctname= 
Terminated 

我曾嘗試以下:

卸下遠程安全領域,刪除用戶名和密碼。我不確定在這一點上還有什麼其他的嘗試。

首次海報,所以讓我知道是否需要更多的細節,或者如果你有問題。

感謝您的幫助!

回答

1

爲了記錄,無法執行EJB是通過從7.1.1升級來解決的。到7.1.3。升級之後,我仍然收到SASL異常,但是EJB成功執行。

通過切換到使用ejb-client而不是遠程命名庫並添加集羣屬性來解決SASL異常。遠程命名無論如何都不會進行負載平衡,所以交換機對我來說是必要的。