一、该问题的重现步骤是什么?
1. 总共两台服务器.A服务器安装了系统环境.如,redis.nacos.rabbitmq.nginx等
2. jar 包部署在另外一台B服务器上. 通过A服务的中nginx 代理到具体的jar包服务模块上
二、你期待的结果是什么?实际看到的又是什么?
1,期望结果为.能正常访问服务模块
2,通过接口前端页面访问后端系统模块出现以下信息.
Failed to handle request [POST http://47.109.*.*/blade-auth/oauth/token?username=admin&password=e10adc3949ba59abbe56e057f20f883e&grant_type=captcha&scope=all&type=account]: null: /172.24.*.*:8100"
其他服务模块出现
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: 2025-01-06 17:39:18.768 ERROR 17079 --- [ XNIO-1 task-2] o.s.c.l.e.BladeRestExceptionTranslator : 服务器异常
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: ### Error querying database. Cause: java.lang.NullPointerException
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: ### Cause: java.lang.NullPointerException
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:97) ~[mybatis-spring-2.1.1.jar!/:2.1.1]
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:439) ~[mybatis-spring-2.1.1.jar!/:2.1.1]
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: at com.sun.proxy.$Proxy158.selectList(Unknown Source) ~[na:na]
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:224) ~[mybatis-spring-2.1.1.jar!/:2.1.1]
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.executeForMany(MybatisMapperMethod.java:166) ~[mybatis-plus-core-3.5.3.2.jar!/:3.5.3.2]
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:77) ~[mybatis-plus-core-3.5.3.2.jar!/:3.5.3.2]
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: at com.baomidou.mybatisplus.core.override.MybatisMapperProxy$PlainMethodInvoker.invoke(MybatisMapperProxy.java:148) ~[mybatis-plus-core-3.5.3.2.jar!/:3.5.3.2]
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:89) ~[mybatis-plus-core-3.5.3.2.jar!/:3.5.3.2]
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: at com.sun.proxy.$Proxy189.selectVillageAppPage(Unknown Source) ~[na:na]
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: at org.springblade.adminapp.service.impl.VillageAppServiceImpl.selectVillageAppPage(VillageAppServiceImpl.java:51) ~[classes!/:na]
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: at org.springblade.adminapp.service.impl.VillageAppServiceImpl$$FastClassBySpringCGLIB$$7120f17a.invoke(<generated>) ~[classes!/:na]
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) ~[spring-core-5.3.29.jar!/:5.3.29]
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:793) ~[spring-aop-5.3.29.jar!/:5.3.29]
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.3.29.jar!/:5.3.29]
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763) ~[spring-aop-5.3.29.jar!/:5.3.29]
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: at org.springframework.validation.beanvalidation.MethodValidationInterceptor.invoke(MethodValidationInterceptor.java:123) ~[spring-context-5.3.29.jar!/:5.3.29]
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.29.jar!/:5.3.29]
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763) ~[spring-aop-5.3.29.jar!/:5.3.29]
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:708) ~[spring-aop-5.3.29.jar!/:5.3.29]
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: at org.springblade.adminapp.service.impl.VillageAppServiceImpl$$EnhancerBySpringCGLIB$$7f5ce7f2.selectVillageAppPage(<generated>) ~[classes!/:na]
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: at org.springblade.adminapp.manager.impl.VillageAppMgrServcieImpl.selectVillageAppPage(VillageAppMgrServcieImpl.java:110) ~[classes!/:na]
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: at org.springblade.adminapp.manager.impl.VillageAppMgrServcieImpl$$FastClassBySpringCGLIB$$7a832344.invoke(<generated>) ~[classes!/:na]
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) ~[spring-core-5.3.29.jar!/:5.3.29]
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: at org.springframework.aop.framework.CglibAopProxy.invokeMethod(CglibAopProxy.java:386) ~[spring-aop-5.3.29.jar!/:5.3.29]
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: at org.springframework.aop.framework.CglibAopProxy.access$000(CglibAopProxy.java:85) ~[spring-aop-5.3.29.jar!/:5.3.29]
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:704) ~[spring-aop-5.3.29.jar!/:5.3.29]
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: at org.springblade.adminapp.manager.impl.VillageAppMgrServcieImpl$$EnhancerBySpringCGLIB$$c6a3eb90.selectVillageAppPage(<generated>) ~[classes!/:na]
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: at org.springblade.adminapp.controller.VillageAppController.page(VillageAppController.java:68) ~[classes!/:na]
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: at org.springblade.adminapp.controller.VillageAppController$$FastClassBySpringCGLIB$$29c35634.invoke(<generated>) ~[classes!/:na]
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) ~[spring-core-5.3.29.jar!/:5.3.29]
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:793) ~[spring-aop-5.3.29.jar!/:5.3.29]
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.3.29.jar!/:5.3.29]
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763) ~[spring-aop-5.3.29.jar!/:5.3.29]
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:89) ~[spring-aop-5.3.29.jar!/:5.3.29]
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: at org.springblade.core.log.aspect.RequestLogAspect.aroundApi(RequestLogAspect.java:119) ~[blade-starter-log-3.2.0.RELEASE.jar!/:na]
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: at sun.reflect.GeneratedMethodAccessor128.invoke(Unknown Source) ~[na:na]
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_371]
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_371]
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:634) ~[spring-aop-5.3.29.jar!/:5.3.29]
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:624) ~[spring-aop-5.3.29.jar!/:5.3.29]
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:72) ~[spring-aop-5.3.29.jar!/:5.3.29]
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:175) ~[spring-aop-5.3.29.jar!/:5.3.29]
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763) ~[spring-aop-5.3.29.jar!/:5.3.29]
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97) ~[spring-aop-5.3.29.jar!/:5.3.29]
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.29.jar!/:5.3.29]
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763) ~[spring-aop-5.3.29.jar!/:5.3.29]
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:708) ~[spring-aop-5.3.29.jar!/:5.3.29]
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: at org.springblade.adminapp.controller.VillageAppController$$EnhancerBySpringCGLIB$$e6f40ce9.page(<generated>) ~[classes!/:na]
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_371]
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_371]
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_371]
Jan 6 17:39:18 iZ2vcfti1q5gin57xi2214Z spring_blade_adminapp_jar: at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_371]
但是如果把这些jar 服务放到A 服务器中...所有jar 及前端请求..又是正常的
通过这个日志可以大概推断出问题出自于网络不通
Failed to handle request [POST http://47.109.*.*/blade-auth/oauth/token?username=admin&password=e10adc3949ba59abbe56e057f20f883e&grant_type=captcha&scope=all&type=account]: null: /172.24.*.*:8100"
你访问47.109.*.*的地址,但是他内部去nacos调用时请求的地址是172.24.*.*:8100 ,如果不能连通,就会报错。
你把服务都放到a服务器,因为都是在同一台本地,那么网络自然就不会有问题。你如果分开来,需要保证两台服务器ip互通,并且注册到nacos的地址也需要是真实可互通的地址。
你的gateway也是部署在b服务器和其他的服务一起的么?如果这样的话,只需要注册内网ip到nacos就行,因为gateway会先从nacos获取ip,然后gateway来请求这个ip。那么注册的ip只要是gateway所在服务器能连通的就行。
都是阿里云的服务器!网路都是通的,都可以注册到nacos 中去
gateway 是部署到A服务器中的
gateway部署在a,其他服务部署在b。
那么你现在b服务部署后,注册到nacos的ip,需要手动置顶成b的内网ip地址。不能让他自动找子网地址。
看你的日志,b的服务注册过去变成172开头的ip了。你用a的gateway去访问172肯定访问不通的,注册ip改成内网的就行了。
注册指定可以用这个参数,在LauncherServiceImpl配置:
@AutoService(LauncherService.class) public class DemoLauncherServiceImpl implements LauncherService { @Override public void launcher(SpringApplicationBuilder builder, String appName, String profile, boolean isLocalDev) { Properties props = System.getProperties(); // 指定注册IP PropsUtil.setProperty(props, "spring.cloud.nacos.discovery.ip", "127.0.0.1"); // 指定注册端口 PropsUtil.setProperty(props, "spring.cloud.nacos.discovery.port", "8200"); } @Override public int getOrder() { return 20; } }
或者给jar包启动的时候加上命令行,大概如下:
java -jar app.jar --spring.profiles.active=prod --spring.cloud.nacos.discovery.ip=${ADMIN_IP} --spring.cloud.nacos.discovery.port=${ADMIN_PORT}
扫一扫访问 Blade技术社区 移动端