Search code examples
javaspringjbossapache-cameljndi

How to resolve error with Spring process looking for EJB JNDI endpoint?


I have an Apache Camel Spring process that connects to a JBoss 4.2.3 app server to get EJB remote proxies. The following is the XML snippet of the configuration file:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:jee="http://www.springframework.org/schema/jee"
       xmlns:camel="http://camel.apache.org/schema/spring"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/jee
        http://www.springframework.org/schema/jee/spring-jee.xsd
        http://camel.apache.org/schema/spring
        http://camel.apache.org/schema/spring/camel-spring.xsd"
       default-lazy-init="true">

    <!-- ================================ -->
    <!-- EJB Components -->
    <!-- ================================ -->

    <jee:remote-slsb id="brokingReferenceService"
                     jndi-name="BrokingReferenceServiceBean/remote"
                     business-interface="com.company.command.ejb.BrokingReferenceService"/>

    <jee:remote-slsb id="strategyReferenceService"
                     jndi-name="StrategyReferenceServiceBean/remote"
                     business-interface="com.company.command.ejb.StrategyReferenceService"/>

    <jee:remote-slsb id="instantMessageOrderService"
                     jndi-name="InstantMessageOrderServiceBean/remote"
                     business-interface="com.company.command.ejb.InstantMessageOrderService"/>
    ...
</beans>

I have a jndi.properties file in the classpath, which contains the following:

java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
java.naming.provider.url=http://10.10.0.240:1100

But I am receiving the following error when the process attempts to lookup the JNDI endpoint:

2017-01-03 09:15:07.057 DEBUG (org.springframework.jndi.JndiTemplate) Looking up JNDI object with name [java:comp/env/BrokingReferenceServiceBean/remote]
2017-01-03 09:15:09.322 DEBUG (org.jnp.interfaces.NamingContext) Failed to connect to http:1099
javax.naming.CommunicationException: Failed to connect to server http:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server http:1099 [Root exception is java.net.UnknownHostException: http]]
        at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:274)
        at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1533)
        at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:634)
        at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
        at javax.naming.InitialContext.lookup(InitialContext.java:417)
        at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:154)
        at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:87)
        at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:152)
        at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:178)
        at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:95)
        at org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:105)
        at org.springframework.ejb.access.AbstractRemoteSlsbInvokerInterceptor.lookup(AbstractRemoteSlsbInvokerInterceptor.java:100)
        at org.springframework.ejb.access.AbstractSlsbInvokerInterceptor.refreshHome(AbstractSlsbInvokerInterceptor.java:122)
        at org.springframework.ejb.access.SimpleRemoteSlsbInvokerInterceptor.refreshHome(SimpleRemoteSlsbInvokerInterceptor.java:163)
        at org.springframework.ejb.access.AbstractSlsbInvokerInterceptor.afterPropertiesSet(AbstractSlsbInvokerInterceptor.java:109)
        ...
Caused by: javax.naming.ServiceUnavailableException: Failed to connect to server http:1099 [Root exception is java.net.U
nknownHostException: http]
        at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:248)
        ... 48 more
Caused by: java.net.UnknownHostException: http
        at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
        at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:928)
        at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1323)
        at java.net.InetAddress.getAllByName0(InetAddress.java:1276)
        at java.net.InetAddress.getAllByName(InetAddress.java:1192)
        at java.net.InetAddress.getAllByName(InetAddress.java:1126)
        at java.net.InetAddress.getByName(InetAddress.java:1076)
        at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:76)
        at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:244)
        ... 48 more

Does anyone have an idea why it is not picking up the URL properly? I have defined the URL in the properties file, but it is parsing the URL as "http:1099".

Thanks for your help.


Solution

  • Try those things:

    • java.naming.provider.url=jnp://10.10.0.240:1100
    • java.naming.provider.url=10.10.0.240:1100

    See the documentation here