Repository navigation
Closed
Closed
Copy link
Description
错误如下:
27-Sep-2018 13:39:35.736 SEVERE [RMI TCP Connection(2)-127.0.0.1] org.apache.catalina.core.StandardContext.listenerStart Error configuring application listener of class org.springframework.web.context.ContextLoaderListener
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1333)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1167)
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:520)
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:501)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:120)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4660)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5181)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1678)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:463)
at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:413)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1466)
at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76)
at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1307)
at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1399)
at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:828)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:323)
at sun.rmi.transport.Transport$1.run(Transport.java:178)
at sun.rmi.transport.Transport$1.run(Transport.java:175)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:174)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:557)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:812)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:671)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
maven依赖如下:
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId>
<version>2.6.3</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</exclusion>
</exclusions>
</dependency>Reacted by August and Ben
Metadata
Metadata
Assignees
Labels
No labels
Activity
diecui1202 commentedon Sep 27, 2018
@yangfuhai could u pls. provide a demo to reproduce this problem?
yangfuhai commentedon Sep 27, 2018
已经定位到问题,原因是当排除spring依赖后,dubbo 2.6.3 下有web-fragment.xml文件,web-fragment.xml会自动去加载 org.springframework.web.context.ContextLoaderListener 导致tomcat无法正常启动。
建议修改:
ContextLoaderListener 修改为 DubboContextLoaderListener,在 DubboContextLoaderListener 里去查看spring是否存在,存在就启动spring 的 ContextLoaderListener,否则什么都不做。
diecui1202 commentedon Sep 27, 2018
@ralf0131 pls. check this problem.
ralf0131 commentedon Sep 27, 2018
If you don't run Dubbo with Tomcat + spring, then don't need this file. If file is intended to bed used for Dubbo + Tomcat + Spring.
Please remove the dependency to dubbo-config-spring
diecui1202 commentedon Sep 27, 2018
I think he uses com.alibaba:dubbo, all in one jar, so can not exclude this dependency.
yangfuhai commentedon Oct 6, 2018
之前的版本并没有这个问题。2.6.3 才有的。
ralf0131 commentedon Oct 7, 2018
@yangfuhai In this case, please don't depend on the all in one dependency.
And try to depend on the specific module you wish to use, e.g.
ralf0131 commentedon Oct 7, 2018
@diecui1202
Why we need to shade all the dependency into one jar? This make it difficult to customize the dependency.
I think this is something worth discussion.
SKYhuangjing commentedon Oct 12, 2018
provide dubbo-all-without-spring module, just like dubbo-all, but dubbo-all-without-spring module did't rely spring-framework and have no dubbo-xxx-spring module
I have forked dubbo repo and make dubbo-all-without-spring module in mine repo.
if offical don't provide, you can make it yourself.
ralf0131 commentedon Oct 12, 2018
Hi,
I would suggest to use maven profile to do this kind of customization.
For example, use the
defaultprofile for most of the dependencies, and usespringprofile to include spring dependency.[-]dubbo无法在 【非spring + tomcat】环境下运行[/-][+] dubbo all in one fail to start from a tomcat server when spring framework is absent[/+]beiwei30 commentedon Oct 12, 2018
@yangfuhai, would you mind to try out the change I proposed in #2640
ralf0131 commentedon Oct 12, 2018
Hi,
As another work-around, you may try to skip the annotation scan for dubbo-all.jar, so that this
org.springframework.web.context.ContextLoaderListenerwon't be scaned or loaded.Read this see
Configure your web applicationandExclude JARs from scanningsection for more details.SKYhuangjing commentedon Oct 14, 2018
provide dubbo-all can be easy integrate to our app, if no dubbo-all, we have to need rely multi dubbo-xxx, it's not easy job(That is very painful for rookie(just like me...))
and may be dev don't wanna change the tomcat(or wildfly), in my humble opinion, this work is also more hardly.
as a middleware, i hope dubbo can provide a more easy usage option in non-spring runtime.,just like dubbo-all module. Of course this may be based on the fact that I am a rookie and I hope that the integrated dubbo upgrade can be easier.
beiwei30 commentedon Oct 15, 2018
@SKYhuangjing @yangfuhai I believe I've finalized the solution I proposed in pull request
#2640, would you mind to try it out?
prototype for issue2570 (#2640)
prototype for issue2570 (apache#2640)
test1 (#7)
2018.12.6 (#8)
Update the latest branch (#9)
prototype for issue2570 (apache#2640)
test2 (#14)
beiwei30 commentedon Feb 11, 2019
it's been fixed.
SKYhuangjing commentedon Feb 14, 2019
i have upgraded dubbo version to 2.7.0, it's good solution for me