Tag Archives: JBoss

Running WildFly/ Jboss as service

Here is a step by step guide to get WildFly 9 running as service

1. sudo ln -s /home/kamal/wildfly-9.0.1.Final /opt/wildfly
2. sudo cp /opt/wildfly/bin/init.d/wildfly.conf /etc/default/wildfly.conf
3. sudo vi /etc/default/wildfly.conf
JBOSS_USER=wildfly ##root

4. sudo cp /opt/wildfly/bin/init.d/wildfly-init-redhat.sh /etc/init.d/wildfly
5. sudo chkconfig –add wildfly
6. sudo chkconfig wildfly on
7. sudo mkdir -p /var/log/wildfly
8. sudo adduser wildfly
9. sudo chown -R wildfly:wildfly /opt/wildfly-8.2.0.Final
10. sudo chown -R wildfly:wildfly /home/kamal/wildfly-9.0.1.Final
11. sudo chown wildfly:wildfly /opt/wildfly
12. sudo chown wildfly:wildfly /var/log/wildfly

Finally sudo service wildfly start

Check logs
$ vi /var/log/wildfly/console.log

If you are facing issues with permission, you might want to set user as root in wildfly.conf file



Setting up new Datasource – connection pool in JBOSS 7

If you have a new JBoss 7.x (I am using 7.1.0) installation, you would like to first create an account for admin console. It is easy

1. goto Jboss server in browser (say localhost:8080)
2. Click on admin console (It will tell you to execute add-user.bat or add-user.sh which is inside jboss/bin folder)
3. You will select option a for ManagementRealm user.
4. This is tricky, when it asks for realm, you have to type ManagementRealm (I made this mistake to type something random)
5. Now provide username and password

Go to admin console and you can see existing datasources.

Creating a new datasource would require you to add driver jar file in module folder under appropriate structure, and add a module.xml. For you help, JBoss 7 comes with a preinstalled database driver which you can see under module/com/h2database/h2/main/, here you can see jar file and module.xml. I had to create org/postgresql/main/ and add jar and module.xml.

Now go to standalone.xmlunser /jboss/standalone/configuration and look for existing database drivers

<driver name=”h2″ module=”com.h2database.h2″>

You will add information for your drivers here like

<driver name=”postgresql” module=”org.postgresql”>

Similarly you will see datasource configuration for exisitng database like

<datasource jndi-name=”java:jboss/datasources/ExampleDS” pool-name=”ExampleDS” enabled=”true” use-java-context=”true”>

Similarly you will add information for your database.