Repository navigation
Closed
Milestone
Description
DubboWebApplicationInitializer will create a root application context, which is conflict with the SpringContextLoaderListener in webxml. See attached stacktrace and web configuration for detail.
P.S. Running dubbo web application in JBoss EAP 6.
12:48:06,305 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/naoms.server]] (ServerService Thread Pool -- 7) JBWEB000287: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener: 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:296) [spring-web-4.3.16.RELEASE.jar:4.3.16.RELEASE]
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107) [spring-web-4.3.16.RELEASE.jar:4.3.16.RELEASE]
at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3339) [jbossweb-7.5.26.Final-redhat-1.jar:7.5.26.Final-redhat-1]
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3780) [jbossweb-7.5.26.Final-redhat-1.jar:7.5.26.Final-redhat-1]
at org.jboss.as.web.deployment.WebDeploymentService.doStart(WebDeploymentService.java:163) [jboss-as-web-7.5.18.Final-redhat-1.jar:7.5.18.Final-redhat-1]
at org.jboss.as.web.deployment.WebDeploymentService.access$000(WebDeploymentService.java:61) [jboss-as-web-7.5.18.Final-redhat-1.jar:7.5.18.Final-redhat-1]
at org.jboss.as.web.deployment.WebDeploymentService$1.run(WebDeploymentService.java:96) [jboss-as-web-7.5.18.Final-redhat-1.jar:7.5.18.Final-redhat-1]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [rt.jar:1.8.0_131]
at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:266) [rt.jar:1.8.0_131]
at java.util.concurrent.FutureTask.run(FutureTask.java) [rt.jar:1.8.0_131]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_131]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_131]
at java.lang.Thread.run(Thread.java:748) [rt.jar:1.8.0_131]
at org.jboss.threads.JBossThread.run(JBossThread.java:122)
<?xml version="1.0" encoding="UTF-8"?>
<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">
<display-name>fims.webappserver</display-name>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<!-- Dubbo Configuration -->
<param-value>classpath:base-context.xml,classpath:base-dubbo.xml,classpath:dubbo-provider.xml
</param-value>
</context-param>
</web-app>
Activity
Add comments.
ralf0131 commentedon Jun 28, 2018
Thanks for reporting, I am planning to look into it in the next one to two days.
ralf0131 commentedon Jul 1, 2018
Hi, I think removing SpringContextLoaderListener in your web.xml will solve this issue. But that will require user to change their code.
The DubboWebApplicationInitializer will be called before any Listener configured in web.xml.
I am still thinking about a more elegant way to solve it.
ATAKing1023 commentedon Jul 2, 2018
Is it possible for dubbo to implement it's own ServletContextListener?
ralf0131 commentedon Jul 2, 2018
Yes. But that also requires user to change their configuration. Actually it is possible to configure the
DubboApplicationListenerin your applicationContext.xml or using annotations.The primary concern here is how to enable that feature without user being aware of it. So I use the ServletContainerInitializer to implement that.
If you check the source code of
org.springframework.web.context.AbstractContextLoaderInitializer#registerContextLoaderListenerYou will find that it does the same thing for you. So you will not need to specify the
ContextLoaderListeneranymore.So I am suggesting that you remove the
ContextLoaderListenerconfiguration in your web.xml. Does that make sense?ralf0131 commentedon Jul 11, 2018
Hi, I am closing this issue for now, please reopen it if you still encounter any issue.
ralf0131 commentedon Jul 24, 2018
Hi, I think this issue will break the compatibility if user is going to upgrade to 2.6.3 or above, so I am going to re-open it.
Ensure compatibility for elegant shutdown under servlet container. ap…
Merge pull request #2126, ensure compatibility for elegant shutdown u…
ralf0131 commentedon Jul 26, 2018
Hi, @ATAKing1023 Your problem will fixed in 2.6.3. Please help to check in 2.6.3-release branch, or when we are doing release vote in the mailing list.
ATAKing1023 commentedon Jul 26, 2018
I will verify and comment later. Thank you.
fix default setting (#4955)