Announcement Announcement Module
Collapse
No announcement yet.
PropertyPlaceholderConfigurer value not getting retreived Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • PropertyPlaceholderConfigurer value not getting retreived

    I have defined:
    <code>
    <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.Pr opertyPlaceholderConfigurer">
    <property name="location" value="file://C:\Documents and Settings\bbalmer\eclipse\newton.props"/>
    </bean>
    </code>

    And in newton.props:
    rmi.OrderInvoice=rmi://10.1.33.48:10001/OrderInvoice

    Trying to look up this property in one of my beans:
    <code>
    <property name="serviceUrl"><value>${rmi.OrderInvoice}</value></property>
    </code>

    When I make a call that uses this bean I get:
    java.net.MalformedURLException: invalid URL string: ${rmi.OrderInvoice}

    The newton.props is getting picked up (I see it in the logs) but the rmi.OrderInvoice doesn't seem to get resolved.

    Any ideas?

    -----
    I also moved the newton.props file from the file system and moved it into my web application (classpath:newton.props) with the same result.

    -----
    Last edited by bbalmer; Aug 2nd, 2007, 01:55 PM. Reason: Adding more information

  • #2
    Are you using a BeanFactory instead of an ApplicationContext? Is it possible to see the code and configuration, in [code] [ /code] tags?
    Last edited by karldmoore; Aug 27th, 2007, 03:31 PM.

    Comment


    • #3
      Sorry for the wrong tags. This is running inside a web application so I'm using WebApplicationContext.

      Code:
      <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="location" value="file://C:\Documents and Settings\bbalmer\eclipse\newton.props"/>
      </bean>
      and
      Code:
      <property name="imageLoc">
        <description>Location of image for content</description>
        <value>${imageLoc}</value>
      </property>

      Comment


      • #4
        I'd guess you are loading the properties in the parent context and using the property in the child context and you have a visibility problem. You could try putting the loader bean in the same file where the properties are used.

        Comment


        • #5
          Let me post more of the xml. Both are within the same one. Do I need to add more to my imageService bean to see the PropertyPlaceholderConfigurer bean?

          Code:
          	<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
          		<property name="location" value="file://C:\Documents and Settings\bbalmer\eclipse\newton.props"/>
          	</bean>
          	
          	<bean id="messageSource" 
          		class="org.springframework.context.support.ResourceBundleMessageSource">
          		<property name="basename">
          			<value>webItmMrch</value>
          		</property>
          	</bean>
          
          	
          	<bean id="imageService" class="app.web.itm.mrch.svc.ImageService">
          		<property name="imageDAO" ref="imageDAO"/>
          		<property name="cacheService" ref="cacheService"/>	
          		<property name="imageLoc">
          			<description>Location of image for content</description>
          			<value>${imageLoc}</value>
          		</property>
          	</bean>

          Comment


          • #6
            PropertyPlaceholderConfigurer should complain about unresolved properties unless told not to. Are you using BeanFactory instead of ApplicationContext?
            Last edited by karldmoore; Aug 27th, 2007, 03:31 PM.

            Comment


            • #7
              Sorry for the possible ignorant response but how would I know if I'm using BeanFactory or ApplicationContext?

              This is a web application where my web.xml is using the following (I'm guessing the WebApplicationContext):
              Code:
              	<listener>
              		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
              	</listener>
              	
              	<servlet>
              		<servlet-name>webItmMrch</servlet-name>
              		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
              		<load-on-startup>1</load-on-startup>
              	</servlet>

              Comment


              • #8
                This seems odd to me because from the examples (swapping out jdbc properties) it looks to me like you would just add the bean to the xml and create the properties file and then reference there.

                If, in my web application, I have multiple xml files (all described in the web.xml) if the bean is in one and I reference a property in another, should that matter?

                Comment


                • #9
                  If you do have multiple containers that could be the problem.
                  http://www.springframework.org/docs/...postprocessors
                  Last edited by karldmoore; Aug 27th, 2007, 03:31 PM.

                  Comment

                  Working...
                  X