Hi all;
We are facing a severe blocker in APIM 4.2.0 based product..
When we publish an API from publisher to gateway following error[1] is
thrown and APIs are not deployed in tenant space.

*what we do is*

In the Admin service (RESTAPI admin) we set tenant domain explicitly and
creating  CarbonContext  using  getThreadLocalCarbonContext(). (Because
there is an issue at AbstarctAdmin service, where it creates CarbonContext
using  PrivilegedCarbonContext.getCurrentContext, and that always contains
SuperTenant domain in  it. This was discussed at the last release time and
as a solution  we overwrites that method from our end to use
PrivilegedCarbonContext.getThreadLocalCarbonContext() )

Our sample AdminService code is;

public boolean addApiForTenant(String apiData, String tenantDomain) throws
APIException {
try {
PrivilegedCarbonContext.startTenantFlow();
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenantDomain,
                                                                      true);
boolean status = addApiFromString(apiData);
return status;
} finally {
PrivilegedCarbonContext.endTenantFlow();
}
}

//overwriting this
protected ConfigurationContext getConfigContext() {
.....................................................................
PrivilegedCarbonContext carbonContext =
 PrivilegedCarbonContext.getThreadLocalCarbonContext();
String domain = carbonContext.getTenantDomain();
if (domain != null &&
!MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(domain)) {
System.out.println(" Tenant domain *********" +domain);
return TenantAxisUtils.getTenantConfigurationContext(domain,
mainConfigContext);
.....................................................
}

Can anyone point us, what we do wrong here?

Thanks..


[1]
2013-08-27 16:55:49,126]  INFO - CarbonAuthenticationUtil
'admin@carbon.super [-1234]' logged in at [2013-08-27 16:55:49,125+0530]
 Tenant domain *********test.com
[2013-08-27 16:55:49,152] ERROR - EventAxis2ConfigurationContextObserver
Error in setting tenant information
java.lang.NullPointerException: Tenant domain has not been set in
CarbonContext
        at
org.wso2.carbon.caching.impl.CacheManagerFactoryImpl.getCacheManager(CacheManagerFactoryImpl.java:79)
        at
org.wso2.carbon.user.core.authorization.PermissionTree.getPermissionTreeCache(PermissionTree.java:91)
        at
org.wso2.carbon.user.core.authorization.PermissionTree.updatePermissionTree(PermissionTree.java:905)
        at
org.wso2.carbon.user.core.authorization.JDBCAuthorizationManager.isRoleAuthorized(JDBCAuthorizationManager.java:117)
        at
org.wso2.carbon.event.core.internal.CarbonEventBroker.initializeTenant(CarbonEventBroker.java:97)
        at
org.wso2.carbon.event.core.internal.builder.EventAxis2ConfigurationContextObserver.creatingConfigurationContext(EventAxis2ConfigurationCont
extObserver.java:30)
        at
org.wso2.carbon.core.multitenancy.utils.TenantAxisUtils.doPreConfigContextCreation(TenantAxisUtils.java:507)
        at
org.wso2.carbon.core.multitenancy.utils.TenantAxisUtils.createTenantConfigurationContext(TenantAxisUtils.java:302)
        at
org.wso2.carbon.core.multitenancy.utils.TenantAxisUtils.getTenantConfigurationContext(TenantAxisUtils.java:135)
        at
org.wso2.carbon.rest.api.service.RestApiAdmin.getConfigContext(RestApiAdmin.java:750)
        at
org.wso2.carbon.rest.api.service.RestApiAdmin.getAxisConfig(RestApiAdmin.java:731)
        at
org.wso2.carbon.rest.api.service.RestApiAdmin.getLock(RestApiAdmin.java:713)
        at
org.wso2.carbon.rest.api.service.RestApiAdmin.getApiByName(RestApiAdmin.java:417)
        at
org.wso2.carbon.rest.api.service.RestApiAdmin.getApiForTenant(RestApiAdmin.java:445)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at
org.apache.axis2.rpc.receivers.RPCUtil.invokeServiceClass(RPCUtil.java:212)
        at
org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(RPCMessageReceiver.java:117)
        at
org.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusinessLogic(AbstractInOutMessageReceiver.java:40)
        at
org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:110)
        at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
        at
org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:172)
        at
org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:146)
        at
org.wso2.carbon.core.transports.CarbonServlet.doPost(CarbonServlet.java:231)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:755)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
        at
org.eclipse.equinox.http.servlet.internal.ServletRegistration.service(ServletRegistration.java:61)
        at
org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:128)
        at
org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:68)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
        at
org.wso2.carbon.tomcat.ext.servlet.DelegationServlet.service(DelegationServlet.java:68)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at
org.wso2.carbon.tomcat.ext.filter.CharacterSetFilter.doFilter(CharacterSetFilter.java:61)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
        at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
        at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
        at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
        at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
        at
org.wso2.carbon.tomcat.ext.valves.CompositeValve.continueInvocation(CompositeValve.java:178)
        at
org.wso2.carbon.tomcat.ext.valves.CarbonTomcatValve$1.invoke(CarbonTomcatValve.java:47)
        at
org.wso2.carbon.webapp.mgt.TenantLazyLoaderValve.invoke(TenantLazyLoaderValve.java:56)
        at
org.wso2.carbon.tomcat.ext.valves.TomcatValveContainer.invokeValves(TomcatValveContainer.java:47)
        at
