Problem using HA-JNDI and Fail Over
roberto Apr 15, 2005 8:24 AMMaybe i have found a bug in the cluster environment if enterprise application use HA-JNDI.
I'm using JBoss AS 4.0.1sp1 with jdk 1.4.2_07 on Windows XP using "all" configuration.
I have tre machine:
"HostA" : Load balance base on Apache 2.0 with mod_jk 1.2.x with sticky session
"ClusterB" : Jboss AS 4.0.1 sp1 with my ear with war and ejb modules
"ClusterC" : Jboss AS 4.0.1 sp1 with my ear the same than in ClusterB
In this situation ALL WORKS fine.
If a cliente request to HostA a resouce, this is forward to ClusterB or ClusterC according load balance rules.
Http sessions are replicated too and credential is propagate across cluster.
So the cluster that response to the client request shutdown, a new request from the client (in the same http session) is redirect the the alive cluster and all http session data are visible again.
the web.xml have the attribute.
ejb are not CLUSTERED because are local entity ejb and stateless session.
And this is the correct behavior.
Now my ear application need to use the HA-JNDI because i need to bind to the JNDI a object and this must be see across cluster.
I know that to use HA-JNDI there are different ways:
Solution 1:
try { Properties properties = new Properties(); properties.setProperty(javax.naming.Context.PROVIDER_URL, "localhost:1100"); object = new InitialContext(properties).lookup("myinformation"); } catch (Exception vErr) {}
is the same setting as property jnp.partitionName the partition name (eg. "DefaultPartition")
Solution 2:
put in the classpath a jndi.properties with the provider url or partition name.
In this case i can use object = new InitialContext().lookup("myinformation");
I choose to use the second way because no change in my code is needed and i cannot "hard code" the value.
So i have in my ear a indi.properties with:
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory java.naming.provider.url=jnp://localhost:1100 java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces #jnp.partitionName=DefaultPartition
This works fine too. HA-JNDI works fine. but a big problem occurs when a cluster shutdown: all lookups fail with a NameNotBoundException!
Seem that all the deployed/binded ejb are undeployed (maybe only for the HA-JNDI because if i go on jmx-console i can see the deployed ejb yet).
And another problem http session data are lost (or maybe never replicated to clusters).
Seem that when a cluster shutdown, the jboss container undeploy all and remove all http session using HA-JNDI, so undeploy over all cluster and remove http session data from all cluster.
Any idea about it? or it's really a bug? or i haven't configured well how use HA-JNDI?
I need to use HA-JNDI without change my code...
Thank You
Roberto