You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2020/02/19 08:47:51 UTC

[GitHub] [servicecomb-java-chassis] xuzhiweiand opened a new issue #1582: 使用InvokerUtils.syncInvoke调用RPC接口,一直失败,所有RPC接口都报NullPointerException

xuzhiweiand opened a new issue #1582: 使用InvokerUtils.syncInvoke调用RPC接口,一直失败,所有RPC接口都报NullPointerException
URL: https://github.com/apache/servicecomb-java-chassis/issues/1582
 
 
   所有RPC调用都报空指针,异常来源于servicecomb
   2020-02-18 00:04:18,280Z | ERROR | pool-48-thread-4 | InvokerUtils                     |  | com.huawei.m2m.cig.rpcservice | invoke failed,
   java.lang.NullPointerException: null
           at org.apache.servicecomb.core.Invocation.initTraceId(Invocation.java:248) ~[98:com.huawei.m2m.cig.rpcservice:20.2.3]
           at org.apache.servicecomb.core.Invocation.onStart(Invocation.java:280) ~[98:com.huawei.m2m.cig.rpcservice:20.2.3]
           at org.apache.servicecomb.core.Invocation.onStart(Invocation.java:286) ~[98:com.huawei.m2m.cig.rpcservice:20.2.3]
           at org.apache.servicecomb.core.provider.consumer.InvokerUtils.innerSyncInvoke(InvokerUtils.java:68) [98:com.huawei.m2m.cig.rpcservice:20.2.3]
           at org.apache.servicecomb.core.provider.consumer.InvokerUtils.syncInvoke(InvokerUtils.java:54) [98:com.huawei.m2m.cig.rpcservice:20.2.3]
           at org.apache.servicecomb.core.provider.consumer.InvokerUtils.syncInvoke(InvokerUtils.java:37) [98:com.huawei.m2m.cig.rpcservice:20.2.3]
           at com.huawei.m2m.cig.rpcservice.iocm.IocmCmService.queryCertificatesByPage(IocmCmService.java:184) [98:com.huawei.m2m.cig.rpcservice:20.2.3]
           at com.huawei.m2m.cig.rpcservice.iocm.IocmCmService.queryCertificates(IocmCmService.java:153) [98:com.huawei.m2m.cig.rpcservice:20.2.3]
           at com.huawei.m2m.cig.rpcservice.cert.DeviceCaCerMgr.loadCaCert(DeviceCaCerMgr.java:81) [98:com.huawei.m2m.cig.rpcservice:20.2.3]
           at com.huawei.m2m.cig.rpcservice.cert.DeviceCaCerMgr.access$000(DeviceCaCerMgr.java:37) [98:com.huawei.m2m.cig.rpcservice:20.2.3]
           at com.huawei.m2m.cig.rpcservice.cert.DeviceCaCerMgr$1.run(DeviceCaCerMgr.java:60) [98:com.huawei.m2m.cig.rpcservice:20.2.3]
           at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]
           at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
           at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:?]
           at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:?]
           at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
           at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
           at java.lang.Thread.run(Thread.java:748) [?:?]
   
   2020-02-18 00:04:18,280Z | ERROR | pool-42-thread-1 | InvokerUtils                     |  | com.huawei.m2m.cig.rpcservice | invoke failed,
   java.lang.NullPointerException: null
           at org.apache.servicecomb.core.Invocation.initTraceId(Invocation.java:248) ~[?:?]
           at org.apache.servicecomb.core.Invocation.onStart(Invocation.java:280) ~[?:?]
           at org.apache.servicecomb.core.Invocation.onStart(Invocation.java:286) ~[?:?]
           at org.apache.servicecomb.core.provider.consumer.InvokerUtils.innerSyncInvoke(InvokerUtils.java:68) ~[?:?]
           at org.apache.servicecomb.core.provider.consumer.InvokerUtils.syncInvoke(InvokerUtils.java:54) ~[?:?]
           at org.apache.servicecomb.core.provider.consumer.InvokerUtils.syncInvoke(InvokerUtils.java:37) ~[?:?]
           at com.huawei.m2m.cig.rpcservice.mongo.IocmDeviceAppService.findOneByDeviceId(IocmDeviceAppService.java:46) ~[?:?]
           at com.huawei.m2m.cig.service.connectionInfo.MqttInfo.addConnectionInfo(MqttInfo.java:31) ~[?:?]
           at com.huawei.m2m.cig.mqtt.server.MqttMessageHandler.onConnect(MqttMessageHandler.java:167) ~[?:?]
           at io.moquette.spi.impl.BrokerInterceptor.lambda$notifyClientConnected$0(BrokerInterceptor.java:99) ~[?:?]
           at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
           at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
           at java.lang.Thread.run(Thread.java:748) [?:?]

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] xuzhiweiand commented on issue #1582: 使用InvokerUtils.syncInvoke调用RPC接口,一直失败,所有RPC接口都报NullPointerException

Posted by GitBox <gi...@apache.org>.
xuzhiweiand commented on issue #1582: 使用InvokerUtils.syncInvoke调用RPC接口,一直失败,所有RPC接口都报NullPointerException
URL: https://github.com/apache/servicecomb-java-chassis/issues/1582#issuecomment-588632016
 
 
   我们通过demo进行验证不同class loader是否会导致这个问题,发现不会导致此问题。
   
   public static void main(String[] args) throws Exception {
   
           ExecutorService executorService = Executors.newFixedThreadPool(2);
   
           ClassLoader cl = Thread.currentThread().getContextClassLoader();
   
           executorService.submit(() -> {
               ClassLoader one = new MyClassLoader();
               Thread.currentThread().setContextClassLoader(one);
               try {
                   Log4jUtils.init();
                   BeanUtils.init();
                   InvokerUtils.syncInvoke("simple", "simpleService", "sayOh", new Object[]{"hello, me"});
               } catch (Throwable e) {
                   System.out.println("TEST ERROR");
               }
               System.out.println("TEST Thread " + Thread.currentThread().getContextClassLoader());
           });
           executorService.submit(() -> {
               ClassLoader two = new TheirClassLoader();
               Thread.currentThread().setContextClassLoader(two);
               try {
                   InvokerUtils.syncInvoke("simple", "simpleService", "sayOh", new Object[]{"hello, him"});
               } catch (Throwable e) {
                   System.out.println("ERROR");
               }
               System.out.println("TEST Thread " + Thread.currentThread().getContextClassLoader());
           });
   
           TimeUnit.SECONDS.sleep(30);
           Thread.currentThread().setContextClassLoader(cl);
       }

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] xuzhiweiand commented on issue #1582: 使用InvokerUtils.syncInvoke调用RPC接口,一直失败,所有RPC接口都报NullPointerException

Posted by GitBox <gi...@apache.org>.
xuzhiweiand commented on issue #1582: 使用InvokerUtils.syncInvoke调用RPC接口,一直失败,所有RPC接口都报NullPointerException
URL: https://github.com/apache/servicecomb-java-chassis/issues/1582#issuecomment-588122116
 
 
   这个问题比较难复现,很多天才出一次,这个不好调试,我们的框架是OSGI的。

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] liubao68 commented on issue #1582: 使用InvokerUtils.syncInvoke调用RPC接口,一直失败,所有RPC接口都报NullPointerException

