Jboss, setting environment variables for application

Beau Trepp picture Beau Trepp · Jun 12, 2014 · Viewed 9.3k times · Source

I've been setting up my rails application to run under jruby/warbler inside a java container (JBoss/wildfly). I'm used to running my rails apps on linux machines, more or less with init.d scripts and the like, and I've been using DATABASE_URL to set the connection without putting my credentials in the source.

Warbler itself is created a pre-packaged WAR, I can deploy that to wildfly(jboss) fine.. but there is no examples of how to set environment variables in the context of that application.

I've googled links, but they are cryptic as hell, there's even a stack overflow question here, but the accepted answer seems to be make your own service between to do this?.

Is there an easy way to pass config to wars in jboss?, or do all java enterprisey applications just store the credentials/urls in the war themselves O.O

Answer

cego picture cego · Jun 13, 2014

You could setup a datasource on the application server https://docs.jboss.org/author/display/WFLY8/DataSource+configuration

And in your application you will need to use ActiveRecord-JDBC-Adapter https://github.com/jruby/activerecord-jdbc-adapter

Or you can also set environment variables in the application servers's startup script (bin/standalone.sh or bin/domain.sh)