Spring EJB's do not failover automatically
Hi all,
My program uses Spring to connect to EJB's hosted on JBoss. The EJB's on JBoss are clustered. In the Spring's configuration file, I have provided the list of JBoss IP addresses and HA-JNDI Port numbers, for the Spring beans to access. When the program starts, it connects to which ever JBoss it finds first that is up and is available. If the Jboss is brought down, the bean does not automatically failover to another JBoss node even though the IP of the JBoss is provided in the list of url's. Below is the definition of one of the beans ..
<bean id="oneBean" class="org.springframework.jndi.JndiObjectFactoryB ean">
<property name="jndiName" value="sample/oneBean/remote"/>
<property name="expectedType" value="sample.OneBeanIntf"/>
<property name="jndiEnvironment">
<props>
<prop key="java.naming.factory.initial">
org.jnp.interfaces.NamingContextFactory</prop>
<prop key="java.naming.factory.url.pkgs">
org.jboss.naming:org.jnp.interfaces</prop>
<prop key="java.naming.provider.url">
jnp://3.63.62.90:1200,jnp://3.63.2.22:1200</prop>
</props>
</property>
</bean>
Has anybody faced this problem before ?
Spring and EJB's do not failover
Thanks for the reply ! Is there any link where I can find examples for these configurations ?? I tried setting
Code:
<bean id="oneBean" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="sample/oneBean/remote"/>
<property name="expectedType" value="sample.OneBeanIntf"/>
<property name="cache" value="false">
<property name="jndiEnvironment">
<props>
<prop key="java.naming.factory.initial">
org.jnp.interfaces.NamingContextFactory</prop>
<prop key="java.naming.factory.url.pkgs">
org.jboss.namingrg.jnp.interfaces</prop>
<prop key="java.naming.provider.url">
jnp://3.63.62.90:1200,jnp://3.63.2.22:1200</prop>
</props>
</property>
</bean>
cache to false but still it does not work . Some other way so that performance is not impacted ?
Thanks in advance
Spring EJB's do not failover automatically
Hi! Thanks again ! I tried out the following code , a very crude way of doing it . Is there a better solution ?
Code:
public class FailoverTest {
public static void main(String args[]){
ApplicationContext ctx = new ClassPathXmlApplicationContext("contextFailover1.xml");
try{
while(true){
System.out.println("first "+ctx.getBean("sample/oneBean"));
}
}catch(Exception ex){
System.out.println(ex.getMessage());
ApplicationContext ctx2 = new ClassPathXmlApplicationContext("contextFailover2.xml");
System.out.println("Failover "+ ctx2.getBean("sample/oneBean"));
}
}
}
Thanks !
Spring EJB's do not failover automatically
Yeah, Thanks again ! I am trying failover logic in Spring .but I am in Spring 2.0.6 and using EJB3 . I read in the post
that SimpleRemoteStatelessSessionProxyFactoryBean support for EJB3 is included in Spring 2.5.1 . Any suggestions ?