Feign调用问题 status 401 reading IUserClient#getUsersByDept

Blade 未结 3 1545
brucedong
brucedong 剑圣 2021-04-13 18:46

一、该问题的重现步骤是什么?


自定义bladex-user-api feign 接口:

image.png


并作blade-user-service实现:

image.png


feign客户端调用:

image.png


报错:


image.png


二、你期待的结果是什么?实际看到的又是什么?


当然是正常调用,难道不支持自定义 还需要改动哪些地方


三、你正在使用的是什么产品,什么版本?在什么操作系统上?


BLADEX 

2.6.0.RELEASE


四、请提供详细的错误堆栈信息,这很重要。


五、若有更多详细信息,请在下面提供。

3条回答
  • 2021-04-13 19:14

    我本地测试无误,你再看下控制台的报错吧,你从网页直接访问自然不行,这是需要token认证的

    另外你查一下dept_id字段是否有配置多部门,如果有的话,in和eq就不适合,要用like

    image.png

    image.png

    image.png

    image.png

    作者追问:2021-04-14 11:38

    发现问题了,

    blade-system blade-user和业务系统 biz在同一个微服务环境,比如 都在生成环境,通过feign调用 是可以调通

    但 Biz业务系统在开发环境,就会出现401提示

    这个是什么原因呢

    回答: 2021-04-14 12:42

    你在一个环境能调通,那就不是代码的问题,是部署的问题。你需要确认所有服务是否都部署在同一个环境,服务之间是否可以相互联通

    0 讨论(0)
  • 2021-04-14 08:17

    ================  Request Start  ================

    ===> GET: /duty_roster_record/getUserList

    ===Headers===  Blade-Auth: bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0ZW5hbnRfaWQiOiIwMDAwMDAiLCJ1c2VyX25hbWUiOiJhZG1pbiIsInJlYWxfbmFtZSI6IueuoeeQhuWRmCIsImF2YXRhciI6Imh0dHBzOi8vZ3cuYWxpcGF5b2JqZWN0cy5jb20vem9zL3Jtc3BvcnRhbC9CaWF6ZmFueG1hbU5Sb3h4VnhrYS5wbmciLCJhdXRob3JpdGllcyI6WyJhZG1pbmlzdHJhdG9yIl0sImNsaWVudF9pZCI6InNhYmVyIiwicm9sZV9uYW1lIjoiYWRtaW5pc3RyYXRvciIsImxpY2Vuc2UiOiJQb3dlcmVkIGJ5IHl1bmNodWFuZy50ZWNoIiwicG9zdF9pZCI6IjExMjM1OTg4MTc3Mzg2NzUyMDEiLCJ1c2VyX2lkIjoiMTEyMzU5ODgyMTczODY3NTIwMSIsInJvbGVfaWQiOiIxMTIzNTk4ODE2NzM4Njc1MjAxIiwic2NvcGUiOlsiYWxsIl0sIm5pY2tfbmFtZSI6IueuoeeQhuWRmCIsIm9hdXRoX2lkIjoiIiwiZXhwIjoxNjE4MzAyNDUwLCJkZXB0X2lkIjoiMTEyMzU5ODgxMzczODY3NTIwMSIsImp0aSI6ImUwNWQ3OTk4LTBkNTYtNDNiMy05MmFkLTQ0N2RmNDU3Mzg0NyIsImFjY291bnQiOiJhZG1pbiJ9.KGd_gAr-KC5XOEossK32MwwkGUonUSyBHkxx1HW2nrU

    ===Headers===  Accept: */*

    ===Headers===  Connection: keep-alive

    ===Headers===  User-Agent: PostmanRuntime/7.26.10

    ===Headers===  Postman-Token: ad10adc3-d111-4aa7-a4dd-d566beb8081c

    ===Headers===  Host: localhost:8301

    ===Headers===  Accept-Encoding: gzip, deflate, br

    ================   Request End   ================


    2021-04-14 08:06:01.573  INFO 5400 --- [  XNIO-1 task-2] c.y.core.log.aspect.RequestLogAspect     : 


    ================  Response Start  ================

    <=== GET: /duty_roster_record/getUserList (21 ms)

    ================   Response End   ================


    2021-04-14 08:06:01.575 ERROR 5400 --- [  XNIO-1 task-2] c.y.c.l.e.CloudRestExceptionTranslator   : 服务器异常


    feign.FeignException$Unauthorized: status 401 reading IUserClient#getUsersByDept(Long)

            at feign.FeignException.clientErrorStatus(FeignException.java:161)

            at feign.FeignException.errorStatus(FeignException.java:141)

            at feign.FeignException.errorStatus(FeignException.java:133)

            at feign.codec.ErrorDecoder$Default.decode(ErrorDecoder.java:92)

            at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:151)

            at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:80)

            at feign.ReflectiveFeign$FeignInvocationHandler.invoke(ReflectiveFeign.java:103)

            at com.sun.proxy.$Proxy295.getUsersByDept(Unknown Source)

            at com.yunchuang.feed.controller.SopDutyRosterRecordController.getUserList(SopDutyRosterRecordController.java:84)

            at com.yunchuang.feed.controller.SopDutyRosterRecordController$$FastClassBySpringCGLIB$$e0cd84a1.invoke(<generated>)

            at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)

            at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:752)

            at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)

            at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:88)

            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:498)

            at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:644)

            at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:633)

            at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70)

            at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:175)

            at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:93)

            at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)

            at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691)

            at com.yunchuang.feed.controller.SopDutyRosterRecordController$$EnhancerBySpringCGLIB$$a7d256d9.getUserList(<generated>)

            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:498)

            at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190)

            at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)

            at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105)     

            at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:892)   

            at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:797)        

            at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)

            at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040)

            at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)

            at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)

            at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)

            at javax.servlet.http.HttpServlet.service(HttpServlet.java:645)

            at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)

            at javax.servlet.http.HttpServlet.service(HttpServlet.java:750)

            at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74)

            at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129)

            at com.github.xiaoymin.knife4j.spring.filter.ProductionSecurityFilter.doFilter(ProductionSecurityFilter.java:53)

            at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)

            at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)

            at com.github.xiaoymin.knife4j.spring.filter.SecurityBasicAuthFilter.doFilter(SecurityBasicAuthFilter.java:90)

            at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)

            at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)

            at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)

            at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)

            at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)

            at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)

            at org.springframework.boot.actuate.web.trace.servlet.HttpTraceFilter.doFilterInternal(HttpTraceFilter.java:88)

            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)

            at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)

            at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)

            at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)

            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)

            at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)

            at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)

            at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)

            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)

            at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)

            at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)

            at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:94)

            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)

            at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)

            at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)

            at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.filterAndRecordMetrics(WebMvcMetricsFilter.java:114)

            at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:104)

            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)

            at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)

            at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)

            at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)

            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)

            at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)

            at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)

            at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)

            at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)

            at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68)

            at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)

            at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68)

            at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132)

            at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)

            at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)

            at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)

            at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)    

            at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)

            at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)

            at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)        

            at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)

            at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)

            at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269)

            at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78)

            at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133)

            at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130)

            at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)

            at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)

            at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249)

            at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78)

            at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99)

            at io.undertow.server.Connectors.executeRootHandler(Connectors.java:376)

            at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:830)

            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

            at java.lang.Thread.run(Thread.java:745)



    回答: 2021-04-14 08:19

    带着token访问也是这样的报错,不清楚是在哪个环节被拦截

    回答: 2021-04-14 08:36

    image.png

    in查询换成like,还是同样的错误输出

    0 讨论(0)
  • 2021-04-14 08:33

    兄弟 你请求头没有Authorization

    作者追问:2021-04-14 08:40

    加上也是这样子:

    image.png



    0 讨论(1)
提交回复