Failover does not work properly in remote-naming when lookup remote ejb
zhouyaguo Mar 27, 2014 3:06 AMHi,
I'm using JBoss AS 7.2.0.Final.
I deployed myejb.jar in two standalone AS7 instance and i write a client testcase as following:
public class TestRemoteNaming { public static void main(String[] args) { int count = 0; while (true) { try { Properties props = new Properties(); props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory"); props.put(Context.PROVIDER_URL, "remote://172.17.252.66:31003,remote://172.17.252.63:31003"); props.put("jboss.naming.client.ejb.context", true); InitialContext ctx = new InitialContext(props); Object ob = ctx.lookup("cuam-ear/param-core/ParaSyncService!com.unionpay.param.core.sync.ParaSyncService"); } catch (Exception e) { e.printStackTrace(); count++; System.out.println("count==" + count); } } } }
What i expect is no exception occur, I think remote-naming will do failover inside lookup method, but console prints :
count==1 at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:103) at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:197) at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:174) at org.jboss.naming.remote.protocol.v1.Protocol$1.handleServerMessage(Protocol.java:127) at org.jboss.naming.remote.protocol.v1.RemoteNamingServerV1$MessageReciever$1.run(RemoteNamingServerV1.java:73) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:897) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:919) at java.lang.Thread.run(Thread.java:736) javax.naming.NameNotFoundException: cuam-ear/param-core/ParaSyncService!com.unionpay.param.core.sync.ParaSyncService -- service jboss.naming.context.java.jboss.exported.cuam-ear.param-core."ParaSyncService!com.unionpay.param.core.sync.ParaSyncService" at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:103) at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:197) at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:174) at org.jboss.naming.remote.protocol.v1.Protocol$1.handleServerMessage(Protocol.java:127) at org.jboss.naming.remote.protocol.v1.RemoteNamingServerV1$MessageReciever$1.run(RemoteNamingServerV1.java:73) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:897) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:919) at java.lang.Thread.run(Thread.java:736) count==2 ..... javax.naming.NameNotFoundException: cuam-ear/param-core/ParaSyncService!com.unionpay.param.core.sync.ParaSyncService -- service jboss.naming.context.java.jboss.exported.cuam-ear.param-core."ParaSyncService!com.unionpay.param.core.sync.ParaSyncService" at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:103) at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:197) at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:174) at org.jboss.naming.remote.protocol.v1.Protocol$1.handleServerMessage(Protocol.java:127) at org.jboss.naming.remote.protocol.v1.RemoteNamingServerV1$MessageReciever$1.run(RemoteNamingServerV1.java:73) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:897) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:919) at java.lang.Thread.run(Thread.java:736) count==24 javax.naming.NameNotFoundException: cuam-ear/param-core/ParaSyncService!com.unionpay.param.core.sync.ParaSyncService -- service jboss.naming.context.java.jboss.exported.cuam-ear.param-core."ParaSyncService!com.unionpay.param.core.sync.ParaSyncService" at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:103) at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:197) at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:174) at org.jboss.naming.remote.protocol.v1.Protocol$1.handleServerMessage(Protocol.java:127) at org.jboss.naming.remote.protocol.v1.RemoteNamingServerV1$MessageReciever$1.run(RemoteNamingServerV1.java:73) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:897) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:919) at java.lang.Thread.run(Thread.java:736) count==25 javax.naming.NamingException: Unable to invoke lookup, status=WAITING count==26 at org.jboss.naming.remote.protocol.v1.Protocol$1.execute(Protocol.java:98) at org.jboss.naming.remote.protocol.v1.RemoteNamingStoreV1.lookup(RemoteNamingStoreV1.java:78) at org.jboss.naming.remote.client.HaRemoteNamingStore$1.operation(HaRemoteNamingStore.java:227) at org.jboss.naming.remote.client.HaRemoteNamingStore.namingOperation(HaRemoteNamingStore.java:114) at org.jboss.naming.remote.client.HaRemoteNamingStore.lookup(HaRemoteNamingStore.java:223) at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:79) at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:83) at javax.naming.InitialContext.lookup(InitialContext.java:392) at com.zyg.test.TestRemoteNaming.main(TestRemoteNaming.java:30)
Why i got exception so many times?
Any advice will be appreciated!
Regards.