When server start, application context loaded twice as you can see in log. When I am using Spring Scheduled annottation it runs twice because of my application context load twice. When I deleted contextLoadListener scheduler works nice (only one time), but this time web mvc doesn't work.
INFO: Initializing Spring root WebApplicationContext
INFO: Initializing Spring FrameworkServlet 'employee'
My web.xml is
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://ift.tt/ra1lAU" xmlns="http://ift.tt/nSRXKP" xsi:schemaLocation="http://ift.tt/nSRXKP http://ift.tt/LU8AHS" id="WebApp_ID" version="2.5">
<display-name>xxxx</display-name>
<servlet>
<servlet-name>employee</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>employee</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/employee-servlet.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy
</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
employee-servlet as
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://ift.tt/GArMu6"
xmlns:mvc="http://ift.tt/1bHqwjR"
xmlns:xsi="http://ift.tt/ra1lAU"
xmlns:task="http://ift.tt/LFBt0P"
xmlns:aop="http://ift.tt/OpNdV1"
xmlns:context="http://ift.tt/GArMu7"
xmlns:jee="http://ift.tt/OpNaZ5"
xmlns:lang="http://ift.tt/OGfeTY"
xmlns:p="http://ift.tt/1jdM0fE"
xmlns:tx="http://ift.tt/OGfeU2"
xmlns:util="http://ift.tt/OGfeTW"
xmlns:beans="http://ift.tt/GArMu6"
xsi:schemaLocation="http://ift.tt/GArMu6 http://ift.tt/1jdM0fG
http://ift.tt/OpNdV1 http://ift.tt/1feTlrW
http://ift.tt/GArMu7 http://ift.tt/1jdLYo7
http://ift.tt/OpNaZ5 http://ift.tt/1feTnjL
http://ift.tt/OGfeTY http://ift.tt/1feTlrY
http://ift.tt/OGfeU2 http://ift.tt/18tm2Tg
http://ift.tt/OGfeTW http://ift.tt/1feTls0
http://ift.tt/1bHqwjR http://ift.tt/1cKeJ91
http://ift.tt/GArMu6 http://ift.tt/GArMu6
http://ift.tt/LFBt0P http://ift.tt/1iFJOtt">
<context:annotation-config />
<context:component-scan base-package="xxx.controller" />
<context:component-scan base-package="xxx.service"/>
<context:component-scan base-package="xxx.dao"/>
<context:component-scan base-package="xxx.dvo"/>
<task:annotation-driven />
<bean id="demoServiceBasicUsageFixedDelay" class="xxx.dao.BaseDao"></bean>
<import resource="classpath:spring-security-config.xml" />
<bean id="jspViewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/view/" />
<property name="suffix" value=".jsp" />
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
</bean>
<mvc:resources mapping="/resources/**" location="/resources/" />
<mvc:annotation-driven />
<tx:annotation-driven transaction-manager="transactionManager"/>
<bean id="transactionManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
</beans>
Spring-security.xml as
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://ift.tt/1c8inpe"
xmlns:xsi="http://ift.tt/ra1lAU" xmlns:beans="http://ift.tt/GArMu6"
xmlns:sec="http://ift.tt/1c8inpe"
xsi:schemaLocation="
http://ift.tt/1c8inpe
http://ift.tt/1epvZ6L
http://ift.tt/GArMu6
http://ift.tt/18sW2ax
http://ift.tt/GArMu7
http://ift.tt/1bGeTcI">
<http auto-config="true" disable-url-rewriting="true" use-expressions="true">
<form-login login-page="/signin" authentication-failure-url="/signin?error=1"/>
<logout logout-url="/logout" />
<intercept-url pattern="/resources/**" access="permitAll" />
<intercept-url pattern="/signin" access="permitAll" />
<!-- <intercept-url pattern="/result/**" access="permitAll" /> -->
<intercept-url pattern="/**" access="isAuthenticated()" />
</http>
<authentication-manager erase-credentials="true" >
<authentication-provider user-service-ref="userService">
</authentication-provider>
</authentication-manager>
</beans:beans>
Aucun commentaire:
Enregistrer un commentaire