Spring - @PostConstruct method called two times
<p>Here is my Spring Controller class </p>

<pre><code>@Controller
public class SchedularController{

  @Autowired
  ProjectRepository projectRepository;

  @Autowired
  UtilityRepository utilityRepository;

  @PostConstruct
  public void postconstruct(){
      System.out.println("Starting schedular...");
   }
}
</code></pre>

<p>Problem is when I start server postconstruct method runs two times.</p>

<p>I have checked another posts on this which mostly says - "That can happen if you have multiple frameworks managing the same bean class. E.g. JSF and CDI, or JSF and Spring, or CDI and Spring, etc."</p>

<p>But I am not using JSF or CDI and still having this problem.(and my @PostConstruct method is in controller class)</p>

<p>How to resolve this?</p>

<p><strong>Edit</strong> - </p>

<p>Here is my pom file</p>

<pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0"     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0    http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
 &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
 &lt;groupId&gt;WBPPM&lt;/groupId&gt;
 &lt;artifactId&gt;WBPPM&lt;/artifactId&gt;
 &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
 &lt;packaging&gt;war&lt;/packaging&gt;
 &lt;url&gt;http://maven.apache.org&lt;/url&gt;

&lt;properties&gt;
    &lt;spring.version&gt;4.0.3.RELEASE&lt;/spring.version&gt;
    &lt;spring.security.version&gt;3.0.5.RELEASE&lt;/spring.security.version&gt;
    &lt;mongo-java-driver.version&gt;3.0.2&lt;/mongo-java-driver.version&gt;
    &lt;spring-data-commons.version&gt;1.7.2.RELEASE&lt;/spring-data-commons.version&gt;
    &lt;spring-data-mongodb.version&gt;1.4.2.RELEASE&lt;/spring-data-mongodb.version&gt;
    &lt;org.aspectj-version&gt;1.7.4&lt;/org.aspectj-version&gt;
    &lt;jackson.databind-version&gt;2.2.3&lt;/jackson.databind-version&gt;
    &lt;log4j.version&gt;1.2.17&lt;/log4j.version&gt;
    &lt;slf4j.version&gt;1.7.6&lt;/slf4j.version&gt;
&lt;/properties&gt;

