You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "a601942905git (GitHub)" <gi...@apache.org> on 2018/10/25 15:06:03 UTC

[GitHub] [incubator-dubbo] a601942905git opened issue #2689: @Reference注解使用mock="return null"属性报错

在测试本地伪装的时候,在@Reference注解中使用mock="return null"属性会出现ClassNotFoundException异常,而在xml配置文件中使用mock="return null"就没有问题,难道注解不支持嘛?

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

[GitHub] [incubator-dubbo] diecui1202 commented on issue #2689: @Reference注解使用mock="return null"属性报错

Posted by "diecui1202 (GitHub)" <gi...@apache.org>.
@mercyblitz could u take some time to check this issue?

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


[GitHub] [incubator-dubbo] beiwei30 commented on issue #2689: @Reference注解使用mock="return null"属性报错

Posted by "beiwei30 (GitHub)" <gi...@apache.org>.
@a601942905git I tried to verify it on `2.6.5-SNAPSHOT`, it works as expected.

See below for what I changed:

### boot-dubbo-consumer/pom.xml

```diff
diff --git a/boot-dubbo-consumer/pom.xml b/boot-dubbo-consumer/pom.xml
index 8eacf77..fab9eec 100644
--- a/boot-dubbo-consumer/pom.xml
+++ b/boot-dubbo-consumer/pom.xml
@@ -28,9 +28,27 @@
             <version>0.0.1-SNAPSHOT</version>
         </dependency>
 
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>dubbo</artifactId>
+            <version>2.6.5-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.alibaba.spring</groupId>
+            <artifactId>spring-context-support</artifactId>
+            <version>1.0.2</version>
+        </dependency>
+
         <dependency>
             <groupId>com.alibaba.boot</groupId>
             <artifactId>dubbo-spring-boot-starter</artifactId>
+            <exclusions>
+                <exclusion>
+                    <groupId>com.alibaba</groupId>
+                    <artifactId>dubbo</artifactId>
+                </exclusion>
+            </exclusions>
         </dependency>
 
         <dependency>
```

### com/boot/dubbo/mock/FooCustomerService.java

```diff
diff --git a/boot-dubbo-consumer/src/main/java/com/boot/dubbo/mock/FooCustomerService.java b/boot-dubbo-consumer/src/main/java/com/boot/dubbo/mock/FooCustomerService.java
index dc6c2a1..300e7e5 100644
--- a/boot-dubbo-consumer/src/main/java/com/boot/dubbo/mock/FooCustomerService.java
+++ b/boot-dubbo-consumer/src/main/java/com/boot/dubbo/mock/FooCustomerService.java
@@ -12,7 +12,8 @@ import org.springframework.stereotype.Service;
 @Service
 public class FooCustomerService {
 
-    @Reference(mock = "com.boot.dubbo.mock.MockService")
+//    @Reference(mock = "com.boot.dubbo.mock.MockService")
+    @Reference(mock = "return hello")
     private FooService fooService;
 
     public String testMock() {
```

### output:

