You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "yangfuhai (GitHub)" <gi...@apache.org> on 2018/09/27 05:50:03 UTC

[GitHub] [incubator-dubbo] yangfuhai opened issue #2570: dubbo无法在 【非spring + tomcat】环境下运行

错误如下:
```
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依赖如下:

```xml
<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>
```

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/2570 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org

[GitHub] [incubator-dubbo] beiwei30 closed issue #2570: dubbo all in one fail to start from a tomcat server when spring framework is absent

Posted by "beiwei30 (GitHub)" <gi...@apache.org>.
[ issue closed by beiwei30 ]

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/2570 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org


[GitHub] [incubator-dubbo] ralf0131 commented on issue #2570: dubbo无法在 【非spring + tomcat】环境下运行

Posted by "ralf0131 (GitHub)" <gi...@apache.org>.
Hi, 

I would suggest to use maven profile to do this kind of customization.

For example, use the `default` profile for most of the dependencies, and use `spring` profile to include spring dependency.

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/2570 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org


[GitHub] [incubator-dubbo] SKYhuangjing commented on issue #2570: dubbo all in one fail to start from a tomcat server when spring framework is absent

Posted by "SKYhuangjing (GitHub)" <gi...@apache.org>.
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.


[ Full content available at: https://github.com/apache/incubator-dubbo/issues/2570 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org


[GitHub] [incubator-dubbo] diecui1202 commented on issue #2570: dubbo无法在 【非spring + tomcat】环境下运行

Posted by "diecui1202 (GitHub)" <gi...@apache.org>.
I think he uses com.alibaba:dubbo, all in one jar, so can not exclude this dependency.

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/2570 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org


[GitHub] [incubator-dubbo] SKYhuangjing commented on issue #2570: dubbo无法在 【非spring + tomcat】环境下运行

Posted by "SKYhuangjing (GitHub)" <gi...@apache.org>.
> @diecui1202
> 
> > I think he uses com.alibaba:dubbo, all in one jar, so can not exclude this dependency.
> 
> 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.


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](https://github.com/SKYhuangjing/incubator-dubbo/blob/master/dubbo-all-without-spring/pom.xml) module in mine repo.

if offical don't provide, you can make it yourself.

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/2570 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org


[GitHub] [incubator-dubbo] diecui1202 commented on issue #2570: dubbo无法在 【非spring + tomcat】环境下运行

Posted by "diecui1202 (GitHub)" <gi...@apache.org>.
@yangfuhai could u pls. provide a demo to reproduce this problem?

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/2570 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org


[GitHub] [incubator-dubbo] yangfuhai commented on issue #2570: dubbo无法在 【非spring + tomcat】环境下运行

Posted by "yangfuhai (GitHub)" <gi...@apache.org>.
> I think he uses com.alibaba:dubbo, all in one jar, so can not exclude this dependency.

@diecui1202 , How should I use dubbo without spring?

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/2570 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org


[GitHub] [incubator-dubbo] yangfuhai commented on issue #2570: dubbo无法在 【非spring + tomcat】环境下运行

Posted by "yangfuhai (GitHub)" <gi...@apache.org>.
> I think he uses com.alibaba:dubbo, all in one jar, so can not exclude this dependency.

How should I use dubbo without spring?

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/2570 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org


[GitHub] [incubator-dubbo] SKYhuangjing commented on issue #2570: dubbo all in one fail to start from a tomcat server when spring framework is absent

Posted by "SKYhuangjing (GitHub)" <gi...@apache.org>.
i have upgraded dubbo version to 2.7.0, it's good solution for me

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/2570 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org


[GitHub] [incubator-dubbo] yangfuhai commented on issue #2570: dubbo无法在 【非spring + tomcat】环境下运行

Posted by "yangfuhai (GitHub)" <gi...@apache.org>.
> @yangfuhai could u pls. provide a demo to reproduce this problem?

已经定位到问题,原因是当排除spring依赖后,dubbo 2.6.3 下有web-fragment.xml文件,web-fragment.xml会自动去加载 org.springframework.web.context.ContextLoaderListener 导致tomcat无法正常启动。

建议修改:

ContextLoaderListener 修改为 DubboContextLoaderListener,在 DubboContextLoaderListener 里去查看spring是否存在,存在就启动spring 的 ContextLoaderListener,否则什么都不做。

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/2570 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org

[GitHub] [incubator-dubbo] yangfuhai commented on issue #2570: dubbo无法在 【非spring + tomcat】环境下运行

Posted by "yangfuhai (GitHub)" <gi...@apache.org>.
> I think he uses com.alibaba:dubbo, all in one jar, so can not exclude this dependency.

之前的版本并没有这个问题。2.6.3 才有的。

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/2570 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org

[GitHub] [incubator-dubbo] beiwei30 commented on issue #2570: dubbo all in one fail to start from a tomcat server when spring framework is absent

Posted by "beiwei30 (GitHub)" <gi...@apache.org>.
@yangfuhai, would you mind to try out the change I proposed in https://github.com/apache/incubator-dubbo/pull/2640

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/2570 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org


[GitHub] [incubator-dubbo] ralf0131 commented on issue #2570: dubbo无法在 【非spring + tomcat】环境下运行

Posted by "ralf0131 (GitHub)" <gi...@apache.org>.
@yangfuhai In this case, please don't depend on the all in one dependency. 

```xml
    <groupId>com.alibaba</groupId>
    <artifactId>dubbo</artifactId>
    <version>2.6.3</version>
```

And try to depend on the specific module you wish to use, e.g. 

```xml
    <groupId>com.alibaba</groupId>
    <artifactId>dubbo-config-api</artifactId>
    <version>2.6.3</version>
```

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/2570 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org


[GitHub] [incubator-dubbo] beiwei30 commented on issue #2570: dubbo all in one fail to start from a tomcat server when spring framework is absent

Posted by "beiwei30 (GitHub)" <gi...@apache.org>.
it's been fixed.

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/2570 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org


[GitHub] [incubator-dubbo] ralf0131 commented on issue #2570: dubbo all in one fail to start from a tomcat server when spring framework is absent

Posted by "ralf0131 (GitHub)" <gi...@apache.org>.
Hi, 

As another work-around, you may try to skip the annotation scan for dubbo-all.jar, so that this `org.springframework.web.context.ContextLoaderListener` won't be scaned or loaded. 

Read [this](https://wiki.apache.org/tomcat/HowTo/FasterStartUp) see `Configure your web application` and  `Exclude JARs from scanning` section for more details.

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/2570 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org


[GitHub] [incubator-dubbo] diecui1202 commented on issue #2570: dubbo无法在 【非spring + tomcat】环境下运行

Posted by "diecui1202 (GitHub)" <gi...@apache.org>.
@ralf0131 pls. check this problem. 

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/2570 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org


[GitHub] [incubator-dubbo] ralf0131 commented on issue #2570: dubbo无法在 【非spring + tomcat】环境下运行

Posted by "ralf0131 (GitHub)" <gi...@apache.org>.
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

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/2570 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org


[GitHub] [incubator-dubbo] beiwei30 commented on issue #2570: dubbo all in one fail to start from a tomcat server when spring framework is absent

Posted by "beiwei30 (GitHub)" <gi...@apache.org>.
@SKYhuangjing @yangfuhai I believe I've finalized the solution I proposed in pull request 
https://github.com/apache/incubator-dubbo/pull/2640, would you mind to try it out?

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/2570 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org


[GitHub] [incubator-dubbo] ralf0131 commented on issue #2570: dubbo无法在 【非spring + tomcat】环境下运行

Posted by "ralf0131 (GitHub)" <gi...@apache.org>.
@diecui1202 

> I think he uses com.alibaba:dubbo, all in one jar, so can not exclude this dependency.

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.

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/2570 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org