&lt;dependencies&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;junit&lt;/groupId&gt;
        &lt;artifactId&gt;junit&lt;/artifactId&gt;
        &lt;version&gt;3.8.1&lt;/version&gt;
        &lt;scope&gt;test&lt;/scope&gt;
    &lt;/dependency&gt;

    &lt;!-- Spring Security --&gt;

    &lt;dependency&gt;
        &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
        &lt;artifactId&gt;spring-security-web&lt;/artifactId&gt;
        &lt;version&gt;${spring.security.version}&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
        &lt;artifactId&gt;spring-security-config&lt;/artifactId&gt;
        &lt;version&gt;${spring.security.version}&lt;/version&gt;
    &lt;/dependency&gt;

    &lt;!-- Spring --&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.springframework&lt;/groupId&gt;
        &lt;artifactId&gt;spring-core&lt;/artifactId&gt;
        &lt;version&gt;${spring.version}&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.springframework&lt;/groupId&gt;
        &lt;artifactId&gt;spring-context&lt;/artifactId&gt;
        &lt;version&gt;${spring.version}&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.springframework&lt;/groupId&gt;
        &lt;artifactId&gt;spring-beans&lt;/artifactId&gt;
        &lt;version&gt;${spring.version}&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.springframework&lt;/groupId&gt;
        &lt;artifactId&gt;spring-aop&lt;/artifactId&gt;
        &lt;version&gt;${spring.version}&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;!-- &lt;dependency&gt; &lt;groupId&gt;org.springframework&lt;/groupId&gt; &lt;artifactId&gt;spring-aspects&lt;/artifactId&gt; 
        &lt;version&gt;${spring.version}&lt;/version&gt; &lt;/dependency&gt; --&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.springframework&lt;/groupId&gt;
        &lt;artifactId&gt;spring-orm&lt;/artifactId&gt;
        &lt;version&gt;${spring.version}&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.springframework&lt;/groupId&gt;
        &lt;artifactId&gt;spring-web&lt;/artifactId&gt;
        &lt;version&gt;${spring.version}&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.springframework&lt;/groupId&gt;
        &lt;artifactId&gt;spring-webmvc&lt;/artifactId&gt;
        &lt;version&gt;${spring.version}&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.springframework.ws&lt;/groupId&gt;
        &lt;artifactId&gt;spring-oxm&lt;/artifactId&gt;
        &lt;version&gt;1.5.10&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.codehaus.jettison&lt;/groupId&gt;
        &lt;artifactId&gt;jettison&lt;/artifactId&gt;
        &lt;version&gt;1.1&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.codehaus.castor&lt;/groupId&gt;
        &lt;artifactId&gt;castor&lt;/artifactId&gt;
        &lt;version&gt;1.2&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;xerces&lt;/groupId&gt;
        &lt;artifactId&gt;xercesImpl&lt;/artifactId&gt;
        &lt;version&gt;2.8.1&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;javax.xml.bind&lt;/groupId&gt;
        &lt;artifactId&gt;jaxb-api&lt;/artifactId&gt;
        &lt;version&gt;2.0&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;!-- Xstream and Json provider --&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;com.thoughtworks.xstream&lt;/groupId&gt;
        &lt;artifactId&gt;xstream&lt;/artifactId&gt;
        &lt;version&gt;1.3.1&lt;/version&gt;
        &lt;type&gt;jar&lt;/type&gt;
    &lt;/dependency&gt;
    &lt;!-- Jackson --&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;
        &lt;artifactId&gt;jackson-databind&lt;/artifactId&gt;
        &lt;version&gt;${jackson.databind-version}&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;
        &lt;artifactId&gt;jackson-annotations&lt;/artifactId&gt;
        &lt;version&gt;${jackson.databind-version}&lt;/version&gt;
    &lt;/dependency&gt;

    &lt;!-- Spring / MongoDB --&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.mongodb&lt;/groupId&gt;
        &lt;artifactId&gt;mongo-java-driver&lt;/artifactId&gt;
        &lt;version&gt;${mongo-java-driver.version}&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.springframework.data&lt;/groupId&gt;
        &lt;artifactId&gt;spring-data-mongodb&lt;/artifactId&gt;
        &lt;version&gt;${spring-data-mongodb.version}&lt;/version&gt;
    &lt;/dependency&gt;

    &lt;dependency&gt;
        &lt;groupId&gt;cglib&lt;/groupId&gt;
        &lt;artifactId&gt;cglib&lt;/artifactId&gt;
        &lt;version&gt;2.2.2&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;!-- Tiles plugins --&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.apache.tiles&lt;/groupId&gt;
        &lt;artifactId&gt;tiles-jsp&lt;/artifactId&gt;
        &lt;version&gt;3.0.3&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;!-- &lt;dependency&gt; &lt;groupId&gt;org.slf4j&lt;/groupId&gt; &lt;artifactId&gt;slf4j-log4j12&lt;/artifactId&gt; 
        &lt;version&gt;1.5.11&lt;/version&gt; &lt;/dependency&gt; --&gt;
    &lt;!-- JSTL plugins --&gt;
    &lt;!-- Log4j --&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;log4j&lt;/groupId&gt;
        &lt;artifactId&gt;log4j&lt;/artifactId&gt;
        &lt;version&gt;${log4j.version}&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
        &lt;artifactId&gt;slf4j-log4j12&lt;/artifactId&gt;
        &lt;version&gt;${slf4j.version}&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
        &lt;artifactId&gt;jstl&lt;/artifactId&gt;
        &lt;version&gt;1.2&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;!-- java mail --&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;javax.mail&lt;/groupId&gt;
        &lt;artifactId&gt;mail&lt;/artifactId&gt;
        &lt;version&gt;1.4.4&lt;/version&gt;
    &lt;/dependency&gt; 
    &lt;!-- AspectJ --&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.aspectj&lt;/groupId&gt;
        &lt;artifactId&gt;aspectjrt&lt;/artifactId&gt;
        &lt;version&gt;${org.aspectj-version}&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.aspectj&lt;/groupId&gt;
        &lt;artifactId&gt;aspectjweaver&lt;/artifactId&gt;
        &lt;version&gt;${org.aspectj-version}&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;commons-lang&lt;/groupId&gt;
        &lt;artifactId&gt;commons-lang&lt;/artifactId&gt;
        &lt;version&gt;2.6&lt;/version&gt;
    &lt;/dependency&gt;


    &lt;dependency&gt;
        &lt;groupId&gt;commons-fileupload&lt;/groupId&gt;
        &lt;artifactId&gt;commons-fileupload&lt;/artifactId&gt;
        &lt;version&gt;1.2.2&lt;/version&gt;
    &lt;/dependency&gt;

    &lt;!-- Recaptcha check Api --&gt;
    &lt;dependency&gt;
     &lt;groupId&gt;org.glassfish&lt;/groupId&gt;
     &lt;artifactId&gt;javax.json&lt;/artifactId&gt;
     &lt;version&gt;1.0.2&lt;/version&gt;
    &lt;/dependency&gt;

    &lt;!-- Apache Commons Upload --&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;commons-io&lt;/groupId&gt;
        &lt;artifactId&gt;commons-io&lt;/artifactId&gt;
        &lt;version&gt;1.3.2&lt;/version&gt;
    &lt;/dependency&gt;

    &lt;!-- Jasper Report --&gt;
    &lt;!-- &lt;dependency&gt;
        &lt;groupId&gt;net.sf.jasperreports&lt;/groupId&gt;
        &lt;artifactId&gt;jasperreports&lt;/artifactId&gt;
        &lt;version&gt;5.6.0&lt;/version&gt;
    &lt;/dependency&gt; --&gt;

    &lt;!-- Freemarker Template --&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.freemarker&lt;/groupId&gt;
        &lt;artifactId&gt;freemarker&lt;/artifactId&gt;
        &lt;version&gt;2.3.20&lt;/version&gt;
    &lt;/dependency&gt;

    &lt;!-- &lt;dependency&gt;
        &lt;groupId&gt;com.jolbox&lt;/groupId&gt;
        &lt;artifactId&gt;bonecp&lt;/artifactId&gt;
        &lt;version&gt;0.8.0.RELEASE&lt;/version&gt;
    &lt;/dependency&gt; --&gt;

    &lt;!-- Excel File Read/write --&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.apache.poi&lt;/groupId&gt;
        &lt;artifactId&gt;poi-ooxml&lt;/artifactId&gt;
        &lt;version&gt;3.11&lt;/version&gt;
    &lt;/dependency&gt;

    &lt;!-- amazonaws --&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;com.amazonaws&lt;/groupId&gt;
        &lt;artifactId&gt;aws-java-sdk-s3&lt;/artifactId&gt;
        &lt;version&gt;1.10.4&lt;/version&gt;
    &lt;/dependency&gt;

    &lt;!-- Push Notification --&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;com.ganyo&lt;/groupId&gt;
        &lt;artifactId&gt;gcm-server&lt;/artifactId&gt;
        &lt;version&gt;1.0.2&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;es.arcadiaconsulting.javapns&lt;/groupId&gt;
        &lt;artifactId&gt;javapns&lt;/artifactId&gt;
        &lt;version&gt;2.2-json&lt;/version&gt;
    &lt;/dependency&gt;

    &lt;!-- http://mvnrepository.com/artifact/it.sauronsoftware.cron4j/cron4j --&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;it.sauronsoftware.cron4j&lt;/groupId&gt;
        &lt;artifactId&gt;cron4j&lt;/artifactId&gt;
        &lt;version&gt;2.2.5&lt;/version&gt;
    &lt;/dependency&gt;



