3 Replies Latest reply on Nov 28, 2013 3:00 PM by Wolf-Dieter Fink

    Error lookup datasource jndi Spring Jboss 7

    Rodrigo Parede Newbie

      Please help me!

       

      I started migrating jboss 4 to jboss 7.

       

      Error console:

      Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceJNDI' defined in ServletContext resource [/WEB-INF/cms-servlet.xml]: Invocation of init method failed; nested exception is javax.naming.NamingException: JBAS011843: Failed instantiate InitialContextFactory org.jnp.interfaces.NamingContextFactory from classloader ModuleClassLoader for Module "deployment.cms_motov2.war:main" from Service Module Loader

        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338) [spring-2.5.6.SEC03.jar:2.5.6.SEC03]

        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473) [spring-2.5.6.SEC03.jar:2.5.6.SEC03]

        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) [spring-2.5.6.SEC03.jar:2.5.6.SEC03]

        at java.security.AccessController.doPrivileged(Native Method) [rt.jar:1.7.0_09]

        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) [spring-2.5.6.SEC03.jar:2.5.6.SEC03]

        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) [spring-2.5.6.SEC03.jar:2.5.6.SEC03]

        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) [spring-2.5.6.SEC03.jar:2.5.6.SEC03]

        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) [spring-2.5.6.SEC03.jar:2.5.6.SEC03]

        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) [spring-2.5.6.SEC03.jar:2.5.6.SEC03]

        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) [spring-2.5.6.SEC03.jar:2.5.6.SEC03]

        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:269) [spring-2.5.6.SEC03.jar:2.5.6.SEC03]

       

      My configuration:

       

      cms-servlet.xml

      <bean id="dataSourceJNDI" class="org.springframework.jndi.JndiObjectFactoryBean">

        <property name="jndiName" value="java:jboss/datasources/myDS"/>

      </bean>

       

      jboss-web.xml

       

      <resource-ref>

              <res-ref-name>jdbc/myDS</res-ref-name>

              <res-type>javax.sql.DataSource</res-type>

              <jndi-name>java:jboss/datasources/myDS</jndi-name>

          </resource-ref>

       

      web.xml

       

      <resource-ref>

        <description>DB Connection</description>

        <res-ref-name>jdbc/myDS</res-ref-name>

        <res-type>javax.sql.DataSource</res-type>

        <res-auth>Container</res-auth>

      </resource-ref>

       

      standalone.xml

      <datasource jndi-name="java:jboss/datasources/myDS" pool-name="myDS" enabled="true" use-java-context="true">

                          <connection-url>jdbc:jtds:sqlserver://server/db;instance=SQLEXPRESS2008RC</connection-url>

                          <driver>mssql</driver>

                          <security>

                              <user-name>user</user-name>

                              <password>senha</password>

                          </security>

                      </datasource>

       

      I already tested the connection in jboss console, the problem must be the lookup in my project