java - Spring FrameworkServlet won't load Properties during Tomcat startup -


i having strange issue spring propertyplaceholderconfigurer

all junit tests pass, when start tomcat, run properties initialization issue:

// first root initialization, properties fine [...] info: initializing spring root webapplicationcontext 14:21:13.195 info  [quartzproperties] - quartzproperties: false 0 0/30 * * * ? true 18:00 1  // second 'servlet' initialization, properties empty [...] info: initializing spring frameworkservlet 'global' 14:21:16.133 info  [quartzproperties] - quartzproperties: false  false ${quartz.triggertime} 0 

the servlet context initialization doesn't use properties, , triggers crash of quartz library (invalid values).

i see nothing wrong in configuration , don't understand what's going on:

web.xlm

[...] <servlet>     <servlet-name>global</servlet-name>     <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class>     <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping>     <servlet-name>global</servlet-name>     <url-pattern>/</url-pattern> </servlet-mapping>  <context-param>     <param-name>contextconfiglocation</param-name>     <param-value>         classpath:/applicationcontext.xml     </param-value> </context-param>  <listener>     <listener-class>org.springframework.web.context.contextloaderlistener</listener-class> </listener> 

applicationcontext.xml

<bean id="allproperties" class="org.springframework.beans.factory.config.propertyplaceholderconfigurer" >     <property name="ignoreresourcenotfound" value="false" />     <property name="locations">         <list>             <value>file:///${website_home}/conf/jdbc.properties</value>             <value>file:///${website_home}/conf/hibernate.properties</value>             <value>file:///${website_home}/conf/quartz.properties</value>         </list>     </property> </bean> 

the website_home value comes os environment.

have idea why properties empty in global servlet init?

you need include init param in servlet definition.

<init-param>      <param-name>contextconfiglocation</param-name>      <param-value>classpath:/applicationcontext.xml</param-value> </init-param> 

[...] <servlet>     <servlet-name>global</servlet-name>     <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class>     <init-param>          <param-name>contextconfiglocation</param-name>          <param-value>classpath:/applicationcontext.xml</param-value>     </init-param>     <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping>     <servlet-name>global</servlet-name>     <url-pattern>/</url-pattern> </servlet-mapping>  <context-param>     <param-name>contextconfiglocation</param-name>     <param-value>         classpath:/applicationcontext.xml     </param-value> </context-param>  <listener>     <listener-class>org.springframework.web.context.contextloaderlistener</listener-class> </listener> 

Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -