4 Replies Latest reply on Feb 17, 2011 4:27 AM by ssl oss

    Doesn't connect automatically after restarting PostgreSQL

    ssl oss Newbie

      Hi, all.

       

      I set Gatein3.1.0 to use PostgreSQL for both JCR and IDM.(this works fine)

      While running Gatein3.1.0, after I restart PostgreSQL, the Gatein doesn't work anymore.

       

      So, I put "validationQuery="select version()" testOnBorrow="true"" in conf/server.xml and producer.server.xml

      but this does't work either.

       

      My env:

        Centos5.5

        GateIn-3.1.0-FINAL-tomcat(OpenJDK1.6.0)

        PostgreSQL(8.1.21)

       

      Does anyone know how to set this up so that i can restart postgreSQL without restarting Gatein?

       

      Thank you,

      Kenta

        • 1. Doesn't connect automatically after restarting PostgreSQL
          Marko Strukelj Master

          When something doesn't work, there has to be an error message with a stack trace in the log.

           

          Without the stacktrace we can't know what, and where exactly went wrong, we can only guess.

           

          My guess is that the datasource connection recovery may be the problem. If you restarted the DB then connection pools containing active connections would keep containing the connections. A way to fix that might be to configure automatic connection checking on the datasource.

          • 2. Re: Doesn't connect automatically after restarting PostgreSQL
            ssl oss Newbie

            Hi, Marko.

             

            I've been trying to solve the connection checking problem but I can't...

             

            I tested these following operations to see what stack traces I get:

            [Operations:]

                   start PostgreSQL --> start GateIn --> access the portal(login as John) --> restart PostgreSQL --> access the portal --> SEE WHAT HAPPENS

             

            [Test Cases:]

            1. (TestNo.1) with no modification
            2. (TestNo.2) with modification only to server.xml
            3. (TestNo.3) with modification to both server.xml and producer.server.xml
            4. (TestNo.4) with modification only to producer.server.xml

             

            [Stack Trace:]

               SEE THE ATTACHMENTS

             

             

            This is what I've done and what I get.

             

            in conf/server.xml:

             

              <GlobalNamingResources>

                <!-- Editable user database that can also be used by

                     UserDatabaseRealm to authenticate users

                -->

                <Resource name="UserDatabase" auth="Container"

                          type="org.apache.catalina.UserDatabase"

                          description="User database that can be updated and saved"

                          factory="org.apache.catalina.users.MemoryUserDatabaseFactory"

                          pathname="conf/tomcat-users.xml"

                          validationQuery="select version()" testOnBorrow="true" />                  <-------------put this

              </GlobalNamingResources>

             

             

            in conf/producer.server.xml:

             

              <GlobalNamingResources>

             

                <!-- Test entry for demonstration purposes -->

                <Environment name="simpleValue" type="java.lang.Integer" value="30"/>

             

                <!-- Editable user database that can also be used by

                     UserDatabaseRealm to authenticate users -->

                <Resource name="UserDatabase" auth="Container"

                          type="org.apache.catalina.UserDatabase"

                   description="User database that can be updated and saved"

                   validationQuery="select version()" testOnBorrow="true" >                            <-----------------------put this

                </Resource>

                <ResourceParams name="UserDatabase">

                  <parameter>

                    <name>factory</name>

                    <value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>

                  </parameter>

                  <parameter>

                    <name>pathname</name>

                    <value>conf/tomcat-users.xml</value>

                  </parameter>

                </ResourceParams>

             

              </GlobalNamingResources>

             

             

            As you guessed, I, too, think the active connections are closed when I restart the DB.

            And I don't know how to set automatic connection checking other than what I did...

             

            Thank you,

            Kenta

            • 3. Re: Doesn't connect automatically after restarting PostgreSQL
              ssl oss Newbie

              Hi.

               

              I've tried above configuration several times, but it doesn't work...

               

              Does anyone know how to setup tomcat to reconnect to DB automatically?

              I'm really stack...

               

              Thank you,

              Kenta

              • 4. Doesn't connect automatically after restarting PostgreSQL
                ssl oss Newbie

                I could successfully done this

                by modifing "idm-configuration.xml" (for IDM)and "jcr-configuration.xml" (for JCR).

                 

                It only needs to be added "property" with some parameters depending on what you want

                in those xml files and there we go.

                 

                e.g.

                   <property name="validationQuery" value="select version();"/>

                   <property name="testOnBorrow" value="true"/>

                 

                Thank you,

                Kenta