2 Replies Latest reply on Sep 17, 2012 6:07 AM by Julien Pardons

    Datasource configuration from Tomcat

    Julien Pardons Newbie

      Hello,

       

      I'm importing .war package in JBoss 7 and I have some problem with the JNDI Name.

       

      In Tomcat, I have this configuration:

       

      <Resource
          name="jdbc/EPCISDB"
          type="javax.sql.DataSource"
          auth="Container"
          username="epcis"
          password="******"
          driverClassName="com.mysql.jdbc.Driver"
          defaultAutoCommit="false"
          url="jdbc:mysql://localhost:3306/epcis?autoReconnect=true">
        </Resource>
      

       

      I tried a lot of solution, but I still get an error on the deployment:

      {"Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"Services with missing/unavailable dependencies" => ["jboss.naming.context.java.module.\"epcis-repository-0.5.1-SNAPSHOT\".\"epcis-repository-0.5.1-SNAPSHOT\".env.jdbc.EPCISDB missing [ jboss.naming.context.java.jboss.resources.jdbc.EPCISDB ]"]}}}

       

      <datasource jndi-name="java:jboss/datasources/env/jdbc/EPCISDB" pool-name="comp/env/jdbc/EPCISDB" enabled="true" jta="true" use-java-context="true" use-ccm="true">
          <connection-url>
              jdbc:mysql://localhost:3306/epcis?autoReconnect=true
          </connection-url>
          <driver>
              mysql
          </driver>
          <security>
              <user-name>
                  epcis
              </user-name>
              <password>
                  ******
              </password>
          </security>
      </datasource>
      

       

      I have tries this name:

      java:jboss/datasources/env/jdbc/EPCISDB

      java:jboss/datasources/comp/env/jdbc/EPCISDB

      java:jboss/datasources/jdbc/EPCISDB

       

      I the config file, I found many different name too:

       

      # the name of the JNDI datasource holding the connection to the database
      jndi.datasource.name=java:comp/env/jdbc/EPCISDB
      

       

      <property name="jndiName" value="jdbc/EPCISDB" />
      

       

      <resource-ref>
          <res-ref-name>jdbc/EPCISDB</res-ref-name>
          <res-type>javax.sql.DataSource</res-type>
          <res-auth>Container</res-auth>
        </resource-ref>
      

       

      Somebody got a solution for me ?


      Thanks !

       

      Julien

        • 1. Re: Datasource configuration from Tomcat
          Nicklas Karlsson Master

          How are you using the datasource? I don't think you should need any more configuration besides the datasource in standalone.xml (and you might want to use a pool-name without slashes: e.g. EPCISDBPool).Try java:jboss/datasources/EPCISDB for the name

          • 2. Re: Datasource configuration from Tomcat
            Julien Pardons Newbie

            I tried with this name, but I got the same error.

             

            I made a full search on my code, here is the results:

             

            String jndiName = getProperties().getProperty("jndi.datasource.name", "java:comp/env/jdbc/EPCISDB");
            
            jndi.datasource.name=java:comp/env/jdbc/EPCISDB
            
            <hibernate-configuration>
              <session-factory>
                <property name="hibernate.connection.datasource">java:comp/env/jdbc/EPCISDB</property>
            
            <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean" scope="singleton">
                <property name="jndiName" value="jdbc/EPCISDB" />
                <property name="resourceRef" value="true" />
              </bean>
            
            <Resource
                name="jdbc/EPCISDB"
                type="javax.sql.DataSource"
                auth="Container"
                username="${db.username}"
                password="${db.password}"
                driverClassName="com.mysql.jdbc.Driver"
                defaultAutoCommit="false"
                url="jdbc:mysql://localhost:3306/${db.database}?autoReconnect=true">
              </Resource>
            
            <resource-ref>
                <res-ref-name>jdbc/EPCISDB</res-ref-name>
                <res-type>javax.sql.DataSource</res-type>
                <res-auth>Container</res-auth>
              </resource-ref>