org.wso2.carbon.tomcat.ext.valves.CompositeValve.invoke(CompositeValve.java:141)
        at
org.wso2.carbon.tomcat.ext.valves.CarbonStuckThreadDetectionValve.invoke(CarbonStuckThreadDetectionValve.java:156)
        at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
        at
org.wso2.carbon.tomcat.ext.valves.CarbonContextCreatorValve.invoke(CarbonContextCreatorValve.java:52)
        at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
        at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
        at
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
        at
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
        at
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1653)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
        at java.lang.Thread.run(Thread.java:662)
[2013-08-27 16:55:49,168]  INFO - TenantAxisConfigurator Creating tenant
AxisConfiguration for tenant: test.com[1]
[2013-08-27 16:55:49,458]  INFO - UserStoreConfigurationDeployer User Store
Configuration Deployer initiated.
[2013-08-27 16:55:50,236]  INFO - TenantServiceBusInitializer Intializing
the ESB Configuration for the tenant domain : test.com
[2013-08-27 16:55:50,239]  INFO - SynapseControllerFactory Using Synapse
home : C:\Users\TOSH\Desktop\WSO2AM~1.0\bin\..\repository\tenants\1
[2013-08-27 16:55:50,240]  INFO - SynapseControllerFactory Using
synapse.xml location :
C:\Users\TOSH\Desktop\WSO2AM~1.0\bin\..\repository\tenants\1\s
ynapse-configs\default
[2013-08-27 16:55:50,241]  INFO - SynapseControllerFactory Using server
name : synapse.test.com
[2013-08-27 16:55:50,244]  INFO - SynapseControllerFactory The timeout
handler will run every : 15s
[2013-08-27 16:55:50,247]  INFO - Axis2SynapseController Initializing
Synapse at : Tue Aug 27 16:55:50 IST 2013
[2013-08-27 16:55:50,255]  INFO - CarbonSynapseController Loading the
mediation configuration from the file system
[2013-08-27 16:55:50,257]  INFO - MultiXMLConfigurationBuilder Building
synapse configuration from the synapse artifact repository at :
C:\Users\TOSH\
Desktop\WSO2AM~1.0\bin\..\repository\tenants\1\synapse-configs\default
[2013-08-27 16:55:50,283]  INFO - SynapseConfigurationBuilder Loaded
Synapse configuration from the artifact repository at :
C:\Users\TOSH\Desktop\WSO
2AM~1.0\bin\..\repository\tenants\1\synapse-configs\default
[2013-08-27 16:55:50,284]  INFO - Axis2SynapseController Loading mediator
extensions...
[2013-08-27 16:55:50,290]  INFO - Axis2SynapseController Deploying the
Synapse service...
[2013-08-27 16:55:50,291]  INFO - Axis2SynapseController Deploying Proxy
services...
[2013-08-27 16:55:50,292]  INFO - Axis2SynapseController Deploying
EventSources...
[2013-08-27 16:55:50,295]  INFO - ServerManager Server ready for
processing...
[2013-08-27 16:55:50,343]  WARN - MediationStatisticsServiceComponent
Couldn't find the mediation statistics store for tenant id: 1
[2013-08-27 16:55:50,382]  INFO - PermissionUpdater Permission cache
updated for tenant 1
[2013-08-27 16:55:50,384] ERROR - TenantAxisUtils Error occurred while
running deployment for tenant test.com
java.lang.NullPointerException: Tenant domain has not been set in
CarbonContext
        at
org.wso2.carbon.caching.impl.CacheManagerFactoryImpl.getCacheManager(CacheManagerFactoryImpl.java:79)
        at
org.wso2.carbon.registry.core.utils.RegistryUtils.getCacheManager(RegistryUtils.java:288)
        at
org.wso2.carbon.registry.core.utils.RegistryUtils.getResourceCache(RegistryUtils.java:271)
        at
org.wso2.carbon.registry.core.caching.CacheBackedRegistry.getCache(CacheBackedRegistry.java:62)
        at
org.wso2.carbon.registry.core.caching.CacheBackedRegistry.resourceExists(CacheBackedRegistry.java:246)
        at
org.wso2.carbon.registry.core.session.UserRegistry.resourceExists(UserRegistry.java:629)
        at
org.wso2.carbon.datasource.DataSourceInformationManager.populateDataSourceInformation(DataSourceInformationManager.java:62)
        at
org.wso2.carbon.datasource.multitenancy.DataSourceInitializer.createdConfigurationContext(DataSourceInitializer.java:73)
        at
org.wso2.carbon.core.multitenancy.utils.TenantAxisUtils.createTenantConfigurationContext(TenantAxisUtils.java:342)
        at
org.wso2.carbon.core.multitenancy.utils.TenantAxisUtils.getTenantConfigurationContext(TenantAxisUtils.java:135)
        at
org.wso2.carbon.rest.api.service.RestApiAdmin.getConfigContext(RestApiAdmin.java:750)
        at
org.wso2.carbon.rest.api.service.RestApiAdmin.getAxisConfig(RestApiAdmin.java:731)
        at
org.wso2.carbon.rest.api.service.RestApiAdmin.getLock(RestApiAdmin.java:713)
        at org.wso2.carbo

-- 
-Ratha
mobile: (+94)755906608
_______________________________________________
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to