Just another WordPress site


Jboss 7 + PostgreSQL 9

After installing Jboss 7 and PostgreSQL 9 you need to

  1. Create a user and a database for JBoss
  2. Install the JDBC driver in JBoss
  3. Add a datasource to your JBoss configuration

1. Postgres setup

Open the command line in your PostgreSQL directory

cd bin
createuser -D -E -R -P -S jboss

Enter a new password, it will be used in your JBoss config

createdb -O jboss jboss "PostgreSQL datasource for JBoss"

2. Jdbc driver install

Go to your JBoss directory (called later <JBoss7>), then the modules folder.
Create a simple nested folders structure: org\postgresql\main

Open <JBoss7>/modules/org/postgresql/main

Download the current jdbc4 version
at the time of this post: postgresql-9.0-801.jdbc4.jar

Create a file named module.xml with following content

<?xml version="1.0" encoding="UTF-8"?>
    <module xmlns="urn:jboss:module:1.0" name="org.postgresql">
            <resource-root path="postgresql-9.0-801.jdbc4.jar"/>
        <dependencies><module name="javax.api"/></dependencies>

There should be two files in the main folder now.

3. Datasource configuration


Find <datasources> and add the datasource

<datasource jndi-name="java:jboss/datasources/PostgresDS" pool-name="PostgresDS">
		<password> password from the first step, entered after createuser </password>
		<check-valid-connection-sql>SELECT 1</check-valid-connection-sql>
    <driver name="postgresql-jdbc4" module="org.postgresql"/>

in <drivers> add

<driver name="postgresql-jdbc4" module="org.postgresql"/>

4. Start Jboss

When running JBoss in domain mode you should:
  • use the domain folder instead of standalone
  • consider installing the driver as a deployment
Comments (0) Trackbacks (0)

No comments yet.

Leave a comment


No trackbacks yet.