Announcement Announcement Module
Collapse
No announcement yet.
Bug with PropertyPlaceholderConfigurer ? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Bug with PropertyPlaceholderConfigurer ?

    Hi,

    I seem to have found a problem with the PropertyPlaceholderConfigurer. I have configured this in my context as follows:

    <bean id="propertyPlaceholder" class="org.springframework.beans.factory.config.Pr opertyPlaceholderConfigurer">
    <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_FALLBACK"/>
    <property name="searchSystemEnvironment" value="true"/>
    </bean>

    This allows me to get environment variables such as the CATALINA_HOME as in the following bean definition:

    <bean id="catalogueManager" class="com.medseaconsulting.catalogue.business.Pro ductCatalogueManagerImpl" init-method="loadCatalogue">
    <property name="categoryFile" value="${CATALINA_HOME}/webapps/crystal2spain/resources/categories.xml"/>
    <property name="productFile" value="${CATALINA_HOME}/webapps/crystal2spain/resources/products.xml"/>
    </bean>

    When this is deployed to Tomcat 4.1.27 it only gets as far as the following (with Log4j in DEBUG mode)

    Invoking BeanPostProcessors before instantiation of bean 'propertyPlaceholder'
    Using cached introspection results for class [org.springframework.beans.factory.config.PropertyP laceholderConfigurer]
    About to invoke write method [public void org.springframework.beans.factory.config.PropertyP laceholderConfigurer.setSystemPropertiesModeName(j ava.lang.String) throws java.lang.IllegalArgumentException] on object of class [org.springframework.beans.factory.config.PropertyP laceholderConfigurer]
    Invoked write method [public void org.springframework.beans.factory.config.PropertyP laceholderConfigurer.setSystemPropertiesModeName(j ava.lang.String) throws java.lang.IllegalArgumentException] with value of type [java.lang.String]
    Converting String to [boolean] using property editor [org.springframework.beans.propertyeditors.CustomBo oleanEditor@1397e5c]
    About to invoke write method [public void org.springframework.beans.factory.config.PropertyP laceholderConfigurer.setSearchSystemEnvironment(bo olean)] on object
    of class [org.springframework.beans.factory.config.PropertyP laceholderConfigurer]
    Invoked write method [public void org.springframework.beans.factory.config.PropertyP laceholderConfigurer.setSearchSystemEnvironment(bo olean)] with value of type [boolean]
    Invoking setBeanName on BeanNameAware bean 'propertyPlaceholder'
    Invoking setBeanFactory on BeanFactoryAware bean 'propertyPlaceholder'
    Invoking BeanPostProcessors before initialization of bean 'propertyPlaceholder'
    Invoking BeanPostProcessors after initialization of bean 'propertyPlaceholder'

    (never gets any further for the servlet initialisation)

    This then generates an HTTP Status 500 error message when trying to access my web context from the browser with the following exception:

    org.apache.jasper.JasperException: Servlet.init() for servlet crystal2spain threw exception
    at org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:254)
    at org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:295)
    at org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:241)


    If I replace the ${CATALINA_HOME} with the full path within the bean definition all works fine.

    Can anybody tell me what is happening and if this is a bug and how can I get over it.

    I am using Spring 1.2.5

    Regards

    Steve

  • #2
    Re: Bug with PropertyPlaceholderConfigurer ?

    Originally posted by smcardle
    Hi,

    I seem to have found a problem with the PropertyPlaceholderConfigurer. I have configured this in my context as follows:

    <bean id="propertyPlaceholder" class="org.springframework.beans.factory.config.Pr opertyPlaceholderConfigurer">
    <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_FALLBACK"/>
    <property name="searchSystemEnvironment" value="true"/>
    </bean>

    This allows me to get environment variables such as the CATALINA_HOME as in the following bean definition:

    <bean id="catalogueManager" class="com.medseaconsulting.catalogue.business.Pro ductCatalogueManagerImpl" init-method="loadCatalogue">
    <property name="categoryFile" value="${CATALINA_HOME}/webapps/crystal2spain/resources/categories.xml"/>
    <property name="productFile" value="${CATALINA_HOME}/webapps/crystal2spain/resources/products.xml"/>
    </bean>

    When this is deployed to Tomcat 4.1.27 it only gets as far as the following (with Log4j in DEBUG mode)

    Invoking BeanPostProcessors before instantiation of bean 'propertyPlaceholder'
    Using cached introspection results for class [org.springframework.beans.factory.config.PropertyP laceholderConfigurer]
    About to invoke write method [public void org.springframework.beans.factory.config.PropertyP laceholderConfigurer.setSystemPropertiesModeName(j ava.lang.String) throws java.lang.IllegalArgumentException] on object of class [org.springframework.beans.factory.config.PropertyP laceholderConfigurer]
    Invoked write method [public void org.springframework.beans.factory.config.PropertyP laceholderConfigurer.setSystemPropertiesModeName(j ava.lang.String) throws java.lang.IllegalArgumentException] with value of type [java.lang.String]
    Converting String to [boolean] using property editor [org.springframework.beans.propertyeditors.CustomBo oleanEditor@1397e5c]
    About to invoke write method [public void org.springframework.beans.factory.config.PropertyP laceholderConfigurer.setSearchSystemEnvironment(bo olean)] on object
    of class [org.springframework.beans.factory.config.PropertyP laceholderConfigurer]
    Invoked write method [public void org.springframework.beans.factory.config.PropertyP laceholderConfigurer.setSearchSystemEnvironment(bo olean)] with value of type [boolean]
    Invoking setBeanName on BeanNameAware bean 'propertyPlaceholder'
    Invoking setBeanFactory on BeanFactoryAware bean 'propertyPlaceholder'
    Invoking BeanPostProcessors before initialization of bean 'propertyPlaceholder'
    Invoking BeanPostProcessors after initialization of bean 'propertyPlaceholder'

    (never gets any further for the servlet initialisation)

    This then generates an HTTP Status 500 error message when trying to access my web context from the browser with the following exception:

    org.apache.jasper.JasperException: Servlet.init() for servlet crystal2spain threw exception
    at org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:254)
    at org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:295)
    at org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:241)


    If I replace the ${CATALINA_HOME} with the full path within the bean definition all works fine.

    Can anybody tell me what is happening and if this is a bug and how can I get over it.

    I am using Spring 1.2.5

    Regards

    Steve
    I have noticed another issue with this problem. Durring Tomcat startup it never initialises the beans in my context eventhough my servlet had <load-on-startup>1</load-on-startup>. Instead it tries to initialise the servlet when first called and then only gets so far through the initialisation before coming to a stop. This means that the servlet never initialises and that is why I get the HTTP status 500 error from the browser.

    If I do not use the propertys in the string i.e. replace the ${CATALINA_HOME} part with the actual path on my development machine the servlet is fully initialsed correctly at Tomcat startup.

    Any help here would be great....

    Steve

    Comment

    Working...
    X