我正在尝试删除使用TenantMgtAdminServiceStub创建的租户。在碳日志中,它显示以下内容:
TID: [-1234] [] [2016-04-07 23:52:10,645] INFO {org.wso2.carbon.core.services.util.CarbonAuthenticationUtil} - 'admin@carbon.super [-1234]' logged in at [2016-04-07 23:52:10,645-0500] {org.wso2.carbon.core.services.util.CarbonAuthenticationUtil}
TID: [-1234] [] [2016-04-07 23:52:10,784] INFO {org.wso2.carbon.core.services.util.CarbonAuthenticationUtil} - 'admin@carbon.super [-1234]' logged in at [2016-04-07 23:52:10,784-0500] {org.wso2.carbon.core.services.util.CarbonAuthenticationUtil}
TID: [-1234] [] [2016-04-07 23:52:10,866] INFO {org.wso2.carbon.tenant.mgt.services.TenantMgtAdminService} - Starting Tenant Deletion process... {org.wso2.carbon.tenant.mgt.services.TenantMgtAdminService}
TID: [-1234] [] [2016-04-07 23:52:11,150] ERROR {org.wso2.carbon.tenant.mgt.services.TenantMgtAdminService} - Error in notifying tenant addition. {org.wso2.carbon.tenant.mgt.services.TenantMgtAdminService}
org.wso2.carbon.stratos.common.exception.StratosException: Error occurred while revoking the access tokens in tenant 10
at org.wso2.carbon.identity.oauth2.internal.OAuthTenantMgtListenerImpl.onPreDelete(OAuthTenantMgtListenerImpl.java:121)
at org.wso2.carbon.tenant.mgt.util.TenantMgtUtil.triggerPreTenantDelete(TenantMgtUtil.java:118)
at org.wso2.carbon.tenant.mgt.services.TenantMgtAdminService.notifyTenantDeletion(TenantMgtAdminService.java:123)
at org.wso2.carbon.tenant.mgt.services.TenantMgtAdminService.deleteTenant(TenantMgtAdminService.java:557)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
...
Caused by: org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception: Error occurred while retrieving 'ACTIVE or EXPIRED' access tokens for user tenant id : 10
at org.wso2.carbon.identity.oauth2.dao.TokenMgtDAO.getAccessTokensOfTenant(TokenMgtDAO.java:1192)
at org.wso2.carbon.identity.oauth2.internal.OAuthTenantMgtListenerImpl.onPreDelete(OAuthTenantMgtListenerImpl.java:87)
... 59 more
Caused by: org.h2.jdbc.JdbcSQLException: Ambiguous column name "USER_DOMAIN"; SQL statement:
SELECT ACCESS_TOKEN, REFRESH_TOKEN, TIME_CREATED, REFRESH_TOKEN_TIME_CREATED, VALIDITY_PERIOD, REFRESH_TOKEN_VALIDITY_PERIOD, USER_TYPE, TOKEN_SCOPE, ACCESS_TOKEN_TABLE.TOKEN_ID, AUTHZ_USER, USER_DOMAIN, CONSUMER_KEY FROM (SELECT AUTHZ_USER, USER_DOMAIN, CONSUMER_KEY_ID, TOKEN_ID, ACCESS_TOKEN, REFRESH_TOKEN, TIME_CREATED, REFRESH_TOKEN_TIME_CREATED, VALIDITY_PERIOD, REFRESH_TOKEN_VALIDITY_PERIOD, USER_TYPE FROM IDN_OAUTH2_ACCESS_TOKEN WHERE TENANT_ID=? AND (TOKEN_STATE='ACTIVE' OR TOKEN_STATE='EXPIRED')) ACCESS_TOKEN_TABLE JOIN IDN_OAUTH_CONSUMER_APPS ON ID = CONSUMER_KEY_ID LEFT JOIN IDN_OAUTH2_ACCESS_TOKEN_SCOPE ON ACCESS_TOKEN_TABLE.TOKEN_ID = IDN_OAUTH2_ACCESS_TOKEN_SCOPE.TOKEN_ID [90059-140]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:327)
at org.h2.message.DbException.get(DbException.java:167)
at org.h2.message.DbException.get(DbException.java:144)
at org.h2.expression.ExpressionColumn.mapColumn(ExpressionColumn.java:105)
at org.h2.expression.ExpressionColumn.mapColumns(ExpressionColumn.java:82)
at org.h2.command.dml.Select.init(Select.java:710)
at org.h2.command.Parser.parseSelect(Parser.java:1410)
at org.h2.command.Parser.parsePrepared(Parser.java:392)
...
at org.apache.tomcat.jdbc.pool.JdbcInterceptor.invoke(JdbcInterceptor.java:109)
at org.apache.tomcat.jdbc.pool.DisposableConnectionFacade.invoke(DisposableConnectionFacade.java:80)
at com.sun.proxy.$Proxy12.prepareStatement(Unknown Source)
at org.wso2.carbon.identity.oauth2.dao.TokenMgtDAO.getAccessTokensOfTenant(TokenMgtDAO.java:1149)
... 60 more
TID: [-1234] [] [2016-04-07 23:52:11,159] ERROR {org.wso2.carbon.tenant.mgt.services.TenantMgtAdminService} - Error deleting tenant with domain: juan7.com and tenant id: 10. {org.wso2.carbon.tenant.mgt.services.TenantMgtAdminService}
java.lang.Exception: Error in notifying tenant addition.
at org.wso2.carbon.tenant.mgt.services.TenantMgtAdminService.notifyTenantDeletion(TenantMgtAdminService.java:127)
at org.wso2.carbon.tenant.mgt.services.TenantMgtAdminService.deleteTenant(TenantMgtAdminService.java:557)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
...
Caused by: org.wso2.carbon.stratos.common.exception.StratosException: Error occurred while revoking the access tokens in tenant 10
at org.wso2.carbon.identity.oauth2.internal.OAuthTenantMgtListenerImpl.onPreDelete(OAuthTenantMgtListenerImpl.java:121)
at org.wso2.carbon.tenant.mgt.util.TenantMgtUtil.triggerPreTenantDelete(TenantMgtUtil.java:118)
at org.wso2.carbon.tenant.mgt.services.TenantMgtAdminService.notifyTenantDeletion(TenantMgtAdminService.java:123)
... 57 more
Caused by: org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception: Error occurred while retrieving 'ACTIVE or EXPIRED' access tokens for user tenant id : 10
at org.wso2.carbon.identity.oauth2.dao.TokenMgtDAO.getAccessTokensOfTenant(TokenMgtDAO.java:1192)
at org.wso2.carbon.identity.oauth2.internal.OAuthTenantMgtListenerImpl.onPreDelete(OAuthTenantMgtListenerImpl.java:87)
... 59 more
Caused by: org.h2.jdbc.JdbcSQLException: Ambiguous column name "USER_DOMAIN"; SQL statement:
SELECT ACCESS_TOKEN, REFRESH_TOKEN, TIME_CREATED, REFRESH_TOKEN_TIME_CREATED, VALIDITY_PERIOD, REFRESH_TOKEN_VALIDITY_PERIOD, USER_TYPE, TOKEN_SCOPE, ACCESS_TOKEN_TABLE.TOKEN_ID, AUTHZ_USER, USER_DOMAIN, CONSUMER_KEY FROM (SELECT AUTHZ_USER, USER_DOMAIN, CONSUMER_KEY_ID, TOKEN_ID, ACCESS_TOKEN, REFRESH_TOKEN, TIME_CREATED, REFRESH_TOKEN_TIME_CREATED, VALIDITY_PERIOD, REFRESH_TOKEN_VALIDITY_PERIOD, USER_TYPE FROM IDN_OAUTH2_ACCESS_TOKEN WHERE TENANT_ID=? AND (TOKEN_STATE='ACTIVE' OR TOKEN_STATE='EXPIRED')) ACCESS_TOKEN_TABLE JOIN IDN_OAUTH_CONSUMER_APPS ON ID = CONSUMER_KEY_ID LEFT JOIN IDN_OAUTH2_ACCESS_TOKEN_SCOPE ON ACCESS_TOKEN_TABLE.TOKEN_ID = IDN_OAUTH2_ACCESS_TOKEN_SCOPE.TOKEN_ID [90059-140]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:327)
at org.h2.message.DbException.get(DbException.java:167)
at org.h2.message.DbException.get(DbException.java:144)
at org.h2.expression.ExpressionColumn.mapColumn(ExpressionColumn.java:105)
at org.h2.expression.ExpressionColumn.mapColumns(ExpressionColumn.java:82)
at org.h2.command.dml.Select.init(Select.java:710)
at org.h2.command.Parser.parseSelect(Parser.java:1410)
at org.h2.command.Parser.parsePrepared(Parser.java:392)
...
at org.wso2.carbon.identity.oauth2.dao.TokenMgtDAO.getAccessTokensOfTenant(TokenMgtDAO.java:1149)
... 60 more
我用来删除租户的代码非常简单:
String cookie = getCookie();
TenantMgtAdminServiceStub tenantMgtStub = null;
String tenantMgtEndpoint = apiManagerConfiguration.getCarbonUrl() + "TenantMgtAdminService";
tenantMgtStub = new TenantMgtAdminServiceStub(tenantMgtEndpoint);
Options option = tenantMgtStub._getServiceClient().getOptions();
option.setManageSession(true);
option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie);
tenantMgtStub.deleteTenant(domain);
任何帮助将不胜感激。
答案 0 :(得分:0)
首先,您需要停用租户,然后删除租户
tenantMgtStub.deactivateTenant(domainName);
tenantMgtStub.deleteTenant(domainName);
希望这会有所帮助