How to use org.springframework.beans.factory.config.PropertyPlaceholderConfigurer to load a properties file out of a custom module in JBoss EAP 6

Solution Verified - Updated -

Issue

  • We have an example.properties file in a jar, placed as a custom module. Our application is in an EAR with this entry added to the jboss-deployment-structure.xml
            <module name="example" export="true" />

One part of the application uses the following class to replace placeholders and uses the example.properties entries to do it. Configured like so:

  <bean id="examplePropertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="ignoreUnresolvablePlaceholders" value="false" />
    <property name="location" value="com/jboss/examples/example.properties" />
  </bean>

However, we get the following exception when it tries to find that file:

Exception in Initializing Spring Beans
org.springframework.beans.factory.BeanInitializationException: Could not load properties; nested exception is java.io.FileNotFoundException: class path resource [com/jboss/examples/example.properties] cannot be opened because it does not exist

How can we make the example.properties file visible to this spring class?

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP) 6.x
  • Spring Framework

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content