2 Replies Latest reply on Sep 12, 2019 10:56 AM by pino991

    jboss 7.0 and jndi with Spring

    clockdva1

      i have created a datasource in Jboss subsystems, i have tested the connection and it works but i can't get it in a bean from my applicationContext.xml file, i get the error "javax.naming.CommunicationException"

       

      i have tried in this way:

            
       
        <bean id="jndiDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
         <property name="jndiName" value="java:/jboss/myds"/>
         <property name="resourceRef">
            <value>true</value>
         </property>
        </bean>   
         
              

       

         and in this way:

       

         <jee:jndi-lookup expected-type="javax.sql.DataSource" id="springBeanIdForSampleDS" jndi-name="java:/jboss/myds"/>
          

       

       

      thanks

        • 1. Re: jboss 7.0 and jndi with Spring
          zhurlik

          Hi,

           

          Could you try to use just name
          <jee:jndi-lookup id="dataSource" jndi-name="myds"/>

          Thanks,

          Vlad

          1 of 1 people found this helpful
          • 2. Re: jboss 7.0 and jndi with Spring
            pino991

            sorry, i can't use the old account

             

            i have tried and i get

             

             

            Error creating bean with name 'jdataSource': Invocation of init method failed; nested exception is javax.naming.CommunicationException: Failed to connect to any server. Servers tried: [remote://localhost:4447 (java.net.ConnectException: Connection refused: no further information)]

            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1708)

            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:581)

            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:503)

            at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317)

            at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)

            at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)

            at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)

            at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:741)

            at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:869)

            at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)

            at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:409)

            at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:291)

            at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:103)

            at io.undertow.servlet.core.ApplicationListeners.contextInitialized(ApplicationListeners.java:187)

            at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:198)

            at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:100)

            at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:82)

            at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)

            at java.util.concurrent.FutureTask.run(FutureTask.java:266)

            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

            at java.lang.Thread.run(Thread.java:748)

            at org.jboss.threads.JBossThread.run(JBossThread.java:320)

            Caused by: javax.naming.CommunicationException: Failed to connect to any server. Servers tried: [remote://localhost:4447 (java.net.ConnectException: Connection refused: no further information)]

            at org.jboss.naming.remote.client.HaRemoteNamingStore.failOverSequence(HaRemoteNamingStore.java:244)

            at org.jboss.naming.remote.client.HaRemoteNamingStore.namingStore(HaRemoteNamingStore.java:149)

            at org.jboss.naming.remote.client.HaRemoteNamingStore.namingOperation(HaRemoteNamingStore.java:130)

            at org.jboss.naming.remote.client.HaRemoteNamingStore.lookup(HaRemoteNamingStore.java:272)

            at org.jboss.naming.remote.client.RemoteContext.lookupInternal(RemoteContext.java:104)

            at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:93)

            at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:146)

            at javax.naming.InitialContext.lookup(InitialContext.java:417)

            at javax.naming.InitialContext.lookup(InitialContext.java:417)

            at org.springframework.jndi.JndiTemplate.lambda$lookup$0(JndiTemplate.java:156)

            at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:91)

            at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:156)

            at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:178)

            at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:105)

            at org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:114)

            at org.springframework.jndi.JndiObjectFactoryBean.lookupWithFallback(JndiObjectFactoryBean.java:238)

            at org.springframework.jndi.JndiObjectFactoryBean.afterPropertiesSet(JndiObjectFactoryBean.java:224)

            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1767)

            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1704)

            ... 22 more

             

             

            16:25:32,531 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 90) MSC000001: Failed to start service jboss.undertow.deployment.default-server.default-host./scriptDtct0: org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./scriptDtct0: java.lang.RuntimeException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jdataSource': Invocation of init method failed; nested exception is javax.naming.CommunicationException: Failed to connect to any server. Servers tried: [remote://localhost:4447 (java.net.ConnectException: Connection refused: no further information)]

            at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:85)

            at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)

            at java.util.concurrent.FutureTask.run(FutureTask.java:266)

            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

            at java.lang.Thread.run(Thread.java:748)

            at org.jboss.threads.JBossThread.run(JBossThread.java:320)

            Caused by: java.lang.RuntimeException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jdataSource': Invocation of init method failed; nested exception is javax.naming.CommunicationException: Failed to connect to any server. Servers tried: [remote://localhost:4447 (java.net.ConnectException: Connection refused: no further information)]

            at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:231)

            at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:100)

            at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:82)

            ... 6 more

            Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jdataSource': Invocation of init method failed; nested exception is javax.naming.CommunicationException: Failed to connect to any server. Servers tried: [remote://localhost:4447 (java.net.ConnectException: Connection refused: no further information)]

            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1708)

            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:581)

            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:503)

            at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317)

            at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)

            at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)

            at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)

            at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:741)

            at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:869)

            at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)

            at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:409)

            at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:291)

            at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:103)

            at io.undertow.servlet.core.ApplicationListeners.contextInitialized(ApplicationListeners.java:187)

            at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:198)

            ... 8 more

            Caused by: javax.naming.CommunicationException: Failed to connect to any server. Servers tried: [remote://localhost:4447 (java.net.ConnectException: Connection refused: no further information)]

            at org.jboss.naming.remote.client.HaRemoteNamingStore.failOverSequence(HaRemoteNamingStore.java:244)

            at org.jboss.naming.remote.client.HaRemoteNamingStore.namingStore(HaRemoteNamingStore.java:149)

            at org.jboss.naming.remote.client.HaRemoteNamingStore.namingOperation(HaRemoteNamingStore.java:130)

            at org.jboss.naming.remote.client.HaRemoteNamingStore.lookup(HaRemoteNamingStore.java:272)

            at org.jboss.naming.remote.client.RemoteContext.lookupInternal(RemoteContext.java:104)

            at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:93)

            at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:146)

            at javax.naming.InitialContext.lookup(InitialContext.java:417)

            at javax.naming.InitialContext.lookup(InitialContext.java:417)

            at org.springframework.jndi.JndiTemplate.lambda$lookup$0(JndiTemplate.java:156)

            at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:91)

            at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:156)

            at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:178)

            at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:105)

            at org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:114)

            at org.springframework.jndi.JndiObjectFactoryBean.lookupWithFallback(JndiObjectFactoryBean.java:238)

            at org.springframework.jndi.JndiObjectFactoryBean.afterPropertiesSet(JndiObjectFactoryBean.java:224)

            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1767)

            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1704)

            ... 22 more

             

             

            16:25:32,536 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "scriptDtct0.war")]) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.undertow.deployment.default-server.default-host./scriptDtct0" => "org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./scriptDtct0: java.lang.RuntimeException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jdataSource': Invocation of init method failed; nested exception is javax.naming.CommunicationException: Failed to connect to any server. Servers tried: [remote://localhost:4447 (java.net.ConnectException: Connection refused: no further information)]

                Caused by: java.lang.RuntimeException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jdataSource': Invocation of init method failed; nested exception is javax.naming.CommunicationException: Failed to connect to any server. Servers tried: [remote://localhost:4447 (java.net.ConnectException: Connection refused: no further information)]

                Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jdataSource': Invocation of init method failed; nested exception is javax.naming.CommunicationException: Failed to connect to any server. Servers tried: [remote://localhost:4447 (java.net.ConnectException: Connection refused: no further information)]

                Caused by: javax.naming.CommunicationException: Failed to connect to any server. Servers tried: [remote://localhost:4447 (java.net.ConnectException: Connection refused: no further information)]"}}