Posted by GitBox <gi...@apache.org>.
liubao68 commented on issue #1582: 使用InvokerUtils.syncInvoke调用RPC接口,一直失败,所有RPC接口都报NullPointerException
URL: https://github.com/apache/servicecomb-java-chassis/issues/1582#issuecomment-588650048
 
 
   我理解你的这个测试程序和OSGI还不一样。 你实现的classloader在加载类的时候,都会搜索父classloader,无论在哪个线程里面, TraceIdGenerator的实现都能够被classloader搜索到。 而OSGI的每个bundle有自己的classloader,每个bundle能够搜索的 jar 路径是不一样的,即某些bundle可能搜索不到TraceIdGenerator的实现。 
   
   对于OSGI的详细原理我也不熟悉,上面的理解仅供参考。 出现这个错误:
   
   ```
   pool-42-thread-1 | SPIServiceUtils | | com.huawei.m2m.cig.rpcservice | Can not find SPI service for org.apache.servicecomb.core.tracing.TraceIdGenerator
   ```
   
   并且实现类是存在的,那么肯定是和类加载和classpath搜索有关的问题。 所以寻找问题的方向是没错的。 对OSGI的环境java-chassis确实验证的很少,也没有给所有包提供bundle信息。 OSGI最大的特点是它的类隔离机制,不过在微服务架构下,这个机制显得画蛇添足。
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] yhs0092 commented on issue #1582: 使用InvokerUtils.syncInvoke调用RPC接口,一直失败,所有RPC接口都报NullPointerException

Posted by GitBox <gi...@apache.org>.
yhs0092 commented on issue #1582: 使用InvokerUtils.syncInvoke调用RPC接口,一直失败,所有RPC接口都报NullPointerException
URL: https://github.com/apache/servicecomb-java-chassis/issues/1582#issuecomment-588109695
 
 
   在日志里面搜关键字`org.apache.servicecomb.core.tracing.TraceIdGenerator`,能搜到什么记录吗?
   建议把搜到的日志连同下面几行贴出来看一下。
   这里报空指针看着像是TraceIdGenerator的实现类没有加载到

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] yhs0092 commented on issue #1582: 使用InvokerUtils.syncInvoke调用RPC接口,一直失败,所有RPC接口都报NullPointerException

Posted by GitBox <gi...@apache.org>.
yhs0092 commented on issue #1582: 使用InvokerUtils.syncInvoke调用RPC接口,一直失败,所有RPC接口都报NullPointerException
URL: https://github.com/apache/servicecomb-java-chassis/issues/1582#issuecomment-588117674
 
 
   这个扩展使用的是SPI加载机制,建议去`org.apache.servicecomb.core.Invocation#loadTraceIdGenerators`方法里面打个断点调试一下。加载操作就是这里做的

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] xuzhiweiand commented on issue #1582: 使用InvokerUtils.syncInvoke调用RPC接口,一直失败,所有RPC接口都报NullPointerException

