PDA

View Full Version : JNDI with SimpleRemoteStatelessSession in a cluster


mrklc
Jan 17th, 2005, 09:04 AM
Hi all,

I am new here and I would like to ask a question about the setting of JNDI with the

SimpleRemoteStatelessSessionProxyFactoryBean in a cluster environment.

The question is simple: does Spring support jndi syntax like this: iiop://app1:9081,:app2:9081?


The details of the question is in the following:

Assume that I have the following bean defined in an applicationContext.xml:

<bean id="MyFacade" class="org.springframework.ejb.access.SimpleRemoteStatele ssSessionProxyFactoryBean">
<property name="jndiEnvironment">
<props>
<prop key="java.naming.factory.initial">${javax.naming.Context.INITIAL_CONTEXT_FACTORY}</prop>
<prop key="java.naming.provider.url">${javax.naming.Context.PROVIDER_URL}</prop>
</props>
</property>
<property name="jndiName"><value>ejb/MyFacadeHome</value></property>
<property name="businessInterface"><value>MyFacade</value></property>
</bean>

Both javax.naming.Context.INITIAL_CONTEXT_FACTORY & javax.naming.Context.PROVIDER_URL are defined in a properties file. It

was fine until we move our codes in a cluster environment.

In the cluster, we have 2 app servers which are WebSphere, app1 and app2 and their port for jndi lookup is 9081. In single

server case, my "javax.naming.Context.PROVIDER_URL" would be iiop://app1:9081.

However, in a cluster, if I want to use naming service from both app servers, the url would like this:

iiop://app1:9081,:app2:9081. I read from a WebSphere Red Book to find this syntax but it does not work with the above Spring

configuration and I got the following error:

Initialization of bean failed; nested exception is javax.naming.ConfigurationEx
ception: java.lang.NumberFormatException: 9081,:app2:9081
javax.naming.ConfigurationException: java.lang.NumberFormatException: 9081,:sapp02:9081. Root exception is
java.lang.NumberFormatException: 9081,:sapp02:9081
at java.lang.Integer.parseInt(Integer.java(Compiled Code))
at java.lang.Integer.<init>(Integer.java(Inlined Compiled Code))
at com.ibm.ws.naming.util.WsnInitCtxFactory.parseIiop Url(WsnInitCtxFactory.java(Compiled Code))
at com.ibm.ws.naming.util.WsnInitCtxFactory.parseBoot strapURL(WsnInitCtxFactory.java(Compiled Code))
at com.ibm.ws.naming.util.WsnInitCtxFactory.getInitia lContextInternal(WsnInitCtxFactory.java(Compiled Code))
at com.ibm.ws.naming.util.WsnInitCtx.getContext(WsnIn itCtx.java:102)
at com.ibm.ws.naming.util.WsnInitCtx.getContextIfNull (WsnInitCtx.java(Inlined Compiled Code))
at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCt x.java(Compiled Code))
at javax.naming.InitialContext.lookup(InitialContext. java(Compiled Code))
at org.springframework.jndi.JndiTemplate$1.doInContex t(JndiTemplate.java:120)
at org.springframework.jndi.JndiTemplate.execute(Jndi Template.java:85)
at org.springframework.jndi.JndiTemplate.lookup(JndiT emplate.java:117)
at org.springframework.jndi.AbstractJndiLocator.looku p(AbstractJndiLocator.java:169)
at org.springframework.jndi.AbstractJndiLocator.after PropertiesSet(AbstractJndiLocator.java:164)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeInitMethods

(AbstractAutowireCapableBeanFactory.
java:718)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean

(AbstractAutowireCapableBeanFactory.java:21
3)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:159)
at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons

(DefaultListableBeanFactory.java:172)
at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:272)
at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationContext.java:58)


It seems that it treats all chars after the first ":" as port number.

Any idea or work around or I did something totally wrong?

Thanks in advance.

Regards,
KC

fiacobelli
Apr 5th, 2005, 05:28 PM
Did you find a way to solve this?. I can't seem to find out how to do it either.
Thanks.

dejanp
Apr 6th, 2005, 05:20 AM
Did you find a way to solve this?. I can't seem to find out how to do it either.
Thanks.

Shouldn't it be iiop://app1:9081,iiop://app2:9081 and not iiop://app1:9081,:app2:9081 ? That's a comma separated list of URLs and :app2:9081 is not a URL.

fiacobelli
Apr 6th, 2005, 10:30 AM
Well, the specs for the url provider property say they should be separated by a space. If I separate them by a comma or a space or semicolon I get the same error: java.lang.NumberFormatException: For input string: "900,iiop:"
(The port # is 900). I have tried iiop://some.server:900/ iiop://another.server:900/ and then I get an error saying that the second server is not available, but if I work with either server individually it's ok.
Any ideas?
Thanks