Anyone have any suggestions for configuring an SSL encrypted connection pool to postgresql with tomcat 5.5.15?

Eric



On Apr 13, 2006, at 3:28 PM, Eric Roberts wrote:

PROBLEM:

I am having a problem setting up DB connection pooling with Postgresql through JNDI in Tomcat 5.5.15. I have a portlet application that is hosted in the GridSphere portlet container that, upon initialization, gets a database connection from JNDI. The database that I am connecting to REQUIRES an SSL connection so my question is mostly about passing the usessl argument in the JNDI config but I have included my setup to make sure I'm doing everything correctly.

ENVIRONMENT
Linux
Java 1.4.2
Tomcat 5.5.15

Assuming my webapp name is "account-portlet" Here's my setup:

I have a context file in $CATALINA_HOME/conf/Catalina/localhost/ account-portlet.xml and the contents look like the following:

<!-- The contents of this file will be loaded for each web application --> <Context path="/tg-account-portlets" docBase="tg-account-portlets" debug="1">

    <!-- Default set of monitored resources -->
    <WatchedResource>WEB-INF/web.xml</WatchedResource>

    <Resource name="jdbc/jndihandle"
              auth="Container"
              type="javax.sql.DataSource"
factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
              driverClassName="org.postgresql.Driver"
              username="account_user"
              password="secret"
              url="jdbc:postgresql://pgsql.server.org:5432/mydb"
              connectionProperties="useSSL=force"
              />

.....other Resource elements where I'm trying other combinations of properties....

</Context>

I also have the following in my web.xml:

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
  "http://java.sun.com/dtd/web-app_2_3.dtd";>

<web-app>
....

    <resource-ref>
      <description>DataSource</description>
      <res-ref-name>jdbc/jndidatasource</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
    </resource-ref>

</web-app>

I am getting a JNDI context as follows:

public void init() throws PortletException {
        try {
            Context initContext = new InitialContext();
Context envContext = (Context) initContext.lookup ("java:/comp/env");

            //if (context == null) {
            //throw new Exception ("Uh oh -- no context!");
            //}

DataSource ds = (DataSource) envContext.lookup("jdbc/ jndihandle");

            if (ds == null) {
                throw new Exception("Data source not found!");
            }

            conn = ds.getConnection();
        }catch(NamingException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
}

When I run my application I get the following error in catalina.out:

org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Connection rejected: FATAL: No pg_hba.conf entry for host <hidden>, user account_user, database mydb

this tells me that the JNDI stuff is working but the SSL property is not being set. I've tried appending ?useSSL=force to the url attribute, I've tried appending ;useSSL=force to the url attribute. I still get the same error message. I have been unable to find any examples of people passing the useSSL property in the JNDI config. Any Ideas?

Many Thanks,

Eric




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to