Category 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
Edit
JAVA_HOME=”/usr/java/jdk1.7.0_71″
JBOSS_HOME=”/opt/wildfly”
JBOSS_USER=wildfly ##root
JBOSS_MODE=standalone
JBOSS_CONFIG=standalone.xml
STARTUP_WAIT=60
SHUTDOWN_WAIT=60
JBOSS_CONSOLE_LOG=”/var/log/wildfly/console.log”

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

Source:

developer-should-know.tumblr.com/post/112230363742/how-to-install-wildfly-as-a-service-on-linux

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″>
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>

You will add information for your drivers here like

<driver name=”postgresql” module=”org.postgresql”>
<xa-datasource-class>
org.postgresql.xa.PGXADataSource
</xa-datasource-class>
</driver>

Similarly you will see datasource configuration for exisitng database like

<datasources>
<datasource jndi-name=”java:jboss/datasources/ExampleDS” pool-name=”ExampleDS” enabled=”true” use-java-context=”true”>
<connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1</connection-url>
<driver>h2</driver>
<security>
<user-name>sa</user-name>
<password>sa</password>
</security>
</datasource>

Similarly you will add information for your database.

Reference:

https://developer.jboss.org/blogs/amartin-blog/2012/02/08/how-to-set-up-a-postgresql-jdbc-driver-on-jboss-7