3 Replies Latest reply on Nov 10, 2001 11:43 AM by Andreas Schaefer

    Postgres & JAWS Wowes

    John Moore Newbie



      Am having troubles with Postgres using the correct table name. We have a set of CMP entity beans against oracle that all work great. Thought I would try one against postgres to see how it goes.

      JBoss 2.4.3 w/ Embedded Tomcat 3.2.3
      RH Linux 7.1
      Sun 1.3.1 JVM
      jdbc7.0-1.2.jar

      I took our working configuration and modified it for a simple new bean. I have standalone jdbc program that connects to the server just fine. My table name is "tester" and my bean ejb-name is PG. According to JAWS, it wants to select from "PG" instead of the "tester" table. I have a jaws.xml in my deployed jar with a table-name included. I'm stumped.

      The container starts up cleanly, binds the datasource and the client can connect and get the home interface, when I call the findAll() method if bombs since the PG table doesn't exist.
      [JAWS] findAll command executing: SELECT id FROM PG
      [JAWS] java.sql.SQLException: ERROR: Relation 'pg' does not exist
      [JAWS]
      [JAWS] at org.postgresql.Connection.ExecSQL(Connection.java:393)


      I have posted the configuation(s) in case anyone sees something that is just plain wrong.

      ejb-jar.xml
      -----------
      <?xml version="1.0" encoding="UTF-8"?>
      <ejb-jar>
      Sample Postgres Application
      <display-name>Postgres</display-name>
      <enterprise-beans>

      <ejb-name>PG</ejb-name>
      test.PGHome
      test.PG
      <ejb-class>test.PGBean</ejb-class>
      False
      <cmp-field>
      <field-name>id</field-name>
      </cmp-field>

      <cmp-field>
      <field-name>lname</field-name>
      </cmp-field>

      <cmp-field>
      <field-name>fname</field-name>
      </cmp-field>


      <primkey-field>id</primkey-field>
      <prim-key-class>java.lang.Integer</prim-key-class>
      <persistence-type>Container</persistence-type>
      <resource-ref>
      <res-ref-name>jdbc/PostgresDataSource</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
      </resource-ref>

      </enterprise-beans>

      <assembly-descriptor>
      <container-transaction>

      <ejb-name>PG</ejb-name>
      <method-name>*</method-name>

      <trans-attribute>Supports</trans-attribute>
      </container-transaction>
      </assembly-descriptor>

      </ejb-jar>

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

      <resource-managers>
      <resource-manager res-class="org.jboss.ejb.deployment.JDBCResource">
      <res-name>jdbc/PostgresDataSource</res-name>
      <res-jndi-name>java:/PostgresDataSource</res-jndi-name>
      </resource-manager>
      </resource-managers>
      <enterprise-beans>

      <ejb-name>PG</ejb-name>
      <jndi-name>test/PG</jndi-name>
      <configuration-name>Standard CMP EntityBean</configuration-name>

      </enterprise-beans>


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

      PostgresDataSource
      <type-mapping>PostgreSQL</type-mapping>
      true

      <default-entity>
      <create-table>false</create-table>
      <remove-table>false</remove-table>
      <tuned-updates>true</tuned-updates>
      <read-only>false</read-only>
      <time-out>300</time-out>
      <select-for-update>false</select-for-update>
      </default-entity>

      <type-mappings>
      ....
      </type-mappings>


      <ejb-name>PG</ejb-name>
      <table-name>tester</table-name>
      <create-table>false</create-table>

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

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

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




      jboss.jcml
      ----------

      PostgresDataSource
      org.jboss.pool.jdbc.xa.wrapper.XADataSourceImpl
      jdbc:postgresql://linuxdev1:5432/mydatabase
      johnm
      johnm

      :

        • 1. Re: Postgres & JAWS Wowes
          Andreas Schaefer Apprentice

          In ejb-jar.xml drop the following:
          <primkey-field>id</primkey-field>
          <resource-ref>
          <res-ref-name>jdbc/PostgresDataSource</res-ref-name>
          <res-type>javax.sql.DataSource</res-type>
          <res-auth>Container</res-auth>
          </resource-ref>

          In jboss.xml drop the following:
          <resource-managers>
          <resource-manager res-class="org.jboss.ejb.deployment.JDBCResource">
          <res-name>jdbc/PostgresDataSource</res-name>
          <res-jndi-name>java:/PostgresDataSource</res-jndi-name>
          </resource-manager>
          </resource-managers>

          And try again - Andy

          • 2. Re: Postgres & JAWS Wowes
            John Moore Newbie

            Andy,

            Thanks for the input, it didn't make a bit of difference but looks cleaner. I did, however, find my problem.

            In my jaws.xml file I somehow neglected the enterprise-beans tag around the entity. We normally produce our descriptor files via xsl and since I did this by hand, completely missed it when looking at the other generated output.

            Thanks for the assist.
            John Moore


            • 3. Re: Postgres & JAWS Wowes
              Andreas Schaefer Apprentice

              Have a look at XDoclet to generate the DD.

              Andy