Results 1 to 3 of 3

Thread: Property-Placeholder not failing when properties file not present

  1. #1
    Join Date
    Jan 2012
    Posts
    10

    Default Property-Placeholder not failing when properties file not present

    Hi, I've run into somewhat of an odd issue, although someone else might be able to explain it. Essentially, I have 3 application context XML files:

    A.xml
    Code:
    <import resource="B.xml" />
    <import resource="C.xml" />
    B.xml
    Code:
    Does some imports...
    Defines some beans...
    C.xml
    Code:
    <context:property-placeholder location="classpath:nonexistent-file.properties" />
    
    <bean id="context" class="org.somepackage.SomeClass" init-method="initialize" scope="singleton">
      <constructor-arg value="${someprop.propname}"/>
    </bean>
    If I start the A.xml context, I receive an error that says "Could not resolve placeholder..." for the bean with id "context". This is somewhat suprising since the properties file doesn't exist so I would assume it should never make it this far. If I then comment out the import of B.xml, and start A.xml again, I then get an exception because the properties file is not found, which seems like the correct behavior.

    Does anyone have any ideas why this might happen?

    Thanks

  2. #2
    Join Date
    Jan 2012
    Posts
    10

    Default

    One thing I forgot to mention, B.xml also uses a property-placeholder.

    Also, I swapped the order of the imports, and now I'm getting a "property not resolved" exception through a transitive import with B.xml.

  3. #3
    Join Date
    Jan 2012
    Posts
    10

    Default

    My apologies, I've discovered what was happening. I was under the impression that this was being caused by the imports. As it turns out, it seems to have been because of multiple property placeholders. I added the ignore-unresolvable attribute and now things are working as expected. I'm wondering though, are these semantics captured in the documentation somewhere? I assume they are because I discovered this through a post on the forums. But it wasn't completely obvious to me from either the reference manual or Javadocs.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •