3 Replies Latest reply on Feb 20, 2004 4:30 AM by Joachim Van der Auwera

    CMP:Where my data is going?

    mandarjboss Newbie



      To,
      Mr. Bandaru Kagaru,
      I am trying to develop a J2EE(CMP2.0 based) application with JBoss3.2.2.I am able to successfully configure the datasource for PostgreSQL.I have tested the datasource with manual lookup and connection establishment. It is successful.
      Now the problem is when i am executing my CMP bean the application gets deployed and executed successfully even my Finder queries are returning successfully.But when i go to corresponding table in PostgreSQL i can not find my row there.
      It seems to be that my row is getting inserted in HSQL(Hypersonic SQL),the default database of JBoss.That is the whole problem.
      I want my row to be inserted in PostgreSQL and not in HSQL.Can you tell me where am i wrong?
      I am giving details of my CMP's config files below.
      Waiting for your reply.

      In postgres-ds.xml i have following entries

      <local-tx-datasource>
      <jndi-name>PostgresDS</jndi-name>
      <connection-url>jdbc:postgresql://192.168.100.18:5432/xsim</connection-url>
      <driver-class>org.postgresql.Driver</driver-class>
      <user-name>xsim</user-name>
      xsim
      <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.DummyExceptionSorter</exception-sorter-class-name>
      </local-tx-datasource>



      In ejb.jar.xml I have following entries...

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


      In jboss.xml I have following entries


      <enterprise-beans>

      <!--
      To add beans that you have deployment descriptor info for, add
      a file to your XDoclet merge directory called jboss-beans.xml that contains
      the , and <message-driven></message-driven>
      markup for those beans.
      -->


      <ejb-name>QuestionBean</ejb-name>
      <jndi-name>QuestionBean</jndi-name>
      <resource-ref>
      <res-ref-name>java:/PostgresDS</res-ref-name>
      <jndi-name>java:/PostgresDS</jndi-name>
      </resource-ref> -->

      <method-attributes>
      </method-attributes>



      <ejb-name>ChoiceBean</ejb-name>
      <local-jndi-name>ChoiceBean</local-jndi-name>

      <method-attributes>
      </method-attributes>



      </enterprise-beans>

      <resource-managers>
      <resource-manager>
      <res-name>java:/PostgresDS</res-name>
      <res-jndi-name>java:/PostgresDS</res-jndi-name>
      </resource-manager>
      </resource-managers>



      In jbosscmp-jdbc.xml i have following entries

      <?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>

      java:/PostgresDS
      <datasource-mapping>PostgreSQL</datasource-mapping>
      <create-table>false</create-table>
      <remove-table>false</remove-table>

      <enterprise-beans>

      <ejb-name>QuestionBean</ejb-name>
      <table-name>newquestion</table-name>

      <cmp-field>
      <field-name>questionid</field-name>
      <column-name>question_id</column-name>

      </cmp-field>
      <cmp-field>
      <field-name>question</field-name>
      <column-name>question</column-name>

      </cmp-field>
      <cmp-field>
      <field-name>choice</field-name>
      <column-name>choice</column-name>

      </cmp-field>


      <ejb-name>ChoiceBean</ejb-name>
      <table-name>newchoice</table-name>

      <cmp-field>
      <field-name>choiceid</field-name>
      <column-name>choice_id</column-name>

      </cmp-field>
      <cmp-field>
      <field-name>questionid</field-name>
      <column-name>question_id</column-name>

      </cmp-field>
      <cmp-field>
      <field-name>choice1</field-name>
      <column-name>choice1</column-name>

      </cmp-field>
      <cmp-field>
      <field-name>choice2</field-name>
      <column-name>choice2</column-name>

      </cmp-field>
      <cmp-field>
      <field-name>choice3</field-name>
      <column-name>choice3</column-name>

      </cmp-field>
      <cmp-field>
      <field-name>choice4</field-name>
      <column-name>choice4</column-name>

      </cmp-field>

      <!-- jboss 3.2 features -->
      <!-- optimistic locking does not express the exclusions needed -->


      </enterprise-beans>

      </jbosscmp-jdbc>


      In web.xml
      <resource-ref >
      <res-ref-name>jdbc/MyDSName</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
      </resource-ref>

      In jboss-web.xml

      <resource-ref>
      <res-ref-name>jdbc/MyDSName</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <jndi-name>java:/PostgresDS</jndi-name>
      </resource-ref>