Thursday, April 5, 2012

Relative file paths on JBoss EAP 5.1.2

Apparently there was a change in which kind of file URLs are correct in JBoss EAP 5.1.2. This tiny little change caused a great deal of pain in my case throwing
"IllegalArgumentException: URI is not hierarchical" in one environment but not the other.

Very well. We use the PropertyPlaceholderConfigurer with relative paths for file locations to greatly simplify the configuration differences between deployement and development environments. This is all done by simply stating
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations">
        <value>config/application.properties</value>
    </property>
</bean> 

In the applicationContext.xml to load properties from a path relative to the execution path. Running the application with maven jetty makes development rapid and simply and almost no setup is required for new developers.

With the latest change in JBoss, this could have become a very big issue. However, after a long days fiddling, here's the solution with maintained behavior.
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations">
        <value>file:${user.dir}/config/application.properties</value>
    </property>
</bean>


2 comments:

  1. Your solution is identical to how your configuration looked before. Can you please update?

    ReplyDelete
    Replies
    1. Thanks for noticing! I have updated now. In the first example you can see that I use a simple relative path, which will result in the same path as the second example. Except that Jboss won't accept the path as a correct URI.

      Delete