1 Reply Latest reply on Oct 14, 2011 11:50 PM by jaikiran

    JBoss 6 Deployment Issue: javax.naming.namenotfoundexception jdbc not bound

    jsanders

      I am having the following deployment issue for JBoss 6 for my Struts 2, Spring 3, JPA 2 WAR file.

       

      DEPLOYMENTS IN ERROR:

        Deployment "persistence.unit:unitName=EDRVS.war#edrvs" is in error due to the following reason(s): javax.naming.NameNotFoundException: jdbc not bound

       

      persistence.xml follows:

       

      <?xml version="1.0" encoding="UTF-8"?>

      <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence"

                          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                          xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">

       

                          <persistence-unit name="edrvs" transaction-type="RESOURCE_LOCAL">

                       <provider>org.hibernate.ejb.HibernatePersistence</provider>

                       <non-jta-data-source>jdbc/OracleDS</non-jta-data-source> 

                          <class>gov.doleta.edrvs.model.Code</class>

                          <class>gov.doleta.edrvs.model.Errorcheck</class>

                          <class>gov.doleta.edrvs.model.Fileimportlog</class>

                          <class>gov.doleta.edrvs.model.Filerecordlayout</class>

                          <class>gov.doleta.edrvs.model.Filerecordlayoutelement</class>

                          <class>gov.doleta.edrvs.model.Recordxerrorcheck</class>

                          <class>gov.doleta.edrvs.model.State</class>

                          <class>gov.doleta.edrvs.model.TmpfileuploadWia</class>

                          <class>gov.doleta.edrvs.model.Reportquarter</class>

                          <class>gov.doleta.edrvs.model.Userreportingoption</class>

                          <exclude-unlisted-classes/>

       

              <properties>

                        <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />

                  <property name="hibernate.format_sql" value="true"/>

                  <property name="hbm2ddl.auto" value="update"/>

                  <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/>

                                    <property name="hibernate.archive.autodetection" value="class"/>

              </properties>

          </persistence-unit>

       

      </persistence>

       

      oracle-ds.xml follows:

       

      <?xml version="1.0" encoding="UTF-8"?>

       

      <!-- ===================================================================== -->

      <!--                                                                       -->

      <!--  JBoss Server Configuration                                           -->

      <!--                                                                       -->

      <!-- ===================================================================== -->

       

      <!-- See http://www.jboss.org/community/wiki/Multiple1PC for information about local-tx-datasource -->

      <!-- $Id: oracle-ds.xml 97536 2009-12-08 14:05:07Z jesper.pedersen $ -->

      <!-- ==================================================================== -->

      <!--  Datasource config for Oracle originally from Steven Coy             -->

      <!-- ==================================================================== -->

       

      <datasources>

        <local-tx-datasource>

          <jndi-name>jdbc/OracleDS</jndi-name>

          <connection-url>jdbc:oracle:thin:@192.48.52.155:1521:orcl</connection-url>

          <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>

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

          <password>br9900</password>

          <!-- Uses the pingDatabase method to check a connection is still valid before handing it out from the pool -->

          <!--valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name-->

          <!-- Checks the Oracle error codes and messages for fatal errors -->

          <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>

              <!-- sql to call when connection is created

              <new-connection-sql>some arbitrary sql</new-connection-sql>

              -->

       

              <!-- sql to call on an existing pooled connection when it is obtained from pool - the OracleValidConnectionChecker is prefered-->

              <check-valid-connection-sql>select * from dual;</check-valid-connection-sql>

       

              <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->

            <metadata>

               <type-mapping>Oracle11g</type-mapping>

            </metadata>

        </local-tx-datasource>

       

      </datasources>

       

      web.xml follows:

       

      <?xml version="1.0" encoding="UTF-8"?>

       

      <web-app id="starter" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"

                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

       

       

                <display-name>Struts 2 - Maven Archetype - Starter</display-name>

       

       

                <context-param>

                          <param-name>contextConfigLocation</param-name>

                          <param-value>classpath*:applicationContext*.xml</param-value>

                </context-param>

       

       

                <!-- Filters -->

                <filter>

                          <filter-name>action2-cleanup</filter-name>

                          <filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class>

                </filter>

                <filter>

                          <filter-name>sitemesh</filter-name>

                          <filter-class>com.opensymphony.module.sitemesh.filter.PageFilter</filter-class>

                </filter>

                <filter>

                          <filter-name>action2</filter-name>

                          <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>

                </filter>

       

                 <filter-mapping>

                          <filter-name>action2-cleanup</filter-name>

                          <url-pattern>/*</url-pattern>

                </filter-mapping>

                <filter-mapping>

                          <filter-name>sitemesh</filter-name>

                          <url-pattern>/*</url-pattern>

                </filter-mapping>

                <filter-mapping>

                          <filter-name>action2</filter-name>

                          <url-pattern>/*</url-pattern>

                </filter-mapping>

       

                <!-- Listeners -->

                <listener>

                          <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>

                </listener>

       

                     <!-- Servlets -->

                <servlet>

                          <servlet-name>dwr</servlet-name>

                          <servlet-class>uk.ltd.getahead.dwr.DWRServlet</servlet-class>

                          <init-param>

                                    <param-name>debug</param-name>

                                    <param-value>true</param-value>

                          </init-param>

                </servlet>

                <servlet>

                          <servlet-name>jspSupportServlet</servlet-name>

                          <servlet-class>org.apache.struts2.views.JspSupportServlet</servlet-class>

                          <load-on-startup>5</load-on-startup>

                </servlet>

       

                 <servlet-mapping>

                          <servlet-name>dwr</servlet-name>

                          <url-pattern>/dwr/*</url-pattern>

                </servlet-mapping>

       

                   <!-- Welcome file lists -->

                <welcome-file-list>

                          <welcome-file>index.jsp</welcome-file>

                          <welcome-file>default.jsp</welcome-file>

                          <welcome-file>index.html</welcome-file>

                </welcome-file-list>

       

                 <resource-ref>

                          <description>MyDataSource</description>

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

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

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

                </resource-ref>

       

      </web-app>

       

      jboss-web.xml follows:

       

      <jboss-web>

                <resource-ref>

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

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

                          <jndi-name>java:jdbc/OracleDS</jndi-name>

                </resource-ref>

      </jboss-web>

       

      Spring applicationContext.xml follows:

       

      <?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:aop="http://www.springframework.org/schema/aop"

                xmlns:tx="http://www.springframework.org/schema/tx"

                xsi:schemaLocation="

          http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd

          http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd

          http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">

       

       

                <!-- Example of SAF2 action instantiated by Spring -->

                <bean id="helloWorldAction" class="gov.doleta.edrvs.action.HelloWorldAction" />

       

                <bean id="indexAction" class="gov.doleta.edrvs.action.IndexAction" />

       

       

       

                <!-- Enable JPA Support -->

                <bean

                          class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />

       

       

                <!-- Define EntityManagerFactory and Datasource -->

                <bean id="entityManagerFactory"

                          class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">

                          <property name="persistenceUnitName" value="edrvs" />

                          <property name="dataSource" ref="dataSource" />

                          <property name="jpaVendorAdapter">

                                    <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">

                                              <property name="database" value="ORACLE" />

                                              <property name="showSql" value="true" />

                                    </bean>

                          </property>

                </bean>

       

       

                <bean id="dataSource"

                          class="org.springframework.jdbc.datasource.DriverManagerDataSource">

                          <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />

                          <property name="url" value="jdbc:oracle:thin:@192.48.52.155:1521:orcl" />

                          <property name="username" value="brafai" />

                          <property name="password" value="br9900" />

                </bean>

       

       

                <!-- Define Transaction Manager -->

                <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">

                          <property name="entityManagerFactory" ref="entityManagerFactory" />

                </bean>

       

       

                <tx:annotation-driven transaction-manager="transactionManager" />

       

       

                <!-- Define the FileImportLogDao -->

                <bean id="FileImportLogDao" class="gov.doleta.edrvs.dao.FileImportLogDaoImpl" />

       

       

                <!-- Define the FileImportLogService -->

                <!-- enable the configuration of transactional behavior based on annotations -->

                <bean id="FileImportLogService" class="gov.doleta.edrvs.service.FileImportLogServiceImpl">

                          <property name="FileImportLogDao" ref="FileImportLogDao" />

                </bean>

       

       

       

       

                <!-- Define the StateDao -->

                <bean id="StateDao" class="gov.doleta.edrvs.dao.StateDaoImpl" />

       

       

                <!-- Define the StateService -->

                <!-- enable the configuration of transactional behavior based on annotations -->

                <bean id="StateService" class="gov.doleta.edrvs.service.StateServiceImpl">

                          <property name="StateDao" ref="StateDao" />

                </bean>

       

       

                <!-- Define the WIASourceDao -->

                <bean id="WIASourceDao" class="gov.doleta.edrvs.dao.WIASourceDaoImpl" />

       

       

                <!-- Define the WIASourceService -->

                <!-- enable the configuration of transactional behavior based on annotations -->

                <bean id="WIASourceService" class="gov.doleta.edrvs.service.WIASourceServiceImpl">

                          <property name="WIASourceDao" ref="WIASourceDao" />

                </bean>

       

                <!-- Define the FileRecordLayoutElementDao -->

                <bean id="FileRecordLayoutElementDao" class="gov.doleta.edrvs.dao.FileRecordLayoutElementDaoImpl" />

       

       

                <!-- Define the FileRecordLayoutElementService -->

                <!-- enable the configuration of transactional behavior based on annotations -->

                <bean id="FileRecordLayoutElementService" class="gov.doleta.edrvs.service.FileRecordLayoutElementServiceImpl">

                          <property name="FileRecordLayoutElementDao" ref="FileRecordLayoutElementDao" />

                </bean>

       

       

                <!-- Define the CodeDao -->

                <bean id="CodeDao" class="gov.doleta.edrvs.dao.CodeDaoImpl" />

       

       

                <!-- Define the CodeService -->

                <!-- enable the configuration of transactional behavior based on annotations -->

                <bean id="CodeService" class="gov.doleta.edrvs.service.CodeServiceImpl">

                          <property name="CodeDao" ref="CodeDao" />

                </bean>

       

                <!-- Define the ErrorCheckDao -->

                <bean id="ErrorCheckDao" class="gov.doleta.edrvs.dao.ErrorCheckDaoImpl" />

       

       

                <!-- Define the ErrorCheckService -->

                <!-- enable the configuration of transactional behavior based on annotations -->

                <bean id="ErrorCheckService" class="gov.doleta.edrvs.service.ErrorCheckServiceImpl">

                          <property name="ErrorCheckDao" ref="ErrorCheckDao" />

                </bean>

       

                <!-- Define the RecordXErrorCheckDao -->

                <bean id="RecordXErrorCheckDao" class="gov.doleta.edrvs.dao.RecordXErrorCheckDaoImpl" />

       

       

                <!-- Define the RecordXErrorCheckService -->

                <!-- enable the configuration of transactional behavior based on annotations -->

                <bean id="RecordXErrorCheckService" class="gov.doleta.edrvs.service.RecordXErrorCheckServiceImpl">

                          <property name="RecordXErrorCheckDao" ref="RecordXErrorCheckDao" />

                </bean>

       

      </beans>

       

       

       

      Any help is appreciated. I can run my Maven Spring Service JUnit tests without problems and get data to/from the Oracle DB

      but when I try to deploy to JBoss I have the issue above.

       

      Jeff Sanders