12 Replies Latest reply on May 8, 2002 9:59 AM by jessica hekman

    Postgres as default datasource with JBoss 3.0

    jessica hekman Newbie

      I apologize for the earlier posting with no content; apparently my browser navigated the "attach files" screen poorly.

      I've been trying to convince JBoss 3.0 (checked out of the repository around April 14 and built then) to use PostgresQL instead of Hypersonic as its default database. I seem to have successfully convinced JBoss to create a Postgres datasource, but it is still using the old Hypersonc database to persist data.

      I have been unable to find documentation on how to do this, and the configuration has changed significantly since 2.4. If documentation exists and I've just missed it, could someone please point me at it? (I have followed the instructions at
      http://www.jboss.org/modules/bb/index.html?module=bb&op=viewtopic&t=forums/ are helpful for getting the Postgres datasource installed, but not for making it the default datasource.)

      The parts of the startup output which I think are relevant are below:

      21:24:58,166 INFO [MainDeployer] Starting deployment of package: file:/home/jphekman/src/other/jboss-all/build/output/jboss-3.0.0beta2/server/default/deploy/postgres-service.xml
      21:24:59,480 WARN [ServiceController] jboss.jca:service=LocalTxDS,name=PostgresDS does not implement any Service methods
      21:24:59,482 INFO [JBossManagedConnectionPool] Creating
      21:24:59,482 INFO [JBossManagedConnectionPool] Created
      21:24:59,485 INFO [JBossManagedConnectionPool] Starting
      21:24:59,486 INFO [JBossManagedConnectionPool] Started
      21:24:59,488 INFO [MainDeployer] Successfully completed deployment of package: file:/home/jphekman/src/other/jboss-all/build/output/jboss-3.0.0beta2/server/default/deploy/postgres-service.xml

      ...

      21:25:05,711 INFO [DefaultDS] Bound connection factory for resource adapter 'Minerva JDBC LocalTransaction ResourceAdapter' to JNDI name 'java:/DefaultDS'

      ...

      21:25:06,452 INFO [NoTransDS] Bound connection factory for resource adapter 'Minerva JDBC LocalTransaction ResourceAdapter' to JNDI name 'java:/NoTransDS'

      ...

      21:25:06,526 INFO [JaasSecurityManagerService] Added PostgresDbRealm, org.jboss.security.plugins.SecurityDomainContext@cf2a to map
      21:25:07,801 WARN [RARDeployment] Not setting config property 'Password'
      21:25:07,805 INFO [PostgresDS] Bound connection factory for resource adapter 'Minerva JDBC LocalTransaction ResourceAdapter' to JNDI name 'java:/PostgresDS'
      21:25:07,805 INFO [LocalTxConnectionManager] Started
      21:25:07,807 INFO [MainDeployer] Successfully completed deployment of package: file:/home/jphekman/src/other/jboss-all/build/output/jboss-3.0.0beta2/server/default/deploy/jboss-jdbc.rar

      --

      I am assuming that the messages along the lines of "Bound connection factory for resource adapter 'Minerva JDBC LocalTransaction ResourceAdapter'" are talking about binding to various datasources. There are three of those. It does still mention DefaultDS, although I can't find the place in the config files where references to DefaultDS haven't been commented out (well, except for new-hsqldb-default-service.xml, which defines it, but does not ask anything to USE it).

      As for config files...

      In deploy, we have new-hsqldb-default-service.xml, which I haven't removed; perhaps I should? There is also postgres-service.xml there.

      In conf, there is standardjaws.xml, standardjbosscmp-jdbc.xml, and standardjboss.xml (I don't think the last one is relevant, but included it just in case).

      In my application.ear, there is jbosscmp-jdbc.xml.

      Both jbosscmp files contain this:


      <!-- java:/DefaultDS -->
      java:/PostgresDS
      <datasource-mapping>PostgreSQL</datasource-mapping>
      <!-- <datasource-mapping>Hypersonic SQL</datasource-mapping> -->


      postgres-service.xml begins like so:



      The top of standardjaws:


      <!-- java:/DefaultDS
      <type-mapping>Hypersonic SQL</type-mapping> -->
      java:/PostgresDS
      <type-mapping>PostgreSQL</type-mapping>
      false

      Does anyone have any suggestions for me?

      Thanks,
      Jessica

        • 1. Re: Postgres as default datasource with JBoss 3.0
          jessica hekman Newbie

          I am having a hell of a time convincing Mozilla to attach files and not dump content! I'll try again...

          • 2. Re: Postgres as default datasource with JBoss 3.0
            David Jencks Master

            1. I suggest you get rc2 or rebuild from cvs. The local Minerva wrapper is gone, you will have to upgrade sometime, why not now. The config files have some more changes, I'd start over with the examples (in docs/examples/jca in the zip).

            2. I often cheat and remove all datasource configurations except the one I want, and bind it under DefaultDS.

            3. Everything looks ok to me at first glance. I'd check in jndiview to make sure your postgres ds really is bound, and what it is bound under, and check the jboss.jca mbeans for it to verify they really are there and started.

            • 3. Re: Postgres as default datasource with JBoss 3.0
              jessica hekman Newbie

              I got rc2. After a few hitches which forums searches solved, I ran up against this error in the startup output:

              17:33:22,489 INFO [EjbModule] Deploying RecommendationBean
              17:33:24,251 INFO [EjbModule] Deploying FandomBean
              17:33:24,332 INFO [EjbModule] Deploying UtilAutoNumber
              17:33:24,393 INFO [EjbModule] Deploying AutorecUtilBean
              17:33:27,076 ERROR [EntityContainer] Exception in service lifecyle operation: create
              17:33:27,085 ERROR [STDERR] java.sql.SQLException: ResourceException javax.resource.ResourceException: Could not create connection
              17:33:27,086 ERROR [STDERR] at org.jboss.resource.adapter.jdbc.local.LocalDataSource.getConnection(LocalDataSource.java:105)
              [...]

              Now, it is possible that this is an EJB problem which I should take to a different forum; it does appear that the first few beans were deployed successfully. The one that failed was the only one which is a session bean, and there were some earlier errors about it (new to me in RC2; I didn't get these errors with RC1):

              17:33:22,393 INFO [EJBDeployer]
              Bean : AutorecUtilBean
              Method : public abstract RecommendationLocal createRecommendation(String, String, String, String, String, String, Collection)
              Section: 7.10.7
              Warning: null

              17:33:22,394 INFO [EJBDeployer]
              Bean : AutorecUtilBean
              Section: 7.10.1
              Warning: The session bean must implement either a remote home and remote, or a local home and a local interface.

              I got similar errors with another session bean which I have since stopped using. Note that the method it complains about is in fact defined (though not abstract) and both the local home and local interface are implemented.

              So maybe it's an EJB problem. But it *does* say it can't make a connection, which sounds like a datasource problem. So perhaps the connection error just happens to come after the EJB error, and is in fact unrelated.

              Any more suggestions?

              j

              • 4. Re: Postgres as default datasource with JBoss 3.0
                David Jencks Master

                I think the verifier got installed between rc1 and rc2... thus the warnings. (I don't know if they are correct or not;-)

                The exception is from an entity bean being deployed, presumably when the cmp engine tries to see if the table is there. So I think there is something wrong with the db config. I suspect a wrong url, since security problems usually give me a more specific exception message.

                • 5. Re: Postgres as default datasource with JBoss 3.0
                  Emerson Cargnin Newbie

                  i'm having the same kind of problem with oracle...

                  • 6. Re: Postgres as default datasource with JBoss 3.0
                    jessica hekman Newbie

                    All right: I hadn't created the database or told Postgres to allow TCP/IP connections.

                    Then I discovered that I had to set the username parameter; this is required by Postgres. I did NOT have to set the password parameter. The username parameter is in the postgres-service.xml file that comes with RC2, but is commented out. (Maybe a comment saying "postgres requires this to be set" would be helpful, or uncommenting it and setting the username to "[username]", which is the style the document uses for other required elements.)

                    Anyways, things work perfectly now. Thank you very much, David, for your help.

                    • 7. Re: Postgres as default datasource with JBoss 3.0
                      David Jencks Master

                      Did you set up container managed security with a PostgresRealm in login-conf.xml? I advise doing this rather than relying on fixed username/pw in the postgres-service.xml file. The info goes to the same place anyway, which is why I wonder if you set it up properly.

                      • 8. Re: Postgres as default datasource with JBoss 3.0
                        jessica hekman Newbie

                        No, I didn't know I should have edited login-config.xml.I added the suggested text from postgres-service.xml:

                        <application-policy name = "PostgresDbRealm">

                        <login-module code = "org.jboss.resource.security.ConfiguredIdentityLoginModule" flag = "required">
                        <!-- <module-option name = "principal">autorec</module-option> -->
                        <module-option name = "userName">autorec</module-option>
                        <!-- <module-option name = "password"></module-option> -->
                        <module-option name = "managedConnectionFactoryName">jboss.jca:service=LocalTxCM,name=PostgresDS</module-option>
                        </login-module>

                        </application-policy>

                        (I tried it with "principal" set to "autorec" and with it unset.) When I comment out setting the username in postgres-service.xml and add this login-config.xml, I once again fail to get a Connection:

                        java.sql.SQLException: ResourceException javax.resource.ResourceException: Could not create connection

                        When I uncomment the username setting in postgres-service, it works again. Should I worry about this? Am I doing something wrong?

                        j

                        • 9. Re: Postgres as default datasource with JBoss 3.0
                          David Jencks Master

                          I think you need all 3 module options, even if the password is blank. As I recall the login module objects if any are missing. Is there a stack trace of an exception earlier?

                          • 10. Re: Postgres as default datasource with JBoss 3.0
                            jessica hekman Newbie

                            Okay, I defined all three objects:


                            <login-module code = "org.jboss.resource.security.ConfiguredIdentityLoginModule" flag = "required">
                            <module-option name = "principal">autorec</module-option>
                            <module-option name = "userName">autorec</module-option>
                            <module-option name = "password"></module-option>
                            <module-option name = "managedConnectionFactoryName">jboss.jca:service=LocalTxCM,name=PostgresDS</module-option>
                            </login-module>


                            However, I still get an Exception. The very first Exception that happens is right after it tries to deploy EJB:

                            java.sql.SQLException: ResourceException javax.resource.ResourceException: Could not create connection

                            The postgres deployment is pretty problem-free (except for the "does not implement any service methods" warning, which we see in other places as well, notably in hsqldb deployment).

                            08:34:27,506 INFO [MainDeployer] Starting deployment of package: file:/home/jphekman/src/autorec/jboss-3.0.0RC2/server/default/deploy/postgres-service.xml
                            08:34:28,316 WARN [ServiceController] jboss.jca:service=LocalTxDS,name=PostgresDS does not implement any Service methods
                            08:34:28,318 INFO [JBossManagedConnectionPool] Creating
                            08:34:28,318 INFO [JBossManagedConnectionPool] Created
                            08:34:28,321 INFO [JBossManagedConnectionPool] Starting
                            08:34:28,322 INFO [JBossManagedConnectionPool] Started
                            08:34:28,323 INFO [MainDeployer] Successfully completed deployment of package: file:/home/jphekman/src/autorec/jboss-3.0.0RC2/server/default/deploy/postgres-service.xml

                            j

                            • 11. Re: Postgres as default datasource with JBoss 3.0
                              David Jencks Master

                              Just to check something really stupid... in my browser I'm seeing an escaped angle bracket on the
                              <module-option name = "managedConnectionFactoryName">jboss.jca:service=LocalTxCM,name=PostgresDS&l t;/module-option>

                              line... this is really valid xml in your actual config, right?

                              • 12. Re: Postgres as default datasource with JBoss 3.0
                                jessica hekman Newbie

                                Yeah, the XML in the config is well-formed; the forum software must have made that change for some reason. I triple-checked.

                                j