7 Replies Latest reply on Apr 24, 2002 9:45 AM by tsmets

    JBoss and PostgreSQL

    spierson

      I have a very simple Bean managed Entity bean. I cannot for the life of me get it to work under JBoss talking to a PostgreSQL database.

      I will say at the beginning I have the simple bean working under Weblogic and PostgreSQL just fine so I think I have security/access setup correctly for PostgreSQL.

      To create the JDBC pool I have edited my jboss.jcml file as follows:

      1. I added the driver as follows:

      org.hsqldb.jdbcDriver,org.gjt.mm.mysql.Driver,org.postgresql.Driver


      2. I have defined the pool as follows:

      org.jboss.pool.jdbc.xa.wrapper.XADataSourceImpl
      PostgresDS
      jdbc:postgresql://localhost/cadence
      cadence
      cadence
      5
      20


      I have played around changing the min/max size which hasn't helped.

      The driver loads successfully and the pool is created and bound to the name specified. My simple EJB and war are deployed. The war simply tries to view/add rows in the database via JSP.

      When I try and execute the JSP code I get a transaction excpetion that says:
      An error occured in the bean. Error Message is:
      Error executing SQL SELECT OBJECT_ID FROM GLOSSARY ORDER BY OBJECT_NAME: java.sql.SQLException: Table not found: GLOSSARY in statement [SELECT OBJECT_ID FROM GLOSSARY ORDER BY OBJECT_NAME];
      nested exception is: javax.ejb.EJBException: Error executing SQL SELECT OBJECT_ID FROM GLOSSARY ORDER BY OBJECT_NAME: java.sql.SQLException: Table not found: GLOSSARY in statement [SELECT OBJECT_ID FROM GLOSSARY ORDER BY OBJECT_NAME]

      Stack Trace is :
      javax.transaction.TransactionRolledbackException: Error executing SQL SELECT OBJECT_ID FROM GLOSSARY ORDER BY OBJECT_NAME: java.sql.SQLException: Table not found: GLOSSARY in statement [SELECT OBJECT_ID FROM GLOSSARY ORDER BY OBJECT_NAME];
      nested exception is: javax.ejb.EJBException: Error executing SQL SELECT OBJECT_ID FROM GLOSSARY ORDER BY OBJECT_NAME: java.sql.SQLException: Table not found: GLOSSARY in statement [SELECT OBJECT_ID FROM GLOSSARY ORDER BY OBJECT_NAME]
      javax.ejb.EJBException: Error executing SQL SELECT OBJECT_ID FROM GLOSSARY ORDER BY OBJECT_NAME: java.sql.SQLException: Table not found: GLOSSARY in statement [SELECT OBJECT_ID FROM GLOSSARY ORDER BY OBJECT_NAME]
      <>

      I have tried lowercasing everything. I have tried putting "" around the database, and column names. I get the same exception each time.

      I do have the PostgreSQL Postmaster running is '-i' to accept TCP/IP connections.

      I can connect to the db from within JBuilder just fine but I'm not using a pool, so that's why I think I am creating the pool in JBoss incorrectly.

      Any ideas? Thoughts?

      If it makes a difference I am running on Windows 2000.

        • 1. Re: JBoss and PostgreSQL
          brianhuang2002

          look like your settings for pgsql are correct. Did you configure pg_hba.conf on the pgsql DB directory (not installation directory) to accept connections from clients? If did, you may check if you specify the datasource. You may test by setting the datasource and type-mapping in standardjaws.xml as

          ...
          java:/PostgresDB
          <type-mapping>PostgreSQL</type-mapping>
          .....


          Brian

          • 2. Re: JBoss and PostgreSQL
            spierson

            I have modified my pg_hba.conf file as follows:

            local all trust
            host all 127.0.0.1 255.255.255.255 trust
            host all 0.0.0.0 0.0.0.0 trust

            I have added the lines you specifed to the standardjaws.xml file. I am new to JBoss and PostgreSQL so I am unsure what these lines do or what i should expect to see.

            Thanks so much for your comment/direction

            • 3. Re: JBoss and PostgreSQL
              roadrunner

              Hmm, just an idea:
              How could JBoss know which pool to use for CMP ?
              Comment out the DefaultDS section in jboss.jcml and change


              to


              regards
              Sven

              • 4. Re: JBoss and PostgreSQL
                dsundstrom

                > I have added the lines you specifed to the
                > standardjaws.xml file. I am new to JBoss and
                > PostgreSQL so I am unsure what these lines do or what
                > i should expect to see.

                > local all trust
                trust all connections over Unix-socket connections:

                > host all 127.0.0.1 255.255.255.255 trust
                trust all connection from the localhost over tcp/ip

                > host all 0.0.0.0 0.0.0.0 trust
                trust all connections from anywhere on the internet over tcp/ip

                Trust means "Allow any user on the local system to connect to any database under any username," so the last line is very bad. You only need the first two lines. Next time read the comments in the pg_hba.conf file.

                • 5. Re: JBoss and PostgreSQL
                  xuxiaomin

                  there is a typo error:
                  PostgresDS

                  PostgresDS should be PostgresDB.

                  Is your code now work?

                  • 6. Re: JBoss and PostgreSQL
                    pazu

                    Also, check in your deployment descriptor if you have <create-table>true</create-table> for the GLOSSARY entity bean.

                    • 7. Re: JBoss and PostgreSQL
                      tsmets

                      Is the following MBEAN correct ?



                      <mbean code="org.jboss.jdbc.JdbcProvider"
                      name="DefaultDomain:service=JdbcProvider">
                      <attribute name="Drivers">org.postgresql.Driver</attribute>
                      </mbean>


                      Thomas,