&lt;/dependencies&gt; 

&lt;build&gt;
    &lt;sourceDirectory&gt;src&lt;/sourceDirectory&gt;
    &lt;plugins&gt;
        &lt;plugin&gt;
            &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
            &lt;version&gt;3.1&lt;/version&gt;
            &lt;configuration&gt;
                &lt;source&gt;1.7&lt;/source&gt;
                &lt;target&gt;1.7&lt;/target&gt;
            &lt;/configuration&gt;
        &lt;/plugin&gt;
        &lt;plugin&gt;
            &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt;
            &lt;version&gt;2.3&lt;/version&gt;
            &lt;configuration&gt;
                &lt;warSourceDirectory&gt;WebContent&lt;/warSourceDirectory&gt;
                &lt;failOnMissingWebXml&gt;false&lt;/failOnMissingWebXml&gt;
            &lt;/configuration&gt;
        &lt;/plugin&gt;
    &lt;/plugins&gt;
&lt;/build&gt;
&lt;/project&gt;
</code></pre>

<p>Here is my spring context file - </p>

<pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxrs="http://cxf.apache.org/jaxrs"
xmlns:cxf="http://cxf.apache.org/core" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:oxm="http://www.springframework.org/schema/oxm"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:mongo="http://www.springframework.org/schema/data/mongo"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd 
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/beans  http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-1.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
http://www.springframework.org/schema/data/mongo
http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd"&gt;

