Question

I am looking up my JNDI value of endpoint (properties file is not an option) on server like this

<jee:jndi-lookup id="MyEndpoint" jndi-name="endpoint.url" />

I would like to use the above looked up value in the place of address.

<jaxws:client id="helloClient"
       serviceClass="demo.spring.HelloWorld"
       address="http://localhost:9002/HelloWorld" />

I tried address="${MyEndpoint}". Did n't work. Looks like I have to use another bean, which uses jndi value and use its method to return as string i.e. address="#{MyBean.geyMyEndpoint()}". Doesn't look clean that way. Any suggestions?

Was it helpful?

Solution

You should be able to use Spring Expression Language to get the behavior you want, without using another bean. The following works for me in Tomcat 7:

<jee:jndi-lookup id="MyEndpoint" jndi-name="java:comp/env/MyEndpoint" />

<jaxws:client id="helloClient"
       serviceClass="demo.spring.HelloWorld"
       address="#{MyEndpoint}" />

OTHER TIPS

Also on another note from Spring 3.1 - Spring has unified property management. so instead of the above solution you can do this

<jaxws:client id="helloClient"  serviceClass="demo.spring.HelloWorld"  address="${endpoint.url}" />

endpoint.url could be any property(system, environment etc) and it will automatically resolve the property. so no need to do separate JNDI lookup and your code looks clean.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top