3 Replies Latest reply on Dec 2, 2002 5:16 AM by HunJae Lee

    Postgresql and JBOSS

    zzz Newbie

      Hi,

      I want to configure JBOSS 3.0.4 to work with PostgreSQL.
      I took postgres-service.xml, changed it and put it in JBOSS/server/default/deploy, also put the driver in JBOSS/server/default/lib and I have the following exception

      3:44:19,941 ERROR [DefaultDS] Unable to bind connection factory to JNDI name 'java:/DefaultDS'
      javax.naming.NameAlreadyBoundException
      at org.jnp.server.NamingServer.bind(NamingServer.java:130)
      at org.jnp.interfaces.NamingContext.bind(NamingContext.java:424)
      at org.jnp.interfaces.NamingContext.bind(NamingContext.java:395)
      at org.jboss.naming.Util.bind(Util.java:83)
      at org.jboss.naming.Util.bind(Util.java:70)
      at org.jboss.resource.connectionmanager.RARDeployment.startManagedConnectionFactory(RARDeployment.java:590)
      at java.lang.reflect.Method.invoke(Native Method)
      at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
      at org.jboss.resource.connectionmanager.BaseConnectionManager2.startService(BaseConnectionManager2.java:382)
      at org.jboss.resource.connectionmanager.LocalTxConnectionManager.startService(LocalTxConnectionManager.java:179)
      at org.jboss.system.ServiceMBeanSupport.start(ServiceMBeanSupport.java:165)
      at java.lang.reflect.Method.invoke(Native Method)
      at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
      at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
      at $Proxy5.start(Unknown Source)
      at org.jboss.system.ServiceController.start(ServiceController.java:398)
      at org.jboss.system.ServiceController.start(ServiceController.java:418)
      at org.jboss.system.ServiceController.start(ServiceController.java:418)
      at java.lang.reflect.Method.invoke(Native Method)
      at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
      at org.jboss.util.jmx.MBeanProxy.invoke(MBeanProxy.java:174)
      at $Proxy8.start(Unknown Source)
      at org.jboss.resource.RARDeployer.start(RARDeployer.java:212)
      at org.jboss.deployment.MainDeployer.start(MainDeployer.java:807)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:621)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:585)
      at java.lang.reflect.Method.invoke(Native Method)
      at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
      at org.jboss.util.jmx.MBeanProxy.invoke(MBeanProxy.java:174)
      at $Proxy4.deploy(Unknown Source)

      Thanks, I appreciate!

        • 1. Re: Postgresql and JBOSS
          Al Byers Newbie

          I would like to tack my question on to this topic. I got the same error that zzzz did, so I changed things to PostgresDS instead of DefaultDS with similar results.


          I am trying to configure JBoss as an app server for "Open for
          Business" (www.ofbiz.org). Ofbiz has an entity persistence engine with
          is configured by the entityengine.xml file which has a line like this
          in its Postgres datasource definition tag:
          <jndi-jdbc jndi-server-name="default" jndi-name="PostgresDS"
          isolation-level="ReadCommitted"/>

          When I start JBoss, there are these lines in the output:
          ...
          13:59:42,825 INFO [GenericDelegator] Doing database check as
          requested in entityengine.xml with addMissing=true
          13:59:42,917 INFO [ConnectionFactory] Doing JNDI lookup for name
          PostgresDS
          13:59:43,000 WARN [ConnectionFactory]
          [ConnectionFactory.getConnection] Failed to find DataSource named
          PostgresDS in JNDI server with name default. Trying normal database.
          javax.naming.NameNotFoundException: PostgresDS not bound
          at org.jnp.server.NamingServer.getBinding(NamingServer.java:495)
          ...

          I have included the postgres-service.xml file in my deploy dir. It has
          the line:
          PostgresDS

          standardjaws.xml has:

          java:/PostgresDS
          <type-mapping>PostgreSQL</type-mapping>
          false
          ...

          One thing I am not clear on is where/how the Postgres name/object gets loaded into the JNDI service.
          Can anyone see what I am doing wrong or suggest a diagnostic course of action?
          TIA
          Al

          • 2. Re: Postgresql and JBOSS
            HunJae Lee Newbie

            I wonder why the NameAlreadyBoundException occurs. There should be bound the same jndi name already to other. Remove your configuration, and restart jboss, and check this.
            :8080/jmx-console --> Jndiview --> list()
            You will find the jndi name.

            I had succeeded JBOSS 3.0.4 & PostgreSQL.

            Following is the only section I modified in postgres-service.xml, more precisly I changed JndiName only! and any other tag and attribute should be original.
            =========================================================
            jdbc/SolDS01


            <config-property name="ConnectionURL" type="java.lang.String">jdbc:postgresql://localhost:5432/soldb</config-property>
            <config-property name="DriverClass" type="java.lang.String">org.postgresql.Driver</config-property>
            <!--set these only if you want only default logins, not through JAAS -->
            <config-property name="UserName" type="java.lang.String"></config-property>
            <config-property name="Password" type="java.lang.String"></config-property>




            ======================================
            and add to conf/login-config.xml a clause like this...
            =========================================


            <application-policy name = "PostgresDbRealm">

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

            </application-policy>

            ==============================
            and any other files keep untouched..

            This is well worked for me.
            good luck.
            > Hi,
            >
            > I want to configure JBOSS 3.0.4 to work with
            > PostgreSQL.
            > I took postgres-service.xml, changed it and put it in
            > JBOSS/server/default/deploy, also put the driver in
            > JBOSS/server/default/lib and I have the following
            > exception
            >
            > 3:44:19,941 ERROR [DefaultDS] Unable to bind
            > connection factory to JNDI name 'java:/DefaultDS'
            > javax.naming.NameAlreadyBoundException
            > at
            > at
            > at
            > t
            > org.jnp.server.NamingServer.bind(NamingServer.java:130
            >
            > at
            > at
            > at
            > t
            > org.jnp.interfaces.NamingContext.bind(NamingContext.ja
            > a:424)
            > at
            > at
            > at
            > t
            > org.jnp.interfaces.NamingContext.bind(NamingContext.ja
            > a:395)
            > at org.jboss.naming.Util.bind(Util.java:83)
            > at org.jboss.naming.Util.bind(Util.java:70)
            > at
            > at
            > at
            > t
            > org.jboss.resource.connectionmanager.RARDeployment.sta
            > tManagedConnectionFactory(RARDeployment.java:590)
            > at java.lang.reflect.Method.invoke(Native
            > (Native Method)
            > at
            > at
            > at
            > t
            > org.jboss.mx.capability.ReflectedMBeanDispatcher.invok
            > (ReflectedMBeanDispatcher.java:284)
            > at
            > at
            > at
            > t
            > org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServer
            > mpl.java:517)
            > at
            > at
            > at
            > t
            > org.jboss.resource.connectionmanager.BaseConnectionMan
            > ger2.startService(BaseConnectionManager2.java:382)
            > at
            > at
            > at
            > t
            > org.jboss.resource.connectionmanager.LocalTxConnection
            > anager.startService(LocalTxConnectionManager.java:179)
            >
            > at
            > at
            > at
            > t
            > org.jboss.system.ServiceMBeanSupport.start(ServiceMBea
            > Support.java:165)
            > at java.lang.reflect.Method.invoke(Native
            > (Native Method)
            > at
            > at
            > at
            > t
            > org.jboss.mx.capability.ReflectedMBeanDispatcher.invok
            > (ReflectedMBeanDispatcher.java:284)
            > at
            > at
            > at
            > t
            > org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServer
            > mpl.java:517)
            > at
            > at
            > at
            > t
            > org.jboss.system.ServiceController$ServiceProxy.invoke
            > ServiceController.java:978)
            > at $Proxy5.start(Unknown Source)
            > at
            > at
            > at
            > t
            > org.jboss.system.ServiceController.start(ServiceContro
            > ler.java:398)
            > at
            > at
            > at
            > t
            > org.jboss.system.ServiceController.start(ServiceContro
            > ler.java:418)
            > at
            > at
            > at
            > t
            > org.jboss.system.ServiceController.start(ServiceContro
            > ler.java:418)
            > at java.lang.reflect.Method.invoke(Native
            > (Native Method)
            > at
            > at
            > at
            > t
            > org.jboss.mx.capability.ReflectedMBeanDispatcher.invok
            > (ReflectedMBeanDispatcher.java:284)
            > at
            > at
            > at
            > t
            > org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServer
            > mpl.java:517)
            > at
            > at
            > at
            > t
            > org.jboss.util.jmx.MBeanProxy.invoke(MBeanProxy.java:1
            > 4)
            > at $Proxy8.start(Unknown Source)
            > at
            > at
            > at
            > t
            > org.jboss.resource.RARDeployer.start(RARDeployer.java:
            > 12)
            > at
            > at
            > at
            > t
            > org.jboss.deployment.MainDeployer.start(MainDeployer.j
            > va:807)
            > at
            > at
            > at
            > t
            > org.jboss.deployment.MainDeployer.deploy(MainDeployer.
            > ava:621)
            > at
            > at
            > at
            > t
            > org.jboss.deployment.MainDeployer.deploy(MainDeployer.
            > ava:585)
            > at java.lang.reflect.Method.invoke(Native
            > (Native Method)
            > at
            > at
            > at
            > t
            > org.jboss.mx.capability.ReflectedMBeanDispatcher.invok
            > (ReflectedMBeanDispatcher.java:284)
            > at
            > at
            > at
            > t
            > org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServer
            > mpl.java:517)
            > at
            > at
            > at
            > t
            > org.jboss.util.jmx.MBeanProxy.invoke(MBeanProxy.java:1
            > 4)
            > at $Proxy4.deploy(Unknown Source)
            >
            > Thanks, I appreciate!

            • 3. Re: Postgresql and JBOSS
              HunJae Lee Newbie

              I wonder why the NameAlreadyBoundException occurs. There should be bound the same jndi name already to other. Remove your configuration, and restart jboss, and check this.
              :8080/jmx-console --> Jndiview --> list()
              You will find the jndi name.

              I had succeeded JBOSS 3.0.4 & PostgreSQL.

              Following is the only section I modified in postgres-service.xml, more precisly I changed JndiName only! and any other tag and attribute should be original.
              =========================================================
              jdbc/SolDS01


              <config-property name="ConnectionURL" type="java.lang.String">jdbc:postgresql://localhost:5432/soldb</config-property>
              <config-property name="DriverClass" type="java.lang.String">org.postgresql.Driver</config-property>
              <!--set these only if you want only default logins, not through JAAS -->
              <config-property name="UserName" type="java.lang.String"></config-property>
              <config-property name="Password" type="java.lang.String"></config-property>




              ======================================
              and add to conf/login-config.xml a clause like this...
              =========================================


              <application-policy name = "PostgresDbRealm">

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

              </application-policy>

              ==============================
              and any other files keep untouched..

              This is well worked for me.
              good luck.