Jboss 7 classpath and external properties

C:\jboss-as-7.1.1.Final\bin>standalone.bat -P=C:\jboss-as-7.1.1.Final\modules\xxxxx\xxxx.properties

-P or –properties, would load the specified properties into jboss system environment

See boot.log with above properties:

12:31:56,005 INFO [org.jboss.modules] JBoss Modules version 1.1.1.GA

12:31:56,137 INFO [org.jboss.msc] JBoss MSC version 1.0.2.GA

12:31:56,168 INFO [org.jboss.as] JBAS015899: JBoss AS 7.1.1.Final "Brontes" starting

12:31:56,170 DEBUG [org.jboss.as.config] Configured system properties:

FPW.details.sql = SELECT xxxxxx

awt.toolkit = sun.awt.windows.WToolkit

camel.context.startonboot = true

camel.scan.class.resolver = org.apache.camel.jboss.JBossPackageScanClassResolver

java.net.preferIPv4Stack = true

java.runtime.name = Java(TM) SE Runtime Environment

java.runtime.version = 1.6.0_31-b05

java.specification.name = Java Platform API Specification

java.specification.vendor = Sun Microsystems Inc.

java.specification.version = 1.6

java.util.logging.manager = org.jboss.logmanager.LogManager

java.vendor = Sun Microsystems Inc.

java.vendor.url = http://java.sun.com/

java.vendor.url.bug = http://java.sun.com/cgi-bin/bugreport.cgi

java.version = 1.6.0_31

java.vm.info = mixed mode

java.vm.name = Java HotSpot(TM) 64-Bit Server VM

java.vm.specification.name = Java Virtual Machine Specification

java.vm.specification.vendor = Sun Microsystems Inc.

java.vm.specification.version = 1.0

java.vm.vendor = Sun Microsystems Inc.

java.vm.version = 20.6-b01

javax.management.builder.initial = org.jboss.as.jmx.PluggableMBeanServerBuilder

javax.xml.datatype.DatatypeFactory = __redirected.__DatatypeFactory

javax.xml.parsers.DocumentBuilderFactory = __redirected.__DocumentBuilderFactory

javax.xml.parsers.SAXParserFactory = __redirected.__SAXParserFactory

javax.xml.stream.XMLEventFactory = __redirected.__XMLEventFactory

javax.xml.stream.XMLInputFactory = __redirected.__XMLInputFactory

javax.xml.stream.XMLOutputFactory = __redirected.__XMLOutputFactory

javax.xml.transform.TransformerFactory = __redirected.__TransformerFactory

javax.xml.validation.SchemaFactory:http://www.w3.org/2001/XMLSchema = __redirected.__SchemaFactory

javax.xml.xpath.XPathFactory:http://java.sun.com/jaxp/xpath/dom = __redirected.__XPathFactory

jboss.home.dir = C:\jboss-as-7.1.1.Final

12:31:56,231 DEBUG [org.jboss.as.config] VM Arguments: -XX:+TieredCompilation -Dprogram.name=standalone.bat -Xms64M -Xmx512M -XX:MaxPermSize=256M -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djava.net.preferIPv4Stack=true -Dorg.jboss.resolver.warning=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djboss.server.default.config=standalone.xml -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n -Dorg.jboss.boot.log.file=C:\jboss-as-7.1.1.Final\standalone\log\boot.log -Dlogging.configuration=file:C:\jboss-as-7.1.1.Final\standalone/configuration/logging.properties

12:31:56,874 INFO [org.xnio] XNIO Version 3.0.3.GA

12:31:56,874 INFO [org.jboss.as.server] JBAS015888: Creating http management service using socket-binding (management-http)

12:31:56,882 INFO [org.xnio.nio] XNIO NIO Implementation Version 3.0.3.GA

12:31:56,888 INFO [org.jboss.remoting] JBoss Remoting version 3.2.3.GA

12:31:56,956 INFO [org.jboss.as.security] JBAS013101: Activating Security Subsystem

12:31:56,969 INFO [org.jboss.as.webservices] JBAS015537: Activating WebServices Extension

12:31:56,983 INFO [org.jboss.as.logging] JBAS011502: Removing bootstrap log handlers

12:31:56,983 INFO [org.jboss.as.connector] JBAS010408: Starting JCA Subsystem (JBoss IronJacamar 1.0.9.Final)

12:31:56,996 INFO [org.jboss.as.security] JBAS013100: Current PicketBox version=4.0.7.Final

Above properties are loaded into system properties and were from composerinterfacesmgr.properties.

However, if using above parameter alone, it still wont put the properties into classpath, so below spring application context configuration wont work:

<bean class="com.bfm.app.jmim.conf.Configurer">

<property name="locations">

<list>

<value>classpath:xxxx.properties</value>

</list>

</property>

</bean>

To resolve, as for current, the only solution is to create new modules, and put the properties inside the module, and specify to depend on this module in jboss-deployment-structure.xml: https://community.jboss.org/wiki/HowToPutAnExternalFileInTheClasspath

<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.1">

<deployment>

<exclusions>

<module name="org.apache.log4j" />

<module name="org.slf4j" />

<module name="org.slf4j.impl" />

<module name="org.slf4j.ext" />

<module name="org.slf4j.jcl-over-slf4j" />

<module name="org.apache.commons.logging" />

<module name="org.jboss.logging.jul-to-slf4j-stub" />

<module name="org.jboss.logging" />

<module name="org.jboss.as.logging" />

</exclusions>

<dependencies>

<module name="org.osgi.core" />

<module name="com.xxxx.xxxx" />

</dependencies>

<!-- <resources> -->

<!-- <resource-root path="xxxx.properties" /> -->

<!-- </resources> -->

</deployment>

</jboss-deployment-structure>

With above two together, the application would work. If only create a module, and put the properties into classpath, it might not work either. For example, log4j.xml,

<appender name="emailAppender" class="org.apache.log4j.net.SMTPAppender">

<param name="Threshold" value="DEBUG"/>

<param name="To" value="${smtp.error.recipient}" />

<param name="BufferSize" value="1" />

<layout class="org.apache.log4j.PatternLayout">

<param name="ConversionPattern" value="%d %-5p [%t] %c{2} (%F:%L) - %m%n" />

</layout>

</appender>

Above requires a system property or at least the classloader of log4j aware of. So the first change, specify the -P / –properties needed to put that properties into system environment.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store