Accessing EJB3 through mod_cluster
bibhunayak Jun 11, 2014 7:40 AMHi,
In standalone mode i have 3 nodes out of which 2 nodes are in cluster.Node1 and Node2 have stateless EJB and Node3 has client to access the clustered EJB.
mod_cluster loadbalancer is installed on Apache httpd server.
My requirement is from node3 i will send the request to load balancer and load balancer should forward the request to either Node1 and Node2.
Current configurations are :
jboss-ejb-client.properties
endpoint.name=client-endpoint
remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false
invocation.timeout=3000
reconnect.tasks.timeout=2000
remote.connections=node1,node2
remote.connection.node1.host=127.0.0.1
remote.connection.node1.port=4547
remote.connection.node1.username=test
remote.connection.node1.password=test123
remote.connection.node1.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
remote.connection.node1.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT=false
remote.connection.node1.connect.options.org.xnio.Options.SASL_DISALLOWED_MECHANISMS=${host.auth:JBOSS-LOCAL-USER}
remote.connection.node2.host=127.0.0.1
remote.connection.node2.port=4647
remote.connection.node2.username=test
remote.connection.node2.password=test123
remote.connection.node2.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
remote.connection.node2.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT=false
remote.connection.node2.connect.options.org.xnio.Options.SASL_DISALLOWED_MECHANISMS=${host.auth:JBOSS-LOCAL-USER}
remote.clusters=ejb
remote.cluster.ejb.clusternode.selector=org.jboss.ejb.client.RandomClusterNodeSelector
remote.cluster.ejb.connect.timeout=2500
remote.cluster.ejb.max-allowed-connected-nodes=2
remote.cluster.ejb.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
remote.cluster.ejb.connect.options.org.xnio.Options.SSL_ENABLED=false
remote.cluster.ejb.username=test
remote.cluster.ejb.password=test123
Below is the code snipet used for EJBClientContext and JNDI context
//setting EJBClientContext
System.out.println("EJBClient context setup startrd****************************"); Properties properties = new Properties(); properties.put("endpoint.name", "client-endpoint"); properties.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false"); properties.put("remote.connections", "node1"); properties.put("remote.connection.node1.host", "127.0.0.1"); properties.put("remote.connection.node1.port", "4547"); //properties.put("remote.connection.node1.username", "test"); //properties.put("remote.connection.node1.password", "test123"); properties.put("remote.connection.node1.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS", "false"); PropertiesBasedEJBClientConfiguration configuration = new PropertiesBasedEJBClientConfiguration(properties); final ContextSelector<EJBClientContext> ejbClientContextSelector = new ConfigBasedEJBClientContextSelector(configuration); final ContextSelector<EJBClientContext> previousSelector = EJBClientContext.setSelector(ejbClientContextSelector); System.out.println("EJBClientContext setup ended**********************************"); //setting JNDI Context System.out.println("JNDI conext setup started*************************************"); Properties jndiProperties = new Properties(); jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming"); jndiProperties.put("jboss.naming.client.ejb.context", true); //properties.put("remote.connection.node1.username", "test"); //properties.put("remote.connection.node1.password", "test123"); context = new InitialContext(jndiProperties); System.out.println("JNDI context setup ended****************************************"); return context;
And mod_cluster is listening to this IPs Listen 127.0.0.1:6666 and Listen 127.0.0.1:80.
If all the 3 nodes are in cluster i am able to access EJB3 through mod_cluster.
Below is the exception trace i got while accessing the client from node3
09:32:52,478 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/LoadBalanceEJBClient].[com.test.client.LoadBalanceServlet]] (http--127.0.0.1-8380-1) Servlet.service() for servlet com.test.client.LoadBalanceServlet threw exception: java.lang.IllegalStateException: No EJB receiver available for handling [appName:,modulename:LoadBalanceEJB,distinctname:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@78624930
at org.jboss.ejb.client.EJBClientContext.requireEJBReceiver(EJBClientContext.java:584) [jboss-client.jar:7.1.1.Final]
at org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:119) [jboss-client.jar:7.1.1.Final]
at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:181) [jboss-client.jar:7.1.1.Final]
at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:136) [jboss-client.jar:7.1.1.Final]
at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:121) [jboss-client.jar:7.1.1.Final]
at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:104) [jboss-client.jar:7.1.1.Final]
at $Proxy35.getNodeName(Unknown Source) at com.test.client.LoadBalanceServlet.doGet(LoadBalanceServlet.java:41) [classes:]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:734) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.13.Final.jar:]
at org.jboss.modcluster.container.jbossweb.JBossWebContext$RequestListenerValve.event(JBossWebContext.java:67)
at org.jboss.modcluster.container.jbossweb.JBossWebContext$RequestListenerValve.invoke(JBossWebContext.java:48)
at org.jboss.as.web.session.ClusteredSessionValve.handleRequest(ClusteredSessionValve.java:125) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.web.session.ClusteredSessionValve.invoke(ClusteredSessionValve.java:91) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.web.session.JvmRouteValve.invoke(JvmRouteValve.java:88) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.web.session.LockingValve.invoke(LockingValve.java:56) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:]
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.13.Final.jar:]
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.13.Final.jar:]
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.13.Final.jar:]
at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_09]
Please help me in resolving the issue....