Announcement Announcement Module
Collapse
No announcement yet.
applicationContext.xml not filtering Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • applicationContext.xml not filtering

    I have an application in which I am trying to use the PropertyPlaceholderConfigurer to filter application properties in 2 seperate *.xml files.

    The 2 files are:
    applicationContext.xml
    mytest-servlet.xml (spring servlet configuration)

    mytest-servlet.xml filters without any problem. For some strange reason applicationContext.xml does not filter and I recieve the error message:

    [/WEB-INF/applicationContext.xml]: Could not resolve placeholder 'hibernate.show_sql'

    web.xml
    --------------
    Code:
    <context-param>
    		<param-name>contextConfigLocation</param-name>
    		<param-value>
    		/WEB-INF/applicationContext.xml 
    		</param-value>
    	</context-param>
    
    	<servlet>
    		<servlet-name>context</servlet-name>
    		<servlet-class>
    			org.springframework.web.context.ContextLoaderServlet
    		</servlet-class>
    		<load-on-startup>2</load-on-startup>
    	</servlet>
    
    	<servlet>
    		<servlet-name>mytest</servlet-name>
    		<servlet-class>
    			org.springframework.web.servlet.DispatcherServlet
    		</servlet-class>
    		<load-on-startup>3</load-on-startup>
    	</servlet>
    applicationContext.xml
    ---------------------------------
    Code:
    <beans>
    
        <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    		<property name="location" value="classpath:configuration.properties"/>
    	</bean> 
    
    	<!-- Database Property -->
    	<bean id="hibernateProperties"		class="org.springframework.beans.factory.config.PropertiesFactoryBean">
    		<property name="properties">
    			<props>
    				<prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop>
    				<prop key="hibernate.query.substitutions">true 'Y', false 'N'</prop>
    				<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
    				<prop key="hibernate.jdbc.batch_size">20</prop>
    			</props>
    		</property>
           </bean>
    </beans>
    configuration.properties (located on the classpath)
    ----------------------------
    hibernate.show_sql=true

    any ideas?

  • #2
    I think you are facing the same problem discussed at the end of this thread.
    http://forum.springframework.org/showthread.php?t=40808
    Last edited by karldmoore; Aug 29th, 2007, 12:07 PM.

    Comment


    • #3
      its a little different

      I'm not loading mytest-servlet twice. I thought I may have been loading the applicationContext.xml twice, but that doesn't appear to be the case.

      Comment


      • #4
        I specifically meant the last post.
        Also, BeanFactoryPostProcessors are scoped per-container. This is only relevant if you are using container hierarchies. If you define a BeanFactoryPostProcessor in one container, it will only do its stuff on the bean definitions in that container. Bean definitions in another container will not be post-processed by BeanFactoryPostProcessors in another container, even if both containers are part of the same hierarchy.
        http://www.springframework.org/docs/...postprocessors
        As detailed in the section entitled Section 3.8, “The ApplicationContext”, ApplicationContext instances in Spring can be scoped. In the web MVC framework, each DispatcherServlet has its own WebApplicationContext, which inherits all the beans already defined in the root WebApplicationContext. These inherited beans defined can be overridden in the servlet-specific scope, and new scope-specific beans can be defined local to a given servlet instance.
        http://www.springframework.org/docs/...ml#mvc-servlet
        Last edited by karldmoore; Aug 29th, 2007, 12:06 PM.

        Comment


        • #5
          I got it.

          Thanks for your feedback.

          I figured out what the issue was. I had a context in a jar that was included that specified a different PropertyConfigurer. I simply had to include the file that the included context was looking for in my applicationContext.xml.

          Example:
          Code:
          <property name="locations"> 
              <list>
                 <value>classpath:configuration.properties</value>
                 <value>classpath:sample.properties</value>
              </list>
          </property>
          Thanks again.

          Comment

          Working...
          X