开发者社区> 问答> 正文

service内rpc调用其他service报错?报错

有一个提供数据服务的Aservice连接的A库A表;A服务启动正常。B服务引用了Aservice的api;B服务连接另外的数据库B。在启动B服务时就会报B库中找不到A表的错误(B库中确实无A表)。

1、B服务中pom设置如下

<dependency>
    <groupId>io.jboot.admin</groupId>
    <artifactId>A-service-api</artifactId>
    <version>1.0</version>
</dependency>

2、如果B服务不依赖不引用A服务,则两个服务都能正常使用

具体报错如下:

2018-08-02 08:07:17.228 [INFO ] com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Starting...
2018-08-02 08:07:17.523 [INFO ] com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Start completed.
2018-08-02 08:07:17.757 [ERROR] com.jfinal.core.Config - Plugin start error: com.jfinal.plugin.activerecord.ActiveRecordPlugin.
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'jboot-admin.usersinfo' doesn't exist
com.jfinal.plugin.activerecord.ActiveRecordException: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'jboot-admin.usersinfo' doesn't exist
    at com.jfinal.plugin.activerecord.TableBuilder.build(TableBuilder.java:55)
    at com.jfinal.plugin.activerecord.ActiveRecordPlugin.start(ActiveRecordPlugin.java:226)
    at com.jfinal.core.Config.startPlugins(Config.java:128)
    at com.jfinal.core.Config.configPluginWithOrder(Config.java:71)
    at com.jfinal.core.Config.configJFinal(Config.java:56)
    at com.jfinal.core.JFinal.init(JFinal.java:63)
    at com.jfinal.core.JFinalFilter.init(JFinalFilter.java:49)
    at io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:111)
    at io.undertow.servlet.core.ManagedFilter.createFilter(ManagedFilter.java:80)
    at io.undertow.servlet.core.DeploymentManagerImpl$2.call(DeploymentManagerImpl.java:590)
    at io.undertow.servlet.core.DeploymentManagerImpl$2.call(DeploymentManagerImpl.java:555)
    at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:42)
    at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
    at io.undertow.servlet.core.DeploymentManagerImpl.start(DeploymentManagerImpl.java:597)
    at io.jboot.server.undertow.UnderTowServer.initUndertowServer(UnderTowServer.java:104)
    at io.jboot.server.undertow.UnderTowServer.start(UnderTowServer.java:192)
    at io.jboot.Jboot.startServer(Jboot.java:167)
    at io.jboot.Jboot.start(Jboot.java:148)
    at io.jboot.Jboot.run(Jboot.java:91)
    at QuartzServiceStart.main(QuartzServiceStart.java:5)
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'jboot-admin.usersinfo' doesn't exist
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
    at com.mysql.jdbc.Util.getInstance(Util.java:408)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:943)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3973)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3909)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2527)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2680)
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2486)
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2444)
    at com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1381)
    at com.zaxxer.hikari.pool.ProxyStatement.executeQuery(ProxyStatement.java:111)
    at com.zaxxer.hikari.pool.HikariProxyStatement.executeQuery(HikariProxyStatement.java)
    at com.jfinal.plugin.activerecord.TableBuilder.doBuild(TableBuilder.java:71)
    at com.jfinal.plugin.activerecord.TableBuilder.build(TableBuilder.java:47)
    ... 19 common frames omitted
Can not create Table object, maybe the table UsersInfo is not exists.
java.lang.RuntimeException: Plugin start error: com.jfinal.plugin.activerecord.ActiveRecordPlugin.
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'jboot-admin.usersinfo' doesn't exist
    at com.jfinal.core.Config.startPlugins(Config.java:137)
    at com.jfinal.core.Config.configPluginWithOrder(Config.java:71)
    at com.jfinal.core.Config.configJFinal(Config.java:56)
    at com.jfinal.core.JFinal.init(JFinal.java:63)
    at com.jfinal.core.JFinalFilter.init(JFinalFilter.java:49)
    at io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:111)
    at io.undertow.servlet.core.ManagedFilter.createFilter(ManagedFilter.java:80)
    at io.undertow.servlet.core.DeploymentManagerImpl$2.call(DeploymentManagerImpl.java:590)
    at io.undertow.servlet.core.DeploymentManagerImpl$2.call(DeploymentManagerImpl.java:555)
    at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:42)
    at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
    at io.undertow.servlet.core.DeploymentManagerImpl.start(DeploymentManagerImpl.java:597)
    at io.jboot.server.undertow.UnderTowServer.initUndertowServer(UnderTowServer.java:104)
    at io.jboot.server.undertow.UnderTowServer.start(UnderTowServer.java:192)
    at io.jboot.Jboot.startServer(Jboot.java:167)
    at io.jboot.Jboot.start(Jboot.java:148)
    at io.jboot.Jboot.run(Jboot.java:91)
    at QuartzServiceStart.main(QuartzServiceStart.java:5)
Caused by: com.jfinal.plugin.activerecord.ActiveRecordException: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'jboot-admin.usersinfo' doesn't exist
    at com.jfinal.plugin.activerecord.TableBuilder.build(TableBuilder.java:55)
    at com.jfinal.plugin.activerecord.ActiveRecordPlugin.start(ActiveRecordPlugin.java:226)
    at com.jfinal.core.Config.startPlugins(Config.java:128)
    ... 17 more
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'jboot-admin.usersinfo' doesn't exist
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
    at com.mysql.jdbc.Util.getInstance(Util.java:408)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:943)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3973)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3909)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2527)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2680)
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2486)
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2444)
    at com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1381)
    at com.zaxxer.hikari.pool.ProxyStatement.executeQuery(ProxyStatement.java:111)
    at com.zaxxer.hikari.pool.HikariProxyStatement.executeQuery(HikariProxyStatement.java)
    at com.jfinal.plugin.activerecord.TableBuilder.doBuild(TableBuilder.java:71)
    at com.jfinal.plugin.activerecord.TableBuilder.build(TableBuilder.java:47)
    ... 19 more
八月 02, 2018 8:07:17 上午 io.jboot.server.undertow.UnderTowServer error
严重: can not start undertow with port:9102
java.lang.IllegalArgumentException: UT000008: Handler cannot be null
    at io.undertow.Handlers.handlerNotNull(Handlers.java:582)
    at io.undertow.server.handlers.PathHandler.addPrefixPath(PathHandler.java:131)
    at io.jboot.server.undertow.UnderTowServer.initUndertowServer(UnderTowServer.java:113)
    at io.jboot.server.undertow.UnderTowServer.start(UnderTowServer.java:192)
    at io.jboot.Jboot.startServer(Jboot.java:167)
    at io.jboot.Jboot.start(Jboot.java:148)
    at io.jboot.Jboot.run(Jboot.java:91)
    at QuartzServiceStart.main(QuartzServiceStart.java:5)

jboot start fail!!!

 

3、两个service的jboot.properties基本一样,除了数据库连接参数。都参照jboot-admin进行的配置

#---------------------------------------------------------------------------------#
# Generator Config
# jboot.admin.serviceimpl.ge.entity.package: the entity package;
# jboot.admin.serviceimpl.ge.servicepackage:service 接口 package
# jboot.admin.serviceimpl.ge.serviceimplpackage:service 实现类 package
# jboot.admin.serviceimpl.ge.localdev.removedtablenameprefixes: 需要移除表名前缀只留下后部分,多个逗号隔开
# jboot.admin.serviceimpl.ge.localdev.excludedtable: 生成时不包含表名列表,多个逗号隔开
# jboot.admin.serviceimpl.ge.excludedtableprefixes: 生成时不包含表前缀,多个逗号隔开
#---------------------------------------------------------------------------------#
jboot.admin.serviceimpl.ge.modelpackage=io.jboot.quartz.service.entity.model
jboot.admin.serviceimpl.ge.servicepackage=io.jboot.quartz.service.api
jboot.admin.serviceimpl.ge.serviceimplpackage=io.jboot.quartz.service.provider
jboot.admin.serviceimpl.ge.removedtablenameprefixes=sys_
jboot.admin.serviceimpl.ge.excludedtable=
jboot.admin.serviceimpl.ge.excludedtableprefixes=temp_,v_

#---------------------------------------------------------------------------------#
#jboot的开发模式
jboot.mode=dev
jboot.bannerEnable=true
jboot.bannerFile=banner.txt
jboot.cron4jEnable=false
jboot.cron4jFile=cron4j.properties

#type default undertow (support:undertow)
jboot.server.type=undertow
jboot.server.host=
jboot.server.port=9102
jboot.server.contextPath=
#---------------------------------------------------------------------------------#

#---------------------------------------------------------------------------------#
#jboot.hystrix
jboot.hystrix.url=/hystrix.stream
jboot.hystrix.propertie
jboot.hystrix.closeAutoHystrix=false
#---------------------------------------------------------------------------------#

#---------------------------------------------------------------------------------#
#jboot.metrics
jboot.metric.url=/metric.html
jboot.metric.reporter=console
#---------------------------------------------------------------------------------#

#---------------------------------------------------------------------------------#
jboot.tracing.type=zipkin
jboot.tracing.serviceName=quartz-service
jboot.tracing.url=http://127.0.0.1:9411/api/v2/spans
#---------------------------------------------------------------------------------#

#---------------------------------------------------------------------------------#
jboot.datasource.type=mysql
jboot.datasource.url=jdbc:mysql://127.0.0.1:3306/jboot-admin?characterEncoding=utf8&useSSL=true
jboot.datasource.user=root
jboot.datasource.password=ming768
jboot.datasource.maximumPoolSize = 5
jboot.datasource.sqlTemplatePath=
jboot.datasource.sqlTemplate=
jboot.datasource.table=
jboot.datasource.excludeTable=
#---------------------------------------------------------------------------------#

#---------------------------------------------------------------------------------#
jboot.model.cacheEnable=true
#1小时 ,单位:秒
jboot.model.cacheTime=3600
jboot.model.scan
jboot.model.hystrixEnable=true
#1000 * 30; //单位:毫秒
jboot.model.hystrixTimeout=30000
#---------------------------------------------------------------------------------#

#---------------------------------------------------------------------------------#
#type default motan (support:local,motan,dubbo)
#use motan + consul
jboot.rpc.type = motan
jboot.rpc.registryType = consul
jboot.rpc.registryAddress = 127.0.0.1:8500

#use dubbo + zookeeper
#jboot.rpc.type = dubbo
#jboot.rpc.registryType = zookeeper
#jboot.rpc.registryAddress = 127.0.0.1:2181
#jboot.rpc.dubbo.qosPort = 33333;

jboot.rpc.requestTimeOut=5000
jboot.rpc.callMode=registry
jboot.rpc.registryName=register
jboot.rpc.registryUserName
jboot.rpc.registryPassword
#rpc service config
jboot.rpc.host=127.0.0.1
jboot.rpc.defaultPort=9112
jboot.rpc.defaultGroup=quartz-service
jboot.rpc.defaultVersion=1.0
jboot.rpc.proxy
jboot.rpc.hystrixKeys=
jboot.rpc.hystrixAutoConfig=true
jboot.rpc.hystrixFallbackFactory
jboot.rpc.serialization=fst
#---------------------------------------------------------------------------------#

#---------------------------------------------------------------------------------#
# cache config : type default ehcache (support:ehcache,redis,ehredis)
jboot.cache.type=redis
jboot.cache.redis.host=127.0.0.1
jboot.cache.redis.password=123456
jboot.cache.redis.database=0
#---------------------------------------------------------------------------------#

#---------------------------------------------------------------------------------#
# mq config : type default redis (support: redis,activemq,rabbitmq,hornetq,aliyunmq )
jboot.mq.type=redis
jboot.mq.redis.host=127.0.0.1
jboot.mq.redis.port=6379
jboot.mq.redis.password=123456
jboot.mq.redis.channel=message-channel
#---------------------------------------------------------------------------------#

#---------------------------------------------------------------------------------#
# redis config
jboot.redis.host=127.0.0.1
jboot.redis.password=123456
jboot.redis.database=0
#---------------------------------------------------------------------------------#

展开
收起
爱吃鱼的程序员 2020-06-06 16:16:53 650 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB
                        <p>这个并不是 “service内rpc调用其他service报错”,而是数据库没有对应的表。</p>
    
                    
    
                                回复 <a class="referer" target="_blank">@理工男海哥</a>  : 嗯 解决了,就是用jboot.datasource.table和jboot.datasource.excludeTable这两个参数来弄吧。有时间我去看看jboot源码,多谢
                        
    
                                回复 <a class="referer" target="_blank">@flydoy</a>  :  配置下这个看 jboot.datasource.excludeTable=
                        
    
                                回复 <a class="referer" target="_blank">@理工男海哥</a>  : 编译成jar包依赖也不行,海哥有没有啥解决方案
                        
    
                                回复 <a class="referer" target="_blank">@理工男海哥</a>  : 确实都有自己的jboot.properties.不知道为什么会出现这种情况。我想到的一个解决办法就是把其中一个编译成jar包,再引用。另一个就是把A服务的数据库链接与B服务区分开,按照多数据源的配置方式配置下
                        
    
                                回复 <a class="referer" target="_blank">@flydoy</a>  : B服务肯定不需要A服务的表的,可能是不是在编译的时候,两个服务共享一个jboot.properties配置文件了? 理论上每个服务都应该有自己的 jboot.properties 
    
    2020-06-06 16:17:05
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
《基于 Service Worker 实现在线代理》 立即下载
Data as a Service - 数据即服务 立即下载
CONTAINER SERVICE 立即下载