I have a web application shell running on Tomcat. It's based on an architecture I set up -- and all of my applications have the same problem, even this shell: when the app starts up, I see all of my contexts loaded *twice*. I know this is a common problem, but I can't seem to figure it out!
If I remove the listener and its associated context param, the dispatch loads player-servlet once, but it doesn't load commonContext.xml doesn't load (and I wouldn't expect it to, either).
Help an old man get his sanity back... :-)
web.xml snippets:
commonContext.xml:Code:<servlet> <servlet-name>player</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>player</servlet-name> <url-pattern>/app/*</url-pattern> </servlet-mapping> <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/commonContext.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener>
dao.xml:Code:<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"> <property name="basename"> <value>messages</value> </property> </bean> <import resource="dao.xml"/> <import resource="services.xml"/> <import resource="constants.xml"/>
Code:<import resource="conf/mysql/dao.xml"/>
conf/mysql/dao.xml:
services.xml:Code:<bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator"/> <bean id="chdbPoolAdapter" class="org.apache.commons.dbcp.cpdsadapter.DriverAdapterCPDS"> <property name="driver" value="com.mysql.jdbc.Driver"/> <property name="url" value="jdbc:mysql://localhost:3306/chdb?autoReconnect=true"/> <property name="user" value="root"/> <property name="password" value=""/> </bean> <bean id="chdbDataSource" class="org.apache.commons.dbcp.datasources.SharedPoolDataSource"> <property name="connectionPoolDataSource" ref="chdbPoolAdapter"/> <property name="maxActive" value="100"/> <property name="maxIdle" value="30"/> <property name="maxWait" value="10000"/> </bean> <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="chdbDataSource"/> </bean> <bean id="txInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor"> <property name="transactionManager" ref="txManager"/> <property name="transactionAttributeSource"> <bean class="org.springframework.transaction.annotation.AnnotationTransactionAttributeSource"/> </property> </bean> <bean class="org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor"> <property name="transactionInterceptor" ref="txInterceptor"/> </bean>
(empty)
constants.xml:
(empty)
player-servlet.xml:
Code:<bean id="urlPathController" class="com.xyzcompany.spring.controllers.UrlPathViewController"/> <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="viewClass"><value>org.springframework.web.servlet.view.JstlView</value></property> <property name="prefix"><value>/WEB-INF/views/</value></property> <property name="suffix"><value>.jsp</value></property> </bean> <bean id="handlerMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> <property name="urlMap"> <map> <entry key="/*.view" value-ref="urlPathController"/> </map> </property> </bean>


Reply With Quote

