Uploaded image for project: 'Spring Tool Suite'
  1. Spring Tool Suite
  2. STS-750

Unexpected exception parsing XML document - IllegalArgumentException: Could not resolve placeholder

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Complete
    • Affects Version/s: 2.3.0.RELEASE
    • Fix Version/s: Sprint 8, 2.3.1.RELEASE
    • Component/s: None
    • Labels:
      None
    • Environment:
      Win32 & Linux

      Description

      If I create a Spring Beans Configuration File in STS and add an <import> tag with a property place holder...

      <?xml version="1.0" encoding="UTF-8"?>
      <beans xmlns="http://www.springframework.org/schema/beans"
      	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
       
      	<import	resource="classpath:/envs/${PLATFORM}/cfg.xml" />
      </beans>

      then STS adds an error under the problems tab which says the following...

      Unexpected exception parsing XML document from file [/home/daniel/Eclipse Projects/spel/src/test/java/importTest.xml]; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'PLATFORM'	importTest.xml	/spel/src/test/java

      I don't think this message is correct as I have PLATFORM set as a system property and when executed Spring is able to locate everything fine.

      Please let me know if you need additional information.

      Thanks!

        Activity

        Hide
        cdupuis Christian Dupuis added a comment -

        Spring's SystemPropertyUtils is responsible for this error message as it looks that the JVM which is executing the XML parsing (the JVM in which STS is running) and can't find the placeholder in the system properties.

        Unfortunately SystemPropertyUtils does not allow configuration of properties sources. We may need to change Spring Core to support this usecase or at least make sure that parsing does not fail so badly.

        Christian

        Show
        cdupuis Christian Dupuis added a comment - Spring's SystemPropertyUtils is responsible for this error message as it looks that the JVM which is executing the XML parsing (the JVM in which STS is running) and can't find the placeholder in the system properties. Unfortunately SystemPropertyUtils does not allow configuration of properties sources. We may need to change Spring Core to support this usecase or at least make sure that parsing does not fail so badly. Christian
        Hide
        dmikusa Daniel Mikusa added a comment -

        Based on talking to the support customer, he is looking to have this classified as a warning rather than an error. Cleaning up the wording of the message would also be nice. Would it be possible to have these two changes made?

        Also, in the meantime, I will suggest that he add a system property or environment variable to his STS installation. While not ideal, it sounds like that should clear up his error messages.

        Thanks!

        Show
        dmikusa Daniel Mikusa added a comment - Based on talking to the support customer, he is looking to have this classified as a warning rather than an error. Cleaning up the wording of the message would also be nice. Would it be possible to have these two changes made? Also, in the meantime, I will suggest that he add a system property or environment variable to his STS installation. While not ideal, it sounds like that should clear up his error messages. Thanks!
        Hide
        cdupuis Christian Dupuis added a comment -

        Daniel,

        if it is enough to just suppress the error/warning I'll do that right away.

        Implemented custom subclass to DefaultBeanDefinitionDocumentReader to suppress import statements with placeholders in the resource attribute. A warning will now be generated.

        Hope that is ok.

        Christian

        Show
        cdupuis Christian Dupuis added a comment - Daniel, if it is enough to just suppress the error/warning I'll do that right away. Implemented custom subclass to DefaultBeanDefinitionDocumentReader to suppress import statements with placeholders in the resource attribute. A warning will now be generated. Hope that is ok. Christian
        Hide
        tleese22 Taylor Leese added a comment -

        I am having the same issue, but with a slightly different scenario using STS 2.3.2. Not sure if this should be a new issue or this should be reopened?

        Using something like below:
        <context:component-scan base-package="$

        {application.package}

        " />

        Gives this error:
        Unexpected exception parsing XML document from file [C:/development/my/stuff/src/main/webapp/WEB-INF/applicationContext.xml]; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'application.package' applicationContext.xml /my/stuff/main/webapp/WEB-INF Unknown Spring Beans Problem

        Show
        tleese22 Taylor Leese added a comment - I am having the same issue, but with a slightly different scenario using STS 2.3.2. Not sure if this should be a new issue or this should be reopened? Using something like below: <context:component-scan base-package="$ {application.package} " /> Gives this error: Unexpected exception parsing XML document from file [C:/development/my/stuff/src/main/webapp/WEB-INF/applicationContext.xml] ; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'application.package' applicationContext.xml /my/stuff/main/webapp/WEB-INF Unknown Spring Beans Problem

          People

          • Assignee:
            Unassigned
            Reporter:
            dmikusa Daniel Mikusa
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: