Question

I want Spring to check for system properties in JBoss EAP 6.2 (which uses JBoss AS 7.2) first and then properties that are located inside the jar.

I tried

<context:property-placeholder location="classpath:xxx.properties" />

But this uses the properties in the jar not the system properties from JBoss. I also tried

<context:property-placeholder location="classpath:xxx.properties" system-properties-mode="OVERRIDE" />

Which should be using the old PropertyPlaceholderConfigurer, but this also still uses the properties in the jar. I also tried to set the 3.0 (instead of 3.2) spring xsd but to no avail.

So how can I let Spring first check the properties in JBoss and then in the jar?

EDIT: I tried to replace OVERRIDE with the other options (ENVIRONMENT, NEVER and FALLBACK), but I always end up with a value defined in local properties.

Was it helpful?

Solution

After Artem Bilan's comments, i searched again (just to make sure, there are no duplicates) and found a class that loads the same properties, but within Java (Properties.load()). This causes to override the system properties i was trying to load via Spring.

OTHER TIPS

To expose properties files to applications, we have done the following:

  • Created a JBoss module in a directory struction called com/ourcompany/configuration/main and placed it along with all the other JBoss modules (in the modules directory).

  • Created a module.xml in that directory.

  • Placed all our *.properties files in that directory.

  • Created the following in standalone.xml (the JBoss configuration file) to make the configuration directory visible to all our applications, and to avoid a jboss-deployment-structure.xml file for every application.

Then all properties are on the classpath, as expected.

module.xml:

<module xmlns="urn:jboss:module:1.1" name="com.ourcompany.configuration">
    <resources>
        <resource-root path="."/>
    </resources>
</module>

standalone.xml:

<subsystem xmlns="urn:jboss:domain:ee:1.1">
    <global-modules>
        <module name="com.ourcompany.configuration" slot="main"/>
    </global-modules>
</subsystem>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top