Results 1 to 5 of 5

Thread: applicationContext.xml not filtering

  1. #1
    Join Date
    Jul 2007
    Posts
    3

    Default 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. #2
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    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 at 11:07 AM.
    Barracuda Networks SSL VPN Lead Developer
    http://pramatr.wordpress.com
    http://twitter.com/karldmoore
    http://www.linkedin.com/in/karldmoore
    Any postings are my own opinion, and should not be attributed to my employer or clients.

  3. #3
    Join Date
    Jul 2007
    Posts
    3

    Default 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.

  4. #4
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    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 at 11:06 AM.
    Barracuda Networks SSL VPN Lead Developer
    http://pramatr.wordpress.com
    http://twitter.com/karldmoore
    http://www.linkedin.com/in/karldmoore
    Any postings are my own opinion, and should not be attributed to my employer or clients.

  5. #5
    Join Date
    Jul 2007
    Posts
    3

    Default 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.

Posting Permissions

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