&lt;context:component-scan base-package="com.wb.ppm" /&gt;
&lt;context:annotation-config /&gt;
&lt;mvc:annotation-driven /&gt;
&lt;aop:aspectj-autoproxy /&gt;
&lt;mvc:interceptors&gt;
    &lt;mvc:interceptor&gt;
        &lt;mvc:mapping path="/**/*" /&gt;
        &lt;bean id="webContentInterceptor"
            class="org.springframework.web.servlet.mvc.WebContentInterceptor"&gt;
            &lt;property name="cacheSeconds" value="0" /&gt;
            &lt;property name="useExpiresHeader" value="true" /&gt;
            &lt;property name="useCacheControlHeader" value="true" /&gt;
            &lt;property name="useCacheControlNoStore" value="true" /&gt;
        &lt;/bean&gt;
    &lt;/mvc:interceptor&gt;
    &lt;mvc:interceptor&gt;
        &lt;mvc:mapping path="/*" /&gt;
        &lt;bean class="com.wb.ppm.util.interceptor.WBInterceptor"&gt;
        &lt;/bean&gt;
    &lt;/mvc:interceptor&gt;
&lt;/mvc:interceptors&gt;

&lt;bean id="loggingAspect" class="com.wb.ppm.util.logging.LoggingAspect" /&gt;
&lt;bean id="applicationContext" class="com.wb.ppm.security.SpringApplicationContext"
    factory-method="getInstance" /&gt;

&lt;bean
    class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"&gt;
&lt;/bean&gt;
&lt;bean id="localeResolver"
    class="org.springframework.web.servlet.i18n.SessionLocaleResolver"&gt;
    &lt;property name="defaultLocale" value="en" /&gt;
&lt;/bean&gt;

&lt;bean id="localeChangeInterceptor"
    class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"&gt;
    &lt;property name="paramName" value="language" /&gt;
&lt;/bean&gt;

&lt;bean
    class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"&gt;
    &lt;property name="interceptors"&gt;
        &lt;list&gt;
            &lt;ref bean="localeChangeInterceptor" /&gt;
        &lt;/list&gt;
    &lt;/property&gt;
&lt;/bean&gt;
&lt;!-- Register the welcome.properties --&gt;
&lt;bean id="messageSource"
    class="org.springframework.context.support.ResourceBundleMessageSource"&gt;
    &lt;property name="basename" value="ApplicationResources" /&gt;
&lt;/bean&gt;

&lt;!-- Factory bean that creates the Mongo instance --&gt;
&lt;context:property-placeholder location="classpath:mongodb.properties"
    order="1" /&gt;

&lt;bean id="mongo" class="org.springframework.data.mongodb.core.MongoFactoryBean"&gt;
    &lt;property name="host" value="${mongo.host.name}" /&gt;
    &lt;property name="port" value="${mongo.host.port}" /&gt;
&lt;/bean&gt;


&lt;bean id="mongoDbFactory" class="org.springframework.data.mongodb.core.SimpleMongoDbFactory"&gt;
    &lt;constructor-arg name="mongo" ref="mongo" /&gt;
    &lt;constructor-arg name="databaseName" value="${mongo.db.name}" /&gt;
&lt;/bean&gt;


&lt;mongo:mapping-converter id="converter" /&gt;
&lt;bean name="gridFsTemplate"
    class="org.springframework.data.mongodb.gridfs.GridFsTemplate"&gt;
    &lt;constructor-arg ref="mongoDbFactory" /&gt;
    &lt;constructor-arg ref="converter" /&gt;
&lt;/bean&gt;

&lt;bean id="userCredentials" class="org.springframework.data.authentication.UserCredentials"&gt;
    &lt;constructor-arg name="username" value="${mongo.db.username}" /&gt;
    &lt;constructor-arg name="password" value="${mongo.db.password}" /&gt;
&lt;/bean&gt;

