1 Reply Latest reply on Feb 17, 2004 5:17 AM by razor_harm78

    Help needed for J2EE with JBoss

    mandarjboss

      I am trying to build a J2EE application with JBoss and PostgreSQL.
      In simple words i am trying to insert a row in the database through an Entity Bean.
      I have tested datasource configuration with a test servlet.There is absolutely no problem with it.But i am really confused with configuring so many files.Can anyone tell me if i am right?

      Strangely my application works....?
      I mean Whatever debug mseesages( System.out.println() ) i have given all are printed to server console.Most importantly after the statement
      "home.create(.....)"
      I have printed "Creation Successful" message.Even i can see this printed on server console.But when i go to the corresponding PostgreSQL table i can't see the row which i had tried to insert through my EJB.Where is it?
      Is it in HSQL?If yes ,then that is not what i want !
      I want the row to be in PostgreSQL table.Can anyone tell me where am i wrong?
      Here is a listing of ".xml" files

      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
      </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 jbosscmp-jdbc.xml I have following entries


      <ejb-name>QuestionBean</ejb-name>
      jdbc/MyDSName
      <datasource-mapping>PostgreSQL</datasource-mapping>
      <create-table>false</create-table>
      <table-name>newquestion</table-name>
      ...........
      ........
      ......

      In jboss.xml i have following entries

      <ejb-name>QuestionBean</ejb-name>
      <jndi-name>QuestionBean</jndi-name>
      <resource-ref>
      <res-ref-name>jdbc/MyDSName</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>jdbc/MyDSName</res-name>
      <res-jndi-name>jdbc/MyDSName</res-jndi-name>
      </resource-manager>
      </resource-managers>




      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>



        • 1. Re: Help needed for J2EE with JBoss
          razor_harm78

          You need to edit: standardjbosscmp-jdbc.xml (found in the conf directory).

          Edit the part:

          java:/DefaultDS
          <datasource-mapping>Hypersonic SQL</datasource-mapping>

          Replace it with:
          java:/myDS
          <datasource-mapping>PostgreSQL</datasource-mapping>

          Of course the datasource name should be same in your *-ds.xml file.

          Cheers,

          Harm de Laat
          Informatiefabriek
          The Netherlands