5 Replies Latest reply on Apr 21, 2002 8:04 PM by Chris Evans

    JBoss-Tomcat & PostgreSQL

    Chris Evans Newbie

      I have been trying to get JBoss, Tomcat and PostgreSQL to work together for some time without much progress. So I hope to ask a few questions, and maybe get past this hurdle. I have installed jboss-3.0.0RC1_tomcat-4.0.3 and postgres-7.2.1, I think correctly.

      I have downloaded the latest postgres-service.xml.
      http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/jboss/jbosscx/src/etc/example-config/. PostgreSQL by default listens on port 5432. My database is named "test".

      Question 1: I have changed just a few attributes in that file: ConnectionURL, UserName, Password. Is there anything else that I must/should change in the XML service file? Thanks in advance.

      Chris Evans_____________________________________________________
      <?xml version="1.0" encoding="UTF-8"?>

      <!-- ===================================================================== -->
      <!-- -->
      <!-- JBoss Server Configuration -->
      <!-- -->
      <!-- ===================================================================== -->

      <server>

      <!-- ==================================================================== -->
      <!-- New ConnectionManager setup for default PostgreSQL dbs -->
      <!-- Build jmx-api (build/build.sh all) and view for config documentation -->
      <!-- ==================================================================== -->

      <mbean code="org.jboss.resource.connectionmanager.LocalTxConnectionManager" name="jboss.jca:service=LocalTxCM,name=PostgresDS">
      <!--make the rar deploy! hack till better deployment-->
      <depends>jboss.jca:service=RARDeployer</depends>


      <depends optional-attribute-name="ManagedConnectionFactoryName">
      <!--embedded mbean-->
      <mbean code="org.jboss.resource.connectionmanager.RARDeployment" name="jboss.jca:service=LocalTxDS,name=PostgresDS">
      <!--hack-->
      <depends optional-attribute-name="OldRarDeployment">jboss.jca:service=RARDeployment,name=Minerva JDBC LocalTransaction ResourceAdapter</depends>

      <!--real attributes-->
      <attribute name="ManagedConnectionFactoryProperties">
      <properties>
      <config-property>
      <config-property-name>ConnectionURL</config-property-name>
      <config-property-type>java.lang.String</config-property-type>
      <config-property-value>jdbc:postgresql://localhost:5432/test</config-property-value>
      </config-property>
      <config-property>
      <config-property-name>DriverClass</config-property-name>
      <config-property-type>java.lang.String</config-property-type>
      <config-property-value>org.postgresql.Driver</config-property-value>
      </config-property>
      <config-property>
      <config-property-name>UserName</config-property-name>
      <config-property-type>java.lang.String</config-property-type>
      <config-property-value>postgres</config-property-value>
      </config-property>
      <config-property>
      <config-property-name>Password</config-property-name>
      <config-property-type>java.lang.String</config-property-type>
      <config-property-value>postgres</config-property-value>
      </config-property>
      </properties>

      </attribute>
      <attribute name="JndiName">PostgresDS</attribute>
      </mbean>
      </depends>

      <depends optional-attribute-name="ManagedConnectionPool">
      <!--embedded mbean-->
      <mbean code="org.jboss.resource.connectionmanager.JBossManagedConnectionPool" name="jboss.jca:service=LocalTxPool,name=PostgresDS">

      <attribute name="MinSize">0</attribute>
      <attribute name="MaxSize">50</attribute>
      <attribute name="BlockingTimeoutMillis">5000</attribute>
      <attribute name="IdleTimeoutMinutes">15</attribute>
      <!--criteria indicates if Subject (from security domain) or app supplied
      parameters (such as from getConnection(user, pw)) are used to distinguish
      connections in the pool. Choices are
      ByContainerAndApplication (use both),
      ByContainer (use Subject),
      ByApplication (use app supplied params only),
      ByNothing (all connections are equivalent, usually if adapter supports
      reauthentication)-->
      <attribute name="Criteria">ByContainer</attribute>
      </mbean>

      </depends>
      <depends optional-attribute-name="CachedConnectionManager">jboss.jca:service=CachedConnectionManager</depends>

      <!-- Include a login module configuration named PostgresDbRealm.
      Update your login-conf.xml, here is an example for a
      ConfiguredIdentityLoginModule:

      <application-policy name = "PostgresDbRealm">
      <authentication>
      <login-module code = "org.jboss.resource.security.ConfiguredIdentityLoginModule" flag = "required">
      <module-option name = "principal">yourprincipal</module-option>
      <module-option name = "userName">yourusername</module-option>
      <module-option name = "password">yourpassword</module-option>
      <module-option name = "managedConnectionFactoryName">jboss.jca:service=LocalTxCM,name=PostgresDS</module-option>
      </login-module>
      </authentication>
      </application-policy>

      NOTE: the application-policy name attribute must match the part of
      SecurityDomainJndiName after java:/jaas/, and the
      module-option name = "managedConnectionFactoryName"
      must match the object name of the ConnectionManager you are configuring here.
      -->
      <!--comment out this line if you want component managed security or want
      to use the default values in the ManagedConnectionFactoryProperties -->
      <attribute name="SecurityDomainJndiName">java:/jaas/PostgresDbRealm</attribute>
      <attribute name="TransactionManager">java:/TransactionManager</attribute>
      </mbean>


      </server>

        • 1. Re: JBoss-Tomcat & PostgreSQL
          Chris Evans Newbie

          In addition to configuring postgres-service.xml (see my previous post, this thread), I adapted the following from a couple posts on a previous MySQL thread.

          "What steps are required to get jboss3.0.0RC1_tomcat-4.0.3 and postgresSQL-7.2.1 going?"

          1 - Add latest postgres-service.xml to the $JBOSS_DIST/server/default/deploy directory.
          2 - Add driver (pgjdbc2.jar) to lib directory
          3 - Change the $JBOSS_DIST/server/default/conf/standardjaws.xml entry to "PostgresDS".
          (I assume it is ok to leave the <type-mapping> as "Hypersonic SQL"?)
          4.- Edit $JBOSS_DIST/server/default/conf/login-config.xml, adding a section like that for firebird or hsqldb. (I used the commented-out snippet from the bottom of postgres-service.xml).

          Question 2: do these steps look ok--anything wrong or missing?

          Question 3: how do I know whether it works?

          Thanks again.

          Chris Evans

          • 2. Re: JBoss-Tomcat & PostgreSQL
            Chris Evans Newbie

            Following on my previous messages ...

            I just tried firing up Tomcat, then JBoss (PostgreSQL has been running all along). I am getting an error. The context is below. Note the 3rd (timestamped) line, which says "PostgresDS does not implement any Service methods". This might be related to the error. But then it seems to finish deploying PostgreSQL (line 8), and chokes (line 10) on tomcat4-service.xml (which I have not touched).

            Thoughts please?
            ----------------------------------------------------------
            08:38:51,495 INFO [MainDeployer] Successfully completed deployment of package: file:/usr/local/pkg/jboss-3.0.0RC1_tomcat-4.0.3/server/default/deploy/cluster-service.xml
            08:38:51,496 INFO [MainDeployer] Starting deployment of package: file:/usr/local/pkg/jboss-3.0.0RC1_tomcat-4.0.3/server/default/deploy/postgres-service.xml
            08:38:51,937 WARN [ServiceController] jboss.jca:service=LocalTxDS,name=PostgresDS does not implement any Service methods
            08:38:51,938 INFO [JBossManagedConnectionPool] Creating
            08:38:51,938 INFO [JBossManagedConnectionPool] Created
            08:38:51,940 INFO [JBossManagedConnectionPool] Starting
            08:38:51,941 INFO [JBossManagedConnectionPool] Started
            08:38:51,941 INFO [MainDeployer] Successfully completed deployment of package: file:/usr/local/pkg/jboss-3.0.0RC1_tomcat-4.0.3/server/default/deploy/postgres-service.xml
            08:38:51,942 INFO [MainDeployer] Starting deployment of package: file:/usr/local/pkg/jboss-3.0.0RC1_tomcat-4.0.3/server/default/deploy/tomcat4-service.xml
            08:38:52,254 ERROR [SARDeployer] create operation failed for package file:/usr/local/pkg/jboss-3.0.0RC1_tomcat-4.0.3/server/default/deploy/tomcat4-service.xml
            org.jboss.deployment.DeploymentException: could not create mbean; - nested throwable is: RuntimeErrorException: instantiating org.jboss.web.catalina.EmbeddedCatalinaServiceSX failed: java.lang.NoClassDefFoundError: org/apache/catalina/LifecycleListener
            Cause: java.lang.NoClassDefFoundError: org/apache/catalina/LifecycleListener
            RuntimeErrorException: instantiating org.jboss.web.catalina.EmbeddedCatalinaServiceSX failed: java.lang.NoClassDefFoundError: org/apache/catalina/LifecycleListener
            Cause: java.lang.NoClassDefFoundError: org/apache/catalina/LifecycleListener
            at org.jboss.mx.server.MBeanServerImpl.handleInstantiateExceptions(MBeanServerImpl.java:858)
            at org.jboss.mx.server.MBeanServerImpl.instantiate(MBeanServerImpl.java:791)
            at org.jboss.mx.server.MBeanServerImpl.instantiate(MBeanServerImpl.java:213)
            at org.jboss.mx.server.MBeanServerImpl.createMBean(MBeanServerImpl.java:254)
            at org.jboss.system.ServiceCreator.install(ServiceCreator.java:104)
            at org.jboss.system.ServiceConfigurator.internalInstall(ServiceConfigurator.java:182)
            at org.jboss.system.ServiceConfigurator.install(ServiceConfigurator.java:149)
            at org.jboss.system.ServiceController.install(ServiceController.java:193)
            at sun.reflect.GeneratedMethodAccessor7.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:324)
            at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
            at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:492)
            at org.jboss.util.jmx.MBeanProxy.invoke(MBeanProxy.java:174)
            at $Proxy3.install(Unknown Source)
            at org.jboss.deployment.SARDeployer.create(SARDeployer.java:244)
            at org.jboss.deployment.MainDeployer.create(MainDeployer.java:626)
            at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:506)
            at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:470)
            at sun.reflect.GeneratedMethodAccessor8.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:324)
            at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
            at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:492)
            at org.jboss.util.jmx.MBeanProxy.invoke(MBeanProxy.java:174)
            at $Proxy4.deploy(Unknown Source)
            at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:350)
            at org.jboss.deployment.scanner.URLDeploymentScanner.scanDirectory(URLDeploymentScanner.java:530)
            at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:410)
            at org.jboss.deployment.scanner.AbstractDeploymentScanner.startService(AbstractDeploymentScanner.java:237)
            at org.jboss.system.ServiceMBeanSupport.start(ServiceMBeanSupport.java:162)
            at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:324)
            at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
            at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:492)
            at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:867)
            at $Proxy0.start(Unknown Source)
            at org.jboss.system.ServiceController.start(ServiceController.java:341)
            at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:324)
            at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
            at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:492)
            at org.jboss.util.jmx.MBeanProxy.invoke(MBeanProxy.java:174)
            at $Proxy3.start(Unknown Source)
            at org.jboss.deployment.SARDeployer.start(SARDeployer.java:281)
            at org.jboss.deployment.MainDeployer.start(MainDeployer.java:665)
            at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:507)
            at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:470)
            at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:452)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:324)
            at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
            at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:492)
            at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:320)
            at org.jboss.system.server.ServerImpl.start(ServerImpl.java:218)
            at org.jboss.Main.boot(Main.java:142)
            at org.jboss.Main$1.run(Main.java:375)
            at java.lang.Thread.run(Thread.java:536)

            • 3. Re: JBoss-Tomcat & PostgreSQL
              justin Newbie

              I fixed this by editing
              $JBOSS_DIST/server/default/deploy/tomcat4-service.xml

              and changing the path for the catalina.home entry to the fully qualified path to catalina. e.g.:

              <!DOCTYPE server [
              <!ENTITY catalina.home "/full/path/to/jboss/catalina">
              ]>


              hope this helps.
              justin

              • 4. Re: JBoss-Tomcat & PostgreSQL
                David Jencks Master

                For db connection issues for jboss 3 rc1 please check http://jboss.org/forums/thread.jsp?forum=67&thread=13366 and if you have more problems ask on the jca forum.

                To tell if your datasource loaded ok, look at the mbeans for it in the jmx viewer (port 8082) and check in jndiview to see it the datasource got bound.

                Thanks

                • 5. Re: JBoss-Tomcat & PostgreSQL
                  Chris Evans Newbie

                  Thanks Justin, that helped. David, I do have a follow-up question that I will put on the JCA group.