Home > Java > Changing jBoss DefaultDS

Changing jBoss DefaultDS


jBoss Application Server 5.x comes shipped with HQSQL as default database backend  called DefaultDS. However, sometimes using HSQL isn’t a good approach when you are deploying the application server on production. The following steps will guide you to change DefaultDS to use another database backend such as PostgreSQL 8.x.

1. Create a PostgreSQL database as usual

This procedure is out-of-scope of this post.

2. Configure login-config.xml

Add the following lines to your running jBoss login-config.xml

PostgreSQLRealm">
<authentication>
<login-module
 code="org.jboss.resource.security.ConfiguredIdentityLoginModule"
 flag="required">
<module-option name="principal">postgres-user</module-option>
<module-option name="userName">postgres-user</module-option>
<module-option name="password">postgres-password</module-option>
<module-option name="managedConnectionFactoryName">
 jboss.jca:service=LocalTxCM,name=DefaultDS
</module-option>
</login-module>
</authentication>
</application-policy>

3. Configure JMS

  • Copy postgresql-persistence-service.xml from the jboss_instalation/docs/examples/jms/ to jboss_instalation/server/all/deploy/messaging
  • Remove or rename hsqldb-persistence-service.xml from jboss_instalation/server/all/deploy/messaging

4. Create a new DefaultDS file

  • Create a new file called postgresql-ds.xml on the deploy folder.

(Example file. You can change it based on your needs)

<?xml version="1.0" encoding="UTF-8"?>
<datasources>
<local-tx-datasource>
<jndi-name>DefaultDS</jndi-name>
<connection-url>
 jdbc:postgresql://hostname:5432/database
</connection-url>
<driver-class>org.postgresql.Driver</driver-class>
<min-pool-size>5</min-pool-size>
<max-pool-size>20</max-pool-size>
<idle-timeout-minutes>0</idle-timeout-minutes>
<track-statements/>
<security-domain>PostgreSQLRealm</security-domain>
<security-domain-and-application>
 PostgreSQLRealm
</security-domain-and-application>
<prepared-statement-cache-size>32</prepared-statement-cache-size>
<metadata>
<type-mapping>PostgreSQL</type-mapping>
</metadata>
</local-tx-datasource>
</datasources>
  • Remove or rename the hsqldb-ds.xml file on deploy folder.

5. Start jBoss and enjoy

Advertisements
Categories: Java
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: