You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "Alfred-Wong (GitHub)" <gi...@apache.org> on 2019/04/08 08:02:38 UTC

[GitHub] [incubator-dubbo] Alfred-Wong opened issue #3827: 通过spring配置文件方式消费dubbo服务,在servlet中注入了该dubbo服务,报代理错误

- [ ] I have searched the [issues](https://github.com/apache/incubator-dubbo/issues) of this repository and believe that this is not a duplicate.
- [ ] I have checked the [FAQ](https://github.com/apache/incubator-dubbo/blob/master/FAQ.md) of this repository and believe that this is not a duplicate.

### test

* Dubbo version: 2.7.0
* Operating System version: 
* Java version: 1.8

### Steps to reproduce this issue

1. 通过spring配置文件方式消费dubbo服务
2.在servlet中注入了该dubbo服务
3. 服务启动报错,报could not generate CGLIB subclass of class org.apache.dubbo.common.bytecode.proxy0;common causes of this problem include using a final class or a non-visible class

如果把服务消费reference的配置改为饥饿加载init=“true”,则启动不报错。
是什么原因导致

Pls. provide [GitHub address] to reproduce this issue.

### Expected Result

What do you expected from the above steps?

### Actual Result

What actually happens?

If there is an exception, please attach the exception trace:

```
Just put your stack trace here!
```

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

[GitHub] [incubator-dubbo] kexianjun commented on issue #3827: 通过spring配置文件方式消费dubbo服务,在servlet中注入了该dubbo服务,报代理错误

Posted by "kexianjun (GitHub)" <gi...@apache.org>.
>如果没记错的话,servlet默认不属于spring容器的bean, 所以你这个注解是不被扫描的。
可以将这个servlet使用spring的方式 ServletRegistrationBean 来把这个servlet注册到spring容器里

_Originally posted by @Gonzo-Tan in https://github.com/apache/incubator-dubbo/issues/770#issuecomment-339541534_

那这个回复能解答你的疑问吗

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

[GitHub] [incubator-dubbo] kexianjun commented on issue #3827: 通过spring配置文件方式消费dubbo服务,在servlet中注入了该dubbo服务,报代理错误

Posted by "kexianjun (GitHub)" <gi...@apache.org>.
这个问题跟dubbo关系不大,servlet 注入 spring bean 请参考 https://github.com/kexianjun/dubbo-test/blob/master/dubbo-issue-3827/issue-3827-comsumer/src/main/java/issue/test/servlet/WorkServlet.java

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

[GitHub] [incubator-dubbo] Alfred-Wong commented on issue #3827: 通过spring配置文件方式消费dubbo服务,在servlet中注入了该dubbo服务,报代理错误

Posted by "Alfred-Wong (GitHub)" <gi...@apache.org>.
> Can you provide a demo to reproduce this issue?

[#770]跟这个问题类似,差别在于没有使用注解的方式,通过<dubbo:reference >方式消费服务,并通过@Autowired的方式注入到servlet中

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

[GitHub] [incubator-dubbo] Alfred-Wong commented on issue #3827: 通过spring配置文件方式消费dubbo服务,在servlet中注入了该dubbo服务,报代理错误

Posted by "Alfred-Wong (GitHub)" <gi...@apache.org>.
跟[https://github.com/apache/incubator-dubbo/issues/770](url)这个问题类似,差别在于没有使用注解的方式,通过<dubbo o:reference >方式消费服务,并通过@Autowired的方式注入到servlet中

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

[GitHub] [incubator-dubbo] Alfred-Wong commented on issue #3827: 通过spring配置文件方式消费dubbo服务,在servlet中注入了该dubbo服务,报代理错误

Posted by "Alfred-Wong (GitHub)" <gi...@apache.org>.
[#770](https://github.com/apache/incubator-dubbo/issues/770)跟这个问题类似,差别在于没有使用注解的方式,通过<dubbo:reference >方式消费服务,并通过@Autowired的方式注入到servlet中

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

[GitHub] [incubator-dubbo] Alfred-Wong commented on issue #3827: 通过spring配置文件方式消费dubbo服务,在servlet中注入了该dubbo服务,报代理错误

Posted by "Alfred-Wong (GitHub)" <gi...@apache.org>.
[#770]跟这个问题类似,差别在于没有使用注解的方式,通过<dubbo:reference >方式消费服务,并通过@Autowired的方式注入到servlet中

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

[GitHub] [incubator-dubbo] Alfred-Wong commented on issue #3827: 通过spring配置文件方式消费dubbo服务,在servlet中注入了该dubbo服务,报代理错误

Posted by "Alfred-Wong (GitHub)" <gi...@apache.org>.
跟[https://github.com/apache/incubator-dubbo/issues/770#issue-267959964](url)这个问题类似,差别在于没有使用注解的方式,通过<dubbo o:reference >方式消费服务,并通过@Autowired的方式注入到servlet中

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

[GitHub] [incubator-dubbo] Alfred-Wong commented on issue #3827: 通过spring配置文件方式消费dubbo服务,在servlet中注入了该dubbo服务,报代理错误

Posted by "Alfred-Wong (GitHub)" <gi...@apache.org>.
> > 如果没记错的话,servlet默认不属于spring容器的bean, 所以你这个注解是不被扫描的。
> > 可以将这个servlet使用spring的方式 ServletRegistrationBean 来把这个servlet注册到spring容器里
> 
> _Originally posted by @Gonzo-Tan in [#770 (comment)](https://github.com/apache/incubator-dubbo/issues/770#issuecomment-339541534)_
> 
> 那这个回复能解答你的疑问吗

跟我的问题有点差异。我的是非注解方式,且如果通过配置饥饿加载可以注入。非饥饿加载Spring代理报无法继承final类无法进行字节码增强

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

[GitHub] [incubator-dubbo] CodeIngL commented on issue #3827: 通过spring配置文件方式消费dubbo服务,在servlet中注入了该dubbo服务,报代理错误

Posted by "CodeIngL (GitHub)" <gi...@apache.org>.
使用lazy的得到的结果是你的接口单独被代理,而不是dubbo出来的proxy,这意味着你二次代理的对象不在是org.apache.dubbo.common.bytecode.proxy0。之后在你真正调用方法的时候才会引用到你的dubboproxy

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

[GitHub] [incubator-dubbo] Alfred-Wong commented on issue #3827: 通过spring配置文件方式消费dubbo服务,在servlet中注入了该dubbo服务,报代理错误

Posted by "Alfred-Wong (GitHub)" <gi...@apache.org>.
> > 如果没记错的话,servlet默认不属于spring容器的bean, 所以你这个注解是不被扫描的。
> > 可以将这个servlet使用spring的方式 ServletRegistrationBean 来把这个servlet注册到spring容器里
> 
> _Originally posted by @Gonzo-Tan in [#770 (comment)](https://github.com/apache/incubator-dubbo/issues/770#issuecomment-339541534)_
> 不是我的问题所在,非注解方式,如果配置饥饿加载就可以。
> 那这个回复能解答你的疑问吗
Hi


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

[GitHub] [incubator-dubbo] kexianjun commented on issue #3827: 通过spring配置文件方式消费dubbo服务,在servlet中注入了该dubbo服务,报代理错误

Posted by "kexianjun (GitHub)" <gi...@apache.org>.
Can you provide a demo to reproduce this issue?

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


[GitHub] [incubator-dubbo] Alfred-Wong commented on issue #3827: 通过spring配置文件方式消费dubbo服务,在servlet中注入了该dubbo服务,报代理错误

Posted by "Alfred-Wong (GitHub)" <gi...@apache.org>.
#770跟这个问题类似,差别在于没有使用注解的方式,通过<dubbo:reference >方式消费服务,并通过@Autowired的方式注入到servlet中

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

[GitHub] [incubator-dubbo] kexianjun commented on issue #3827: 通过spring配置文件方式消费dubbo服务,在servlet中注入了该dubbo服务,报代理错误

Posted by "kexianjun (GitHub)" <gi...@apache.org>.
servlet 注入 spring bean 请参考 https://github.com/kexianjun/dubbo-test/blob/master/dubbo-issue-3827/issue-3827-comsumer/src/main/java/issue/test/servlet/WorkServlet.java 

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