2 Replies Latest reply on Jun 27, 2003 10:04 PM by thava

    DataSource not bound error within the same EJBJAR

    thava Newbie

      Hi,

      I have an ejbjar with two local entity bean and one remote Session facade remote session bean. I always get datasource not bound error. I am using firebird and my firebird-ds.xml is as follows
      <--start-->
      <connection-factories>

      <!--FBManager can be used to create and drop databases.
      Drop is especially useful during testing, since it
      assures a clean start next time. -->

      /usr/local/firebird/examples/employee.fdb
      xxx
      yyy
      true
      false


      <tx-connection-factory>

      <jndi-name>employeeDS</jndi-name>

      <xa-transaction/>

      <adapter-display-name>Firebird Database Connector</adapter-display-name>

      <config-property name="Database" type="java.lang.String">localhost/3050:/usr/local/firebird/examples/employee.fdb</config-property>

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

      yyy

      <!--additional properties. only use one way of setting tx isolation, please
      <config-property name="TransactionIsolation"></config-property>
      <config-property name="TransactionIsolationName">TRANSACTION_READ_COMMITTED</config-property>
      <config-property name="BlobBufferLength"></config-property>
      <config-property name="Encoding">UNICODE_FSS</config-property>
      -->

      <min-pool-size>0</min-pool-size>
      </tx-connection-factory>

      </connection-factories>
      <---end--->

      My jbosscmp-jdbc in the ejbjar file is as follows
      <----start----->
      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE jbosscmp-jdbc PUBLIC "-//JBoss//DTD JBOSSCMP-JDBC 3.2//EN" "http://www.jboss.org/j2ee/dtd/jbosscmp-jdbc_3_2.dtd">
      <jbosscmp-jdbc>

      employeeDS
      <datasource-mapping>Firebird</datasource-mapping>

      <enterprise-beans>

      <ejb-name>Department</ejb-name>
      <table-name>DEPARTMENT</table-name>
      <cmp-field>
      <field-name>deptNo</field-name>
      <column-name>DEPT_NO</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>department</field-name>
      <column-name>DEPARTMENT</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>headDept</field-name>
      <column-name>HEAD_DEPT</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>mngrNo</field-name>
      <column-name>MNGR_NO</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>budget</field-name>
      <column-name>BUDGET</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>location</field-name>
      <column-name>LOCATION</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>phoneNo</field-name>
      <column-name>PHONE_NO</column-name>
      </cmp-field>


      <ejb-name>Employee</ejb-name>
      <table-name>EMPLOYEE</table-name>
      <cmp-field>
      <field-name>empNo</field-name>
      <column-name>EMP_NO</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>firstName</field-name>
      <column-name>FIRST_NAME</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>lastName</field-name>
      <column-name>LAST_NAME</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>phoneExt</field-name>
      <column-name>PHONE_EXT</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>hireDate</field-name>
      <column-name>HIRE_DATE</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>deptNo</field-name>
      <column-name>DEPT_NO</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>jobCode</field-name>
      <column-name>JOB_CODE</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>jobGrade</field-name>
      <column-name>JOB_GRADE</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>jobCountry</field-name>
      <column-name>JOB_COUNTRY</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>salary</field-name>
      <column-name>SALARY</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>fullName</field-name>
      <column-name>FULL_NAME</column-name>
      </cmp-field>

      </enterprise-beans>
      </jbosscmp-jdbc>
      <----end---->

      My jboss.xml in ejbjar is as follows
      <--start-->
      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 3.2//EN" "http://www.jboss.org/j2ee/dtd/jboss_3_2.dtd">

      <enterprise-beans>

      <ejb-name>DepartmentSessionFacade</ejb-name>
      <jndi-name>DepartmentSessionFacade</jndi-name>


      <ejb-name>Department</ejb-name>
      <local-jndi-name>Department</local-jndi-name>
      <resource-ref>
      <res-ref-name>employeeDS</res-ref-name>
      <jndi-name>employeeDS</jndi-name>
      </resource-ref>


      <ejb-name>Employee</ejb-name>
      <local-jndi-name>Employee</local-jndi-name>
      <resource-ref>
      <res-ref-name>employeeDS</res-ref-name>
      <jndi-name>employeeDS</jndi-name>
      </resource-ref>

      </enterprise-beans>

      <--end-->

      All help are deeply appreciated as this has been bugging me for days

      Thanks in advance & cheers

        • 1. Re: DataSource not bound error within the same EJBJAR
          Harald Gliebe Novice

          If you specify the jndi-name as "employeeDS", the datasource will be bound to "java:/employeeDS". You have to use this name (with the "java:/" prefix) in the datasource element in jbosscmp-jdbc.xml and in the jndi-name elements in jboss.xml:

          <jbosscmp-jdbc>

          java:/employeeDS
          ....


          ...
          <resource-ref>
          <res-ref-name>employeeDS</res-ref-name>
          <jndi-name>java:/employeeDS</jndi-name>
          </resource-ref>


          Regards,
          Harald

          • 2. Re: DataSource not bound error within the same EJBJAR
            thava Newbie

            Thanks Harald,

            I tried your suggestion previously and retried them again. I get the following error

            "org.jboss.deployment.DeploymentException: Error: can't find data source: java:/employeeDS; - nested throwable: (javax.naming.NameNotFoundException: employeeDS not bound)"

            Appreciate your help
            Thanks