I get these two exceptions successively when I start my application on websphere application server.
1-
Uncaught init() exception created by servlet [context] in application [MosipJobEar4]: java.lang.IllegalStateException: Cannot initialize context because there is already a root application context present - check whether you have multiple ContextLoader* definitions in your web.xml! at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:182) at org.springframework.web.context.ContextLoaderServlet.init(ContextLoaderServlet.java:81) at javax.servlet.GenericServlet.init(GenericServlet.java:161) at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:345) at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.init(ServletWrapperImpl.java:168) at com.ibm.ws.webcontainer.servlet.ServletWrapper.loadOnStartupCheck(ServletWrapper.java:1369) at com.ibm.ws.webcontainer.webapp.WebApp.doLoadOnStartupActions(WebApp.java:638) at com.ibm.ws.webcontainer.webapp.WebApp.commonInitializationFinally(WebApp.java:604) at com.ibm.ws.webcontainer.webapp.WebAppImpl.initialize(WebAppImpl.java:426) at com.ibm.ws.webcontainer.webapp.WebGroupImpl.addWebApplication(WebGroupImpl.java:88) at com.ibm.ws.webcontainer.VirtualHostImpl.addWebApplication(VirtualHostImpl.java:171) at com.ibm.ws.webcontainer.WSWebContainer.addWebApp(WSWebContainer.java:904) at com.ibm.ws.webcontainer.WSWebContainer.addWebApplication(WSWebContainer.java:789) at com.ibm.ws.webcontainer.component.WebContainerImpl.install(WebContainerImpl.java:427) at com.ibm.ws.webcontainer.component.WebContainerImpl.start(WebContainerImpl.java:719) at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:1201) at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:1390) at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:639) at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:979) at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:785) at com.ibm.ws.runtime.component.ApplicationMgrImpl$5.run(ApplicationMgrImpl.java:2220) at com.ibm.ws.security.auth.ContextManagerImpl.runAs(ContextManagerImpl.java:5486) at com.ibm.ws.security.auth.ContextManagerImpl.runAsSystem(ContextManagerImpl.java:5612) at com.ibm.ws.security.core.SecurityContext.runAsSystem(SecurityContext.java:255) at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:2225) at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:436) at com.ibm.ws.runtime.component.CompositionUnitImpl.start(CompositionUnitImpl.java:123) at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:379) at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.access$500(CompositionUnitMgrImpl.java:127) at com.ibm.ws.runtime.component.CompositionUnitMgrImpl$CUInitializer.run(CompositionUnitMgrImpl.java:985) at com.ibm.wsspi.runtime.component.WsComponentImpl$_AsynchInitializer.run(WsComponentImpl.java:524) at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1892)
2-
ServletWrappe E com.ibm.ws.webcontainer.servlet.ServletWrapper init SRVE0271E: Uncaught init() exception created by servlet [dispatcher] in application [MosipJobEar4]: java.lang.NoSuchFieldError: org/springframework/web/context/ConfigurableWebApplicationContext.APPLICATION_CONTEXT_ID_PREFIX at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:430) at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:458) at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:339) at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:306) at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127) at javax.servlet.GenericServlet.init(GenericServlet.java:161)
my web.xml is like below.
<?xml version="1.0" encoding="UTF-8"?> <web-app id="WebApp_ID" version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> <display-name>WEB_MosipJOB</display-name> <description>SGK MOSÄ°P JOB</description> <context-param> <param-name>webAppRootKey</param-name> <param-value>WEB_MosipJOB</param-value> </context-param> <context-param> <param-name>log4jConfigLocation</param-name> <param-value>/WEB-INF/log4j.xml</param-value> </context-param> <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/applicationContext.xml</param-value> </context-param> <context-param> <param-name>CALISMA_ORTAMI</param-name> <param-value>TEST</param-value> <!-- <param-value>PRODUCTION</param-value> --> </context-param> <listener> <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class> </listener> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <servlet> <servlet-name>context</servlet-name> <servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet> <servlet-name>dispatcher</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/dispatcher-config.xml</param-value> </init-param> <load-on-startup>2</load-on-startup> </servlet> <servlet-mapping> <servlet-name>dispatcher</servlet-name> <url-pattern>/job/*</url-pattern> </servlet-mapping> <error-page> <error-code>404</error-code> <location>/jsp/job/error/404.jsp</location> </error-page> <filter> <filter-name>SecurityFilter</filter-name> <filter-class>tr.gov.sgk.mosip.job.filter.SecurityFilter</filter-class> </filter> <filter-mapping> <filter-name>SecurityFilter</filter-name> <servlet-name>dispatcher</servlet-name> </filter-mapping> <filter-mapping> <filter-name>SecurityFilter</filter-name> <url-pattern>*.*</url-pattern> </filter-mapping> <welcome-file-list> <welcome-file>index.htm</welcome-file> <welcome-file>index.html</welcome-file> </welcome-file-list> </web-app>
Part of my pom file is like below:
<spring.framework.spring.version>2.5.6</spring.framework.spring.version> <spring.framework.version>3.0.5.RELEASE</spring.framework.version> <!-- <spring.framework.version>3.1.0.RELEASE</spring.framework.version>--> <!-- <spring.framework.version>4.3.9.RELEASE</spring.framework.version>--> <org.springframework.webflow.version>2.3.4.RELEASE</org.springframework.webflow.version> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>${spring.framework.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>${spring.framework.version}</version> </dependency> <!-- https://mvnrepository.com/artifact/org.springframework.webflow/spring-webflow --> <dependency> <groupId>org.springframework.webflow</groupId> <artifactId>spring-webflow</artifactId> <version>2.3.4.RELEASE</version> </dependency> <!-- https://mvnrepository.com/artifact/org.springframework/spring-jdbc --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> <version>${spring.framework.version}</version> </dependency> <!-- https://mvnrepository.com/artifact/org.springframework/spring-orm --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-orm</artifactId> <version>${spring.framework.version}</version> </dependency> <!-- https://mvnrepository.com/artifact/org.springframework/spring-beans --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>${spring.framework.version}</version> </dependency> <!-- https://mvnrepository.com/artifact/org.springframework/spring-aop --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aop</artifactId> <version>${spring.framework.version}</version> </dependency> <!-- https://mvnrepository.com/artifact/org.springframework/spring --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring</artifactId> <version>${spring.framework.spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>${spring.framework.version}</version> </dependency>
I read that this error may be due to any depencency mismatch. I tried several versions but I couldn’t fix it. I will be very happy if you can help me. Regards, Ferda
Advertisement
Answer
I am not sure how this is fixed, I was changing some configuration and also spring versions experimentally and
after deleting:
<servlet> <servlet-name>context</servlet-name> <servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet>
and updating the spring version to 4.8, I don’t get this error.