Posted by GitBox <gi...@apache.org>.
xuzhiweiand commented on issue #1582: 使用InvokerUtils.syncInvoke调用RPC接口,一直失败,所有RPC接口都报NullPointerException
URL: https://github.com/apache/servicecomb-java-chassis/issues/1582#issuecomment-588113346
 
 
   日志报找不到 TraceIdGenerator 这个接口的实现,不知道这个是怎么加载机制  ?
   
   org.apache_20200218021222.log.gz:2020-02-18 00:04:13,440Z | INFO  | pool-48-thread-1 | SPIServiceUtils                  |  | com.huawei.m2m.cig.rpcservice | Found SPI service org.apache.servicecomb.common.rest.codec.produce.ProduceProcessor, count=2.
   org.apache_20200218021222.log.gz:2020-02-18 00:04:13,440Z | INFO  | pool-48-thread-1 | SPIServiceUtils                  |  | com.huawei.m2m.cig.rpcservice |   0.  @org.apache.servicecomb.common.rest.codec.produce.ProduceJsonProcessor.
   org.apache_20200218021222.log.gz:2020-02-18 00:04:13,440Z | INFO  | pool-48-thread-1 | SPIServiceUtils                  |  | com.huawei.m2m.cig.rpcservice |   1. org.apache.servicecomb.common.rest.codec.produce.ProduceTextPlainProcessor.
   org.apache_20200218021222.log.gz:2020-02-18 00:04:18,275Z | INFO  | pool-42-thread-1 | SPIServiceUtils                  |  | com.huawei.m2m.cig.rpcservice | Found SPI service javax.ws.rs.core.Response$StatusType, count=0.
   org.apache_20200218021222.log.gz:2020-02-18 00:04:18,277Z | INFO  | pool-42-thread-1 | SPIServiceUtils                  |  | com.huawei.m2m.cig.rpcservice | Found SPI service org.apache.servicecomb.core.tracing.TraceIdGenerator, count=0.
   org.apache_20200218021222.log.gz:2020-02-18 00:04:18,278Z | INFO  | pool-42-thread-1 | SPIServiceUtils                  |  | com.huawei.m2m.cig.rpcservice | Can not find SPI service for org.apache.servicecomb.core.tracing.TraceIdGenerator
   org.apache_20200218021222.log.gz:2020-02-18 00:04:18,286Z | INFO  | pool-48-thread-4 | SPIServiceUtils                  |  | com.huawei.m2m.cig.rpcservice | Found SPI service org.apache.servicecomb.swagger.invocation.exception.ExceptionToProducerResponseConverter, count=3.
   org.apache_20200218021222.log.gz:2020-02-18 00:04:18,287Z | INFO  | pool-48-thread-4 | SPIServiceUtils                  |  | com.huawei.m2m.cig.rpcservice |   0. org.apache.servicecomb.swagger.invocation.validator.ConstraintViolationExceptionToProducerResponseConverter.
   org.apache_20200218021222.log.gz:2020-02-18 00:04:18,287Z | INFO  | pool-48-thread-4 | SPIServiceUtils                  |  | com.huawei.m2m.cig.rpcservice |   1. org.apache.servicecomb.swagger.invocation.exception.InvocationExceptionToProducerResponseConverter.
   org.apache_20200218021222.log.gz:2020-02-18 00:04:18,287Z | INFO  | pool-48-thread-4 | SPIServiceUtils                  |  | com.huawei.m2m.cig.rpcservice |   2. org.apache.servicecomb.swagger.invocation.exception.DefaultExceptionToProducerResponseConverter.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] liubao68 edited a comment on issue #1582: 使用InvokerUtils.syncInvoke调用RPC接口,一直失败,所有RPC接口都报NullPointerException

Posted by GitBox <gi...@apache.org>.
liubao68 edited a comment on issue #1582: 使用InvokerUtils.syncInvoke调用RPC接口,一直失败,所有RPC接口都报NullPointerException
URL: https://github.com/apache/servicecomb-java-chassis/issues/1582#issuecomment-588123551
 
 
   那就要看下这个接口被 `第一次` 访问的场景有哪些。 OSGI 由于存在不同的 class loader, 不同的入口可能导致当前线程所处的 class loader 不一样, 出现加载类错误的情况。 OSGI 使得运行环境变得复杂, 问题不好发现。 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] liubao68 commented on issue #1582: 使用InvokerUtils.syncInvoke调用RPC接口,一直失败,所有RPC接口都报NullPointerException

Posted by GitBox <gi...@apache.org>.
liubao68 commented on issue #1582: 使用InvokerUtils.syncInvoke调用RPC接口,一直失败,所有RPC接口都报NullPointerException
URL: https://github.com/apache/servicecomb-java-chassis/issues/1582#issuecomment-588123551
 
 
   那就要看下这个接口被 `第一次` 的场景有哪些。 OSGI 由于存在不同的 class loader, 不同的入口可能导致当前线程所处的 class loader 不一样, 出现加载类错误的情况。 OSGI 使得运行环境变得复杂, 问题不好发现。 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] liubao68 edited a comment on issue #1582: 使用InvokerUtils.syncInvoke调用RPC接口,一直失败,所有RPC接口都报NullPointerException

Posted by GitBox <gi...@apache.org>.
liubao68 edited a comment on issue #1582: 使用InvokerUtils.syncInvoke调用RPC接口,一直失败,所有RPC接口都报NullPointerException
URL: https://github.com/apache/servicecomb-java-chassis/issues/1582#issuecomment-588123551
 
 
   那就要看下这个接口被访问的入口或者说线程有哪些。 OSGI 由于存在不同的 class loader, 不同的入口可能导致当前线程所处的 class loader 不一样, 出现加载类错误的情况。 OSGI 使得运行环境变得复杂, 问题不好发现。 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services