```bash
Caused by: com.alibaba.dubbo.remoting.TimeoutException: Waiting server-side response timeout. start time: 2018-10-31 16:37:11.130, end time: 2018-10-31 16:37:14.131, client elapsed: 0 ms, server elapsed: 3001 ms, timeout: 3000 ms, request: Request [id=2, version=2.0.2, twoway=true, event=false, broken=false, data=RpcInvocation [methodName=testFoo, parameterTypes=[], arguments=[], attachments={path=com.boot.dubbo.mock.FooService, interface=com.boot.dubbo.mock.FooService, version=0.0.0, timeout=3000}]], channel: /169.254.14.63:56601 -> /169.254.14.63:20880
	at com.alibaba.dubbo.remoting.exchange.support.DefaultFuture.get(DefaultFuture.java:159) ~[dubbo-2.6.5-SNAPSHOT.jar:2.6.5-SNAPSHOT]
	at com.alibaba.dubbo.remoting.exchange.support.DefaultFuture.get(DefaultFuture.java:135) ~[dubbo-2.6.5-SNAPSHOT.jar:2.6.5-SNAPSHOT]
	at com.alibaba.dubbo.rpc.protocol.dubbo.DubboInvoker.doInvoke(DubboInvoker.java:95) ~[dubbo-2.6.5-SNAPSHOT.jar:2.6.5-SNAPSHOT]
	at com.alibaba.dubbo.rpc.protocol.AbstractInvoker.invoke(AbstractInvoker.java:155) ~[dubbo-2.6.5-SNAPSHOT.jar:2.6.5-SNAPSHOT]
	at com.alibaba.dubbo.monitor.support.MonitorFilter.invoke(MonitorFilter.java:75) ~[dubbo-2.6.5-SNAPSHOT.jar:2.6.5-SNAPSHOT]
	at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:72) ~[dubbo-2.6.5-SNAPSHOT.jar:2.6.5-SNAPSHOT]
	at com.alibaba.dubbo.rpc.protocol.dubbo.filter.FutureFilter.invoke(FutureFilter.java:54) ~[dubbo-2.6.5-SNAPSHOT.jar:2.6.5-SNAPSHOT]
	at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:72) ~[dubbo-2.6.5-SNAPSHOT.jar:2.6.5-SNAPSHOT]
	at com.alibaba.dubbo.rpc.filter.ConsumerContextFilter.invoke(ConsumerContextFilter.java:49) ~[dubbo-2.6.5-SNAPSHOT.jar:2.6.5-SNAPSHOT]
	at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:72) ~[dubbo-2.6.5-SNAPSHOT.jar:2.6.5-SNAPSHOT]
	at com.alibaba.dubbo.rpc.listener.ListenerInvokerWrapper.invoke(ListenerInvokerWrapper.java:77) ~[dubbo-2.6.5-SNAPSHOT.jar:2.6.5-SNAPSHOT]
	at com.alibaba.dubbo.rpc.protocol.InvokerWrapper.invoke(InvokerWrapper.java:56) ~[dubbo-2.6.5-SNAPSHOT.jar:2.6.5-SNAPSHOT]
	at com.alibaba.dubbo.rpc.cluster.support.FailoverClusterInvoker.doInvoke(FailoverClusterInvoker.java:78) ~[dubbo-2.6.5-SNAPSHOT.jar:2.6.5-SNAPSHOT]
	... 12 common frames omitted

调用服务返回结果:hello
```


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

[GitHub] [incubator-dubbo] a601942905git commented on issue #2689: @Reference注解使用mock="return null"属性报错

Posted by "a601942905git (GitHub)" <gi...@apache.org>.
@diecui1202 no one to check this issue?

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


[GitHub] [incubator-dubbo] a601942905git commented on issue #2689: @Reference注解使用mock="return null"属性报错

Posted by "a601942905git (GitHub)" <gi...@apache.org>.
I can provide the code for you [mock-test](https://github.com/a601942905git/boot-dubbo/blob/master/boot-dubbo-consumer/src/main/java/com/boot/dubbo/mock/FooCustomerService.java)

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


[GitHub] [incubator-dubbo] beiwei30 closed issue #2689: @Reference注解使用mock="return null"属性报错

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

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


[GitHub] [incubator-dubbo] beiwei30 commented on issue #2689: @Reference注解使用mock="return null"属性报错

Posted by "beiwei30 (GitHub)" <gi...@apache.org>.
ps, your samples looks good. Are you interested in building https://github.com/dubbo/dubbo-samples together, to show all Dubbo's features as many as possible, and as simple as possible?

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


[GitHub] [incubator-dubbo] beiwei30 commented on issue #2689: @Reference注解使用mock="return null"属性报错

Posted by "beiwei30 (GitHub)" <gi...@apache.org>.
@a601942905git I'm on it.

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