欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

WSO2 API Manager 替换mysql作为数据库,解决AuthorizationUtils Could not set authorizations for the root问题

程序员文章站 2022-09-04 16:47:04
按照wso2官网(https://docs.wso2.com/display/ADMIN44x/Changing+to+MySQL)配置AM的数据库,想从H2换成Mysql5.7,费了将近一天的时间,老是报错,提示AuthorizationUtils Could not set authorizat ......

按照wso2官网(https://docs.wso2.com/display/admin44x/changing+to+mysql)配置am的数据库,想从h2换成mysql5.7,费了将近一天的时间,老是报错,提示authorizationutils could not set authorizations for the root,报错如下:

caused by: com.mysql.cj.exceptions.cjcommunicationsexception: communications link failure
the last packet sent successfully to the server was 0 milliseconds ago. the driver has not received any packets from the server.
        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.cj.exceptions.exceptionfactory.createexception(exceptionfactory.java:61)
        at com.mysql.cj.exceptions.exceptionfactory.createexception(exceptionfactory.java:105)
        at com.mysql.cj.exceptions.exceptionfactory.createexception(exceptionfactory.java:151)
        at com.mysql.cj.exceptions.exceptionfactory.createcommunicationsexception(exceptionfactory.java:167)
        at com.mysql.cj.protocol.a.nativeprotocol.negotiatesslconnection(nativeprotocol.java:361)
        at com.mysql.cj.protocol.a.nativeauthenticationprovider.negotiatesslconnection(nativeauthenticationprovider.java:777)
        at com.mysql.cj.protocol.a.nativeauthenticationprovider.proceedhandshakewithpluggableauthentication(nativeauthenticationprovider.java:486)
        at com.mysql.cj.protocol.a.nativeauthenticationprovider.connect(nativeauthenticationprovider.java:202)
        at com.mysql.cj.protocol.a.nativeprotocol.connect(nativeprotocol.java:1449)
        at com.mysql.cj.nativesession.connect(nativesession.java:165)
        at com.mysql.cj.jdbc.connectionimpl.connectwithretries(connectionimpl.java:849)
        ... 76 more
caused by: java.net.socketexception: broken pipe (write failed)
        at java.net.socketoutputstream.socketwrite0(native method)
        at java.net.socketoutputstream.socketwrite(socketoutputstream.java:111)
        at java.net.socketoutputstream.write(socketoutputstream.java:155)
        at sun.security.ssl.outputrecord.writebuffer(outputrecord.java:431)
        at sun.security.ssl.outputrecord.write(outputrecord.java:417)
        at sun.security.ssl.sslsocketimpl.writerecordinternal(sslsocketimpl.java:879)
        at sun.security.ssl.sslsocketimpl.writerecord(sslsocketimpl.java:850)
        at sun.security.ssl.sslsocketimpl.writerecord(sslsocketimpl.java:720)
        at sun.security.ssl.handshaker.sendchangecipherspec(handshaker.java:1144)
        at sun.security.ssl.clienthandshaker.sendchangecipherandfinish(clienthandshaker.java:1280)
        at sun.security.ssl.clienthandshaker.serverhellodone(clienthandshaker.java:1190)
        at sun.security.ssl.clienthandshaker.processmessage(clienthandshaker.java:369)
        at sun.security.ssl.handshaker.processloop(handshaker.java:1037)
        at sun.security.ssl.handshaker.process_record(handshaker.java:965)
        at sun.security.ssl.sslsocketimpl.readrecord(sslsocketimpl.java:1064)
        at sun.security.ssl.sslsocketimpl.performinitialhandshake(sslsocketimpl.java:1367)
        at sun.security.ssl.sslsocketimpl.starthandshake(sslsocketimpl.java:1395)
        at sun.security.ssl.sslsocketimpl.starthandshake(sslsocketimpl.java:1379)
        at com.mysql.cj.protocol.exportcontrolled.performtlshandshake(exportcontrolled.java:315)
        at com.mysql.cj.protocol.standardsocketfactory.performtlshandshake(standardsocketfactory.java:188)
        at com.mysql.cj.protocol.a.nativesocketconnection.performtlshandshake(nativesocketconnection.java:99)
        at com.mysql.cj.protocol.a.nativeprotocol.negotiatesslconnection(nativeprotocol.java:352)
        ... 82 more
[2019-01-25 17:06:25,484] fatal - userregistry failed to add the root collection to the coreregistry.
org.wso2.carbon.registry.core.exceptions.registryexception: could not set authorizations for the root.
caused by: error! could not create connection to database server. attempted reconnect 3 times. giving up.
        at org.wso2.carbon.registry.core.utils.authorizationutils.setrootauthorizations(authorizationutils.java:302)
        at org.wso2.carbon.registry.core.session.userregistry.addrootcollection(userregistry.java:404)
        at org.wso2.carbon.registry.core.session.userregistry.init(userregistry.java:328)
        at org.wso2.carbon.registry.core.session.userregistry.access$100(userregistry.java:61)
        at org.wso2.carbon.registry.core.session.userregistry$2.run(userregistry.java:249)
        at java.security.accesscontroller.doprivileged(native method)
        at org.wso2.carbon.registry.core.session.userregistry.<init>(userregistry.java:246)
        at org.wso2.carbon.registry.core.session.userregistry.<init>(userregistry.java:225)
        at org.wso2.carbon.registry.core.jdbc.embeddedregistryservice.getuserregistry(embeddedregistryservice.java:427)
        at org.wso2.carbon.registry.core.jdbc.embeddedregistryservice.getsystemregistry(embeddedregistryservice.java:292)
        at org.wso2.carbon.registry.core.jdbc.embeddedregistryservice.getsystemregistry(embeddedregistryservice.java:276)
        at org.wso2.carbon.registry.core.jdbc.embeddedregistryservice.getsystemregistry(embeddedregistryservice.java:262)
        at org.wso2.carbon.registry.core.jdbc.embeddedregistryservice.configure(embeddedregistryservice.java:219)
        at org.wso2.carbon.registry.core.jdbc.embeddedregistryservice.<init>(embeddedregistryservice.java:99)
        at org.wso2.carbon.registry.core.internal.registrycoreservicecomponent.getembeddedregistryservice(registrycoreservicecomponent.java:604)
        at org.wso2.carbon.registry.core.internal.registrycoreservicecomponent.buildregistryservice(registrycoreservicecomponent.java:526)
        at org.wso2.carbon.registry.core.internal.registrycoreservicecomponent.activate(registrycoreservicecomponent.java:130)
        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.eclipse.equinox.internal.ds.model.servicecomponent.activate(servicecomponent.java:260)
        at org.eclipse.equinox.internal.ds.model.servicecomponentprop.activate(servicecomponentprop.java:146)
        at org.eclipse.equinox.internal.ds.model.servicecomponentprop.build(servicecomponentprop.java:345)
        at org.eclipse.equinox.internal.ds.instanceprocess.buildcomponent(instanceprocess.java:620)
        at org.eclipse.equinox.internal.ds.instanceprocess.buildcomponents(instanceprocess.java:197)
        at org.eclipse.equinox.internal.ds.resolver.geteligible(resolver.java:343)
        at org.eclipse.equinox.internal.ds.scrmanager.servicechanged(scrmanager.java:222)
        at org.eclipse.osgi.internal.serviceregistry.filteredservicelistener.servicechanged(filteredservicelistener.java:107)
        at org.eclipse.osgi.framework.internal.core.bundlecontextimpl.dispatchevent(bundlecontextimpl.java:861)
        at org.eclipse.osgi.framework.eventmgr.eventmanager.dispatchevent(eventmanager.java:230)
        at org.eclipse.osgi.framework.eventmgr.listenerqueue.dispatcheventsynchronous(listenerqueue.java:148)
        at org.eclipse.osgi.internal.serviceregistry.serviceregistry.publishserviceeventprivileged(serviceregistry.java:819)
        at org.eclipse.osgi.internal.serviceregistry.serviceregistry.publishserviceevent(serviceregistry.java:771)
        at org.eclipse.osgi.internal.serviceregistry.serviceregistrationimpl.register(serviceregistrationimpl.java:130)
        at org.eclipse.osgi.internal.serviceregistry.serviceregistry.registerservice(serviceregistry.java:214)
        at org.eclipse.osgi.framework.internal.core.bundlecontextimpl.registerservice(bundlecontextimpl.java:433)
        at org.wso2.carbon.user.core.internal.activator.startdeploy(activator.java:73)
        at org.wso2.carbon.user.core.internal.bundlecheckactivator.start(bundlecheckactivator.java:61)
        at org.eclipse.osgi.framework.internal.core.bundlecontextimpl$1.run(bundlecontextimpl.java:711)
        at java.security.accesscontroller.doprivileged(native method)
        at org.eclipse.osgi.framework.internal.core.bundlecontextimpl.startactivator(bundlecontextimpl.java:702)
        at org.eclipse.osgi.framework.internal.core.bundlecontextimpl.start(bundlecontextimpl.java:683)
        at org.eclipse.osgi.framework.internal.core.bundlehost.startworker(bundlehost.java:381)
        at org.eclipse.osgi.framework.internal.core.abstractbundle.resume(abstractbundle.java:390)
        at org.eclipse.osgi.framework.internal.core.framework.resumebundle(framework.java:1176)
        at org.eclipse.osgi.framework.internal.core.startlevelmanager.resumebundles(startlevelmanager.java:559)
        at org.eclipse.osgi.framework.internal.core.startlevelmanager.resumebundles(startlevelmanager.java:544)
        at org.eclipse.osgi.framework.internal.core.startlevelmanager.incfwsl(startlevelmanager.java:457)
        at org.eclipse.osgi.framework.internal.core.startlevelmanager.dosetstartlevel(startlevelmanager.java:243)
        at org.eclipse.osgi.framework.internal.core.startlevelmanager.dispatchevent(startlevelmanager.java:438)
        at org.eclipse.osgi.framework.internal.core.startlevelmanager.dispatchevent(startlevelmanager.java:1)
        at org.eclipse.osgi.framework.eventmgr.eventmanager.dispatchevent(eventmanager.java:230)
        at org.eclipse.osgi.framework.eventmgr.eventmanager$eventthread.run(eventmanager.java:340)
[2019-01-25 17:06:25,529] error - registrycoreservicecomponent failed to activate registry core bundle
org.wso2.carbon.registry.core.exceptions.registryexception: failed to add the root collection to the coreregistry.
        at org.wso2.carbon.registry.core.session.userregistry.addrootcollection(userregistry.java:443)
        at org.wso2.carbon.registry.core.session.userregistry.init(userregistry.java:328)
        at org.wso2.carbon.registry.core.session.userregistry.access$100(userregistry.java:61)
        at org.wso2.carbon.registry.core.session.userregistry$2.run(userregistry.java:249)
        at java.security.accesscontroller.doprivileged(native method)
        at org.wso2.carbon.registry.core.session.userregistry.<init>(userregistry.java:246)
        at org.wso2.carbon.registry.core.session.userregistry.<init>(userregistry.java:225)
        at org.wso2.carbon.registry.core.jdbc.embeddedregistryservice.getuserregistry(embeddedregistryservice.java:427)
        at org.wso2.carbon.registry.core.jdbc.embeddedregistryservice.getsystemregistry(embeddedregistryservice.java:292)
        at org.wso2.carbon.registry.core.jdbc.embeddedregistryservice.getsystemregistry(embeddedregistryservice.java:276)
        at org.wso2.carbon.registry.core.jdbc.embeddedregistryservice.getsystemregistry(embeddedregistryservice.java:262)
        at org.wso2.carbon.registry.core.jdbc.embeddedregistryservice.configure(embeddedregistryservice.java:219)
        at org.wso2.carbon.registry.core.jdbc.embeddedregistryservice.<init>(embeddedregistryservice.java:99)
        at org.wso2.carbon.registry.core.internal.registrycoreservicecomponent.getembeddedregistryservice(registrycoreservicecomponent.java:604)
        at org.wso2.carbon.registry.core.internal.registrycoreservicecomponent.buildregistryservice(registrycoreservicecomponent.java:526)
        at org.wso2.carbon.registry.core.internal.registrycoreservicecomponent.activate(registrycoreservicecomponent.java:130)
        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.eclipse.equinox.internal.ds.model.servicecomponent.activate(servicecomponent.java:260)
        at org.eclipse.equinox.internal.ds.model.servicecomponentprop.activate(servicecomponentprop.java:146)
        at org.eclipse.equinox.internal.ds.model.servicecomponentprop.build(servicecomponentprop.java:345)
        at org.eclipse.equinox.internal.ds.instanceprocess.buildcomponent(instanceprocess.java:620)
        at org.eclipse.equinox.internal.ds.instanceprocess.buildcomponents(instanceprocess.java:197)
        at org.eclipse.equinox.internal.ds.resolver.geteligible(resolver.java:343)
        at org.eclipse.equinox.internal.ds.scrmanager.servicechanged(scrmanager.java:222)
        at org.eclipse.osgi.internal.serviceregistry.filteredservicelistener.servicechanged(filteredservicelistener.java:107)
        at org.eclipse.osgi.framework.internal.core.bundlecontextimpl.dispatchevent(bundlecontextimpl.java:861)
        at org.eclipse.osgi.framework.eventmgr.eventmanager.dispatchevent(eventmanager.java:230)
        at org.eclipse.osgi.framework.eventmgr.listenerqueue.dispatcheventsynchronous(listenerqueue.java:148)
        at org.eclipse.osgi.internal.serviceregistry.serviceregistry.publishserviceeventprivileged(serviceregistry.java:819)
        at org.eclipse.osgi.internal.serviceregistry.serviceregistry.publishserviceevent(serviceregistry.java:771)
        at org.eclipse.osgi.internal.serviceregistry.serviceregistrationimpl.register(serviceregistrationimpl.java:130)
        at org.eclipse.osgi.internal.serviceregistry.serviceregistry.registerservice(serviceregistry.java:214)
        at org.eclipse.osgi.framework.internal.core.bundlecontextimpl.registerservice(bundlecontextimpl.java:433)
        at org.wso2.carbon.user.core.internal.activator.startdeploy(activator.java:73)
        at org.wso2.carbon.user.core.internal.bundlecheckactivator.start(bundlecheckactivator.java:61)
        at org.eclipse.osgi.framework.internal.core.bundlecontextimpl$1.run(bundlecontextimpl.java:711)
        at java.security.accesscontroller.doprivileged(native method)
        at org.eclipse.osgi.framework.internal.core.bundlecontextimpl.startactivator(bundlecontextimpl.java:702)
        at org.eclipse.osgi.framework.internal.core.bundlecontextimpl.start(bundlecontextimpl.java:683)
        at org.eclipse.osgi.framework.internal.core.bundlehost.startworker(bundlehost.java:381)
        at org.eclipse.osgi.framework.internal.core.abstractbundle.resume(abstractbundle.java:390)
        at org.eclipse.osgi.framework.internal.core.framework.resumebundle(framework.java:1176)
        at org.eclipse.osgi.framework.internal.core.startlevelmanager.resumebundles(startlevelmanager.java:559)
        at org.eclipse.osgi.framework.internal.core.startlevelmanager.resumebundles(startlevelmanager.java:544)
        at org.eclipse.osgi.framework.internal.core.startlevelmanager.incfwsl(startlevelmanager.java:457)
        at org.eclipse.osgi.framework.internal.core.startlevelmanager.dosetstartlevel(startlevelmanager.java:243)
        at org.eclipse.osgi.framework.internal.core.startlevelmanager.dispatchevent(startlevelmanager.java:438)
        at org.eclipse.osgi.framework.internal.core.startlevelmanager.dispatchevent(startlevelmanager.java:1)
        at org.eclipse.osgi.framework.eventmgr.eventmanager.dispatchevent(eventmanager.java:230)
        at org.eclipse.osgi.framework.eventmgr.eventmanager$eventthread.run(eventmanager.java:340)
caused by: org.wso2.carbon.registry.core.exceptions.registryexception: could not set authorizations for the root.
caused by: error! could not create connection to database server. attempted reconnect 3 times. giving up.
        at org.wso2.carbon.registry.core.utils.authorizationutils.setrootauthorizations(authorizationutils.java:302)
        at org.wso2.carbon.registry.core.session.userregistry.addrootcollection(userregistry.java:404)
        ... 52 more
 
一开始以为是wos2关于root的权限认证问题,百度了半天,解决不了,然后google,也没找到相应的手段,换mysql用户,换连接ip都不行,后来偶然发现lls问题,终于解决!
废话不多,直接说解决方式:
mysql为5.7版本,默认ssl为true,需要关闭ssl
将连接配置修改如下
 <url>jdbc:mysql://localhost:3306/regdb?useunicode=true&amp;characterencoding=utf8&amp;autoreconnect=true&amp;usessl=false</url>