&lt;!-- MongoConverter for converting the dot in map key to \+ in mongodb  --&gt;
&lt;bean id="mongoMoxydomainConverter" class="org.springframework.data.mongodb.core.convert.MappingMongoConverter"&gt;
    &lt;constructor-arg index="0" ref="mongoDbFactory" /&gt;
    &lt;constructor-arg index="1"&gt;
        &lt;bean class="org.springframework.data.mongodb.core.mapping.MongoMappingContext" /&gt;
    &lt;/constructor-arg&gt;
    &lt;property name="mapKeyDotReplacement" value="\\+"/&gt;
&lt;/bean&gt;


&lt;!-- MongoTemplate for connecting and querying the documents in the database --&gt;
&lt;bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate"&gt;
    &lt;constructor-arg name="mongoDbFactory" ref="mongoDbFactory" /&gt;
    &lt;constructor-arg name="mongoConverter" ref="mongoMoxydomainConverter"/&gt;
    &lt;!-- &lt;constructor-arg name="userCredentials" ref="userCredentials" /&gt; --&gt;
&lt;/bean&gt;

&lt;!-- Use this post processor to translate any MongoExceptions thrown in 
    @Repository annotated classes --&gt;
&lt;bean
    class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" /&gt;

&lt;!-- Register the welcome.properties --&gt;
&lt;bean id="tilesConfigurer"
    class="org.springframework.web.servlet.view.tiles3.TilesConfigurer"&gt;
    &lt;property name="definitions"&gt;
        &lt;list&gt;
            &lt;value&gt;/WEB-INF/tiles.xml&lt;/value&gt;
        &lt;/list&gt;
    &lt;/property&gt;
&lt;/bean&gt;

&lt;bean id="tilesviewResolver"
    class="org.springframework.web.servlet.view.UrlBasedViewResolver"&gt;
    &lt;property name="viewClass"
        value="org.springframework.web.servlet.view.tiles3.TilesView" /&gt;
    &lt;property name="order" value="2"&gt;&lt;/property&gt;
&lt;/bean&gt;

&lt;bean id="jstlviewResolver"
    class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
    &lt;property name="viewClass"
        value="org.springframework.web.servlet.view.JstlView" /&gt;
    &lt;property name="prefix" value="/pages/" /&gt;
    &lt;property name="suffix" value=".jsp" /&gt;
    &lt;property name="order" value="3"&gt;&lt;/property&gt;
&lt;/bean&gt;

&lt;!-- Configure to plugin JSON as request and response in method handler --&gt;
&lt;bean
    class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"&gt;
    &lt;property name="messageConverters"&gt;
        &lt;list&gt;
            &lt;ref bean="jsonMessageConverter" /&gt;
            &lt;ref bean="xmlMessageConverter" /&gt;
        &lt;/list&gt;
    &lt;/property&gt;
&lt;/bean&gt;

&lt;bean
    class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"&gt;
&lt;/bean&gt;

&lt;!-- Configure bean to convert JSON to POJO and vice versa --&gt;
&lt;bean id="jsonMessageConverter"
    class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"&gt;
    &lt;property name="supportedMediaTypes" value="application/json" /&gt;
&lt;/bean&gt;
&lt;bean id="multipartResolver"
    class="org.springframework.web.multipart.commons.CommonsMultipartResolver"&gt;
    &lt;property name="maxUploadSize" value="150000000"/&gt;
    &lt;property name="maxInMemorySize" value="150000000"/&gt;
&lt;/bean&gt;

&lt;bean id="xmlMessageConverter"
    class="org.springframework.http.converter.xml.MarshallingHttpMessageConverter"&gt;
    &lt;property name="marshaller" ref="castorMarshaller" /&gt;
    &lt;property name="unmarshaller" ref="castorMarshaller" /&gt;
    &lt;property name="supportedMediaTypes" value="application/xml" /&gt;
&lt;/bean&gt;
&lt;bean id="castorMarshaller" class="org.springframework.oxm.castor.CastorMarshaller"&gt;
&lt;/bean&gt;
&lt;bean id="simpleMappingExceptionResolver"
    class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver"&gt;
    &lt;property name="exceptionMappings"&gt;
        &lt;map&gt;
            &lt;entry key="NotAuthorizedException" value="redirect:/login" /&gt;
        &lt;/map&gt;
    &lt;/property&gt;
    &lt;property name="defaultErrorView" value="redirect:/pages/error/globalError.jsp" /&gt;
&lt;/bean&gt;
</code></pre>

<p>    </p>

<p>Here is my web.xml</p>

<pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0"&gt;
&lt;display-name&gt;WorldBankPPM&lt;/display-name&gt;
&lt;!-- Spring Listeners --&gt;
&lt;context-param&gt;
    &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
    &lt;param-value&gt;classpath:worldbank-context.xml
        classpath:security-applicationContext.xml
    &lt;/param-value&gt;
&lt;/context-param&gt;
&lt;context-param&gt;
    &lt;param-name&gt;log4j-config-location&lt;/param-name&gt;
    &lt;param-value&gt;src/log4j.properties&lt;/param-value&gt;
&lt;/context-param&gt;
&lt;listener&gt;
    &lt;listener-class&gt;org.springframework.web.context.request.RequestContextListener&lt;/listener-class&gt;
&lt;/listener&gt;
&lt;listener&gt;
    &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
&lt;/listener&gt;

&lt;filter&gt;
    &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;
    &lt;filter-class&gt;org.springframework.web.filter.DelegatingFilterProxy&lt;/filter-class&gt;
&lt;/filter&gt;

&lt;filter-mapping&gt;
    &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;
    &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
&lt;/filter-mapping&gt;

&lt;servlet&gt;
    &lt;servlet-name&gt;appServlet&lt;/servlet-name&gt;
    &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
    &lt;init-param&gt;
        &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
        &lt;param-value&gt;/WEB-INF/classes/worldbank-context.xml&lt;/param-value&gt;
    &lt;/init-param&gt;
    &lt;load-on-startup&gt;0&lt;/load-on-startup&gt;
&lt;/servlet&gt;
&lt;servlet-mapping&gt;
    &lt;servlet-name&gt;appServlet&lt;/servlet-name&gt;
    &lt;url-pattern&gt;/&lt;/url-pattern&gt;
    &lt;url-pattern&gt;/login&lt;/url-pattern&gt;
&lt;/servlet-mapping&gt;
&lt;session-config&gt;
    &lt;session-timeout&gt;360&lt;/session-timeout&gt;
&lt;/session-config&gt;
&lt;welcome-file-list&gt;
    &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;
&lt;/welcome-file-list&gt;
&lt;servlet-mapping&gt;
    &lt;servlet-name&gt;default&lt;/servlet-name&gt;
    &lt;url-pattern&gt;/assets/*&lt;/url-pattern&gt;
    &lt;url-pattern&gt;/vendor/*&lt;/url-pattern&gt;
&lt;/servlet-mapping&gt;
&lt;servlet&gt;
    &lt;servlet-name&gt;jsp&lt;/servlet-name&gt;
    &lt;servlet-class&gt;org.apache.jasper.servlet.JspServlet&lt;/servlet-class&gt;
    &lt;init-param&gt;
        &lt;param-name&gt;fork&lt;/param-name&gt;
        &lt;param-value&gt;false&lt;/param-value&gt;
    &lt;/init-param&gt;
    &lt;init-param&gt;
        &lt;param-name&gt;xpoweredBy&lt;/param-name&gt;
        &lt;param-value&gt;false&lt;/param-value&gt;
    &lt;/init-param&gt;
    &lt;init-param&gt;
        &lt;param-name&gt;mappedfile&lt;/param-name&gt;
        &lt;param-value&gt;false&lt;/param-value&gt;
    &lt;/init-param&gt;
    &lt;load-on-startup&gt;3&lt;/load-on-startup&gt;
&lt;/servlet&gt;
&lt;error-page&gt;
    &lt;error-code&gt;404&lt;/error-code&gt;
    &lt;location&gt;/pages/error/error404.jsp&lt;/location&gt;
&lt;/error-page&gt;
&lt;error-page&gt;
    &lt;error-code&gt;500&lt;/error-code&gt;
    &lt;location&gt;/pages/error/globalError.jsp&lt;/location&gt;
&lt;/error-page&gt;
&lt;!-- &lt;security-constraint&gt;
    &lt;web-resource-collection&gt;
        &lt;web-resource-name&gt;securedapp&lt;/web-resource-name&gt;
        &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
    &lt;/web-resource-collection&gt;
    &lt;user-data-constraint&gt;
        &lt;transport-guarantee&gt;CONFIDENTIAL&lt;/transport-guarantee&gt;
    &lt;/user-data-constraint&gt;
&lt;/security-constraint&gt; --&gt;
</code></pre>

<p></p>