Dashboard > blojsom 3.0 > ... > Installation > Tomcat Setup for PostgreSQL
  blojsom 3.0 Log In   View a printable version of the current page.  
  Tomcat Setup for PostgreSQL
Added by David Czarnecki, last edited by Timothy Stone on May 13, 2007  (view change)
Labels: 
(None)

This page describes the setup of blojsom using Tomcat as the application server and PostgreSQL as the database engine.

Configuration Changes

Items marked in bold in the configuration sections below are values to be changed.

Download and Install PostgreSQL

  • Download PostgreSQL and the PostgreSQL JDBC driver.
  • Create a new blojsom database and a user with full privileges for accessing the blojsom database.

Download, Install, and Configure Tomcat

  • Download and follow the installation instructions for Tomcat. Installation notes are available from the Tomcat website.
  • Open %TOMCAT_HOME%/conf/server.xml file and check out the settings for various defined <Connector .../> elements. Set the URIEncoding attribute to UTF-8, which is the character encoding format blojsom uses for encoding links. For example:
    <!-- Define a non-SSL Coyote HTTP/1.1 Connector on port 8080 -->
    <Connector port="8080"
       maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
       enableLookups="false" redirectPort="8443" acceptCount="100"
       debug="0" connectionTimeout="20000"
       disableUploadTimeout="true" URIEncoding="UTF-8"/>

blojsom Setup

  • Download the blojsom 3.0 blojsom.war file.
  • Create a web application directory for the blojsom 3.0 WAR file in %TOMCAT_HOME%/webapps.

    % mkdir blojsom

  • Copy the blojsom.war file into the %TOMCAT_HOME%/webapps/blojsom directory.
  • Unpack the blojsom.war file.

    jar xvf blojsom.war

  • Delete the blojsom.war file.

Database Driver Setup

  • After unpacking the PostgreSQL JDBC Driver, copy the postgresql-8.1-405.jdbc3.jar (or appropriate version) file to %TOMCAT_HOME%/common/lib.

Configure blojsom's Database Settings

  • Edit %TOMCAT_HOME%/webapps/blojsom/WEB-INF/classes/blojsom-helper-beans-include.xml and change the values for the driverClassName, url, username and password for your database to the username and password you created earlier. Be aware the port number that PostgreSQL listens on may be different for your installation of PostgreSQL.
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName" value="org.postgresql.Driver"/>
        <property name="url" value="jdbc:postgresql://localhost:5444/blojsom?charset=utf-8"/>
        <property name="username" value="someuser"/>
        <property name="password" value="somepassword"/>
    </bean>
    JDBC port number
    PostgreSQL listens by default on port 5432. Omit the port number shown above (":5444") to use the PostgreSQL default.

    When do I use the default? If you have not altered, or otherwise configured your PostgreSQL installation differently, then you are a likely candidate for using the default port.

  • Change the hibernate.dialect property in the definition of the hibernateSessionFactory bean to use the org.hibernate.dialect.PostgreSQLDialect dialect.
    <bean id="hibernateSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
            <property name="dataSource" ref="dataSource"/>
            <property name="mappingResources">
                <list>
                    <value>Blog.hbm.xml</value>
                    <value>Entry.hbm.xml</value>
                    <value>Category.hbm.xml</value>
                    <value>Comment.hbm.xml</value>
                    <value>Trackback.hbm.xml</value>
                    <value>Pingback.hbm.xml</value>
                    <value>User.hbm.xml</value>
                </list>
            </property>
            <property name="hibernateProperties">
                <props>
                    <prop key="c3p0.min_size">10</prop>
                    <prop key="c3p0.max_size">50</prop>
                    <prop key="c3p0.timeout">1800</prop>
                    <prop key="c3p0.max_statements">100</prop>
                    <prop key="show_sql">false</prop>
                    <prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
                </props>
            </property>
        </bean>
  • Edit %TOMCAT_HOME%/webapps/blojsom/WEB-INF/classes/blojsom.xml. Change the values for the dbScript and detectBlojsomSQL properties to the values below.
    <bean id="dbloader" class="org.blojsom.util.database.DatabaseLoader" init-method="init">
        <property name="sessionFactory">
            <ref bean="hibernateSessionFactory"/>
        </property>
        <property name="dbScript" value="/WEB-INF/classes/blojsom-full-initial-data-postgresql.sql"/>
        <property name="upgrading" value="false"/>
        <property name="servletConfig">
            <ref bean="servletConfigFactoryBean"/>
        </property>
        <property name="detectBlojsomSQL">
            <value>select relname from pg_stat_user_tables where relname = 'blog';</value>
        </property>
    </bean>

Accessing blojsom

Site running on a free Atlassian Confluence Open Source Project License granted to blojsom. Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5.4 Build:#809 Jun 12, 2007) - Bug/feature request - Contact Administrators