I am trying to setup my project to use different virtual-host names depending on the environment.
I know I could create directories with a separate jboss-web.xml file in each directory. But I recently moved this project to maven and wanted to take advantage of the profiles. I already have the databases set up so they can be configured differently by the profile by using filters.
jboss-web.xml:
<jboss-web>
<context-root>/</context-root>
<virtual-host>${jbossweb.virtualhost}</virtual-host>
</jboss-web>
The environment specific property file has an entry for:
jbossweb.virtualhost=hostname.domain.com
the pom file build section has this definition
<filters>
<filter>src/main/filters/filter-${env}.properties</filter>
</filters>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/webapp/WEB-INF</directory>
<filtering>true</filtering>
</resource>
</resources>
Just for good measure, the profiles section has this configuration:
<profile>
<id>dev</id>
<properties>
<env>dev</env>
</properties>
</profile>
I'm not even sure if what I'm trying to do is possible. When I try it, Jboss-web.xml has the variable name in the virtual-host location and not the value.
Am I barking up the wrong tree?
Thanks,
Eric
Actually, I've discovered a way to do this:
The jboss-web.xml looks like this now:
<jboss-web>
<context-root>${jbossweb.contextroot}</context-root>
<virtual-host>${jbossweb.virtualhost}</virtual-host>
</jboss-web>
The property file looks like this:
jbossweb.virtualhost=hostname
jbossweb.contextroot=/
Then the pom section looks like this for the maven war plugin configuration:
<webResources>
<resource>
<directory>src/main/webapp/WEB-INF</directory>
<filtering>true</filtering>
<include>jboss-web.xml</include>
<targetPath>/WEB-INF</targetPath>
</resource>
</webResources>
And the filters are defined above the plug ins section, but within the build section as follows:
<filters>
<filter>src/main/filters/filter-${env}.properties</filter>
</filters>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With