Hi Ramith, Nihanth, Root cause for this problem is, CarbonContextCreatorValve identify your request as a tenant request, because requestURI contains "/t/". Things become more complicated because it contains "/t/<tenant_domain>" too. When your request is coming through CarbonContextCreatorValve it sets the current tenantId according to the tenant domain you are sending. Then your webapp will be treated as a tenant webapp of that particular tenant so that your datasource will not be available for the web app.
As a simple solution you can change your webapp's relative context to something other than "/t" (change the jaxrs server address in cxf-servlet.xml). @Sameera,Azeez, Anyway IMO it's better to modify the logic inside CarbonContextCreatorValve. If not it will create more complications and security issues when the URL having "/t" Thanks. On Thu, Aug 29, 2013 at 10:48 AM, Afkham Azeez <az...@wso2.com> wrote: > One thing you should do is, use the ThreadLocal CC. Don't use the > getCurrentContext method. You should also ensure that the correct tenant CC > is set as the ThreadLocal. > > > On Thu, Aug 29, 2013 at 10:31 AM, Ramith Jayasinghe <ram...@wso2.com>wrote: > >> I came across this error in AS 5.1.0 as well. >> What happens is, In this (web) application we do this from super tenant >> space: >> >> UserRealmService realmService = >> (UserRealmService) >> PrivilegedCarbonContext.getCurrentContext() >> >> .getOSGiService(UserRealmService.class); >> >> int tenantId = >> realmService.getTenantManager().getTenantId(tenantDomain); >> >> >> Now some where down the line we do this: >> >> Context initCtx = new InitialContext(); >> (DataSource) initCtx.lookup(dataSourceName); >> >> Which throws an error. >> Reason is somehow datasource is being search in the tenant space (which >> we got the tenant ID) instead of super tenant. >> >> I think this is a critical bug. >> >> >> >> >> >> On Thu, Aug 29, 2013 at 6:43 AM, Nihanth Joseph <niha...@wso2.com> wrote: >> >>> Hi, >>> I am getting following exception after the tenant is created. BD >>> credential is configured in supertenant. >>> After tenant created db lookup is happening in tenant space, due to >>> that it fails. >>> >>> >>> >>> [2013-08-28 21:34:30,461] ERROR {org.wso2.carbon.issue.tracker.server. >>> impl.IssueServiceImpl} - Error while get comments for issue >>> java.lang.RuntimeException: Error in looking up data source: Name >>> [jdbc/IssueTrackerDB] >>> is not bound in this Context. Unable to find [jdbc]. >>> at org.wso2.carbon.issue.tracker.util.DBConfiguration.lookupDataSource( >>> DBConfiguration.java:57) >>> at org.wso2.carbon.issue.tracker.util.DBConfiguration.Initialize( >>> DBConfiguration.java:39) >>> at org.wso2.carbon.issue.tracker.util.DBConfiguration.getDBConnection( >>> DBConfiguration.java:70) >>> at org.wso2.carbon.issue.tracker.dao.impl.IssueDAOImpl.getIssueByKey( >>> IssueDAOImpl.java:177) >>> at org.wso2.carbon.issue.tracker.server.impl.IssueServiceImpl.getIssue( >>> IssueServiceImpl.java:61) >>> 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.cxf.service.invoker.AbstractInvoker.performInvocation( >>> AbstractInvoker.java:180) >>> at org.apache.cxf.service.invoker.AbstractInvoker.invoke( >>> AbstractInvoker.java:96) >>> at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:194) >>> at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:100) >>> at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run( >>> ServiceInvokerInterceptor.java:57) >>> at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage( >>> ServiceInvokerInterceptor.java:93) >>> at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept( >>> PhaseInterceptorChain.java:271) >>> at org.apache.cxf.transport.ChainInitiationObserver.onMessage( >>> ChainInitiationObserver.java:121) >>> at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke( >>> AbstractHTTPDestination.java:239) >>> at org.apache.cxf.transport.servlet.ServletController.invokeDestination >>> (ServletController.java:223) >>> at org.apache.cxf.transport.servlet.ServletController.invoke( >>> ServletController.java:203) >>> at org.apache.cxf.transport.servlet.ServletController.invoke( >>> ServletController.java:137) >>> at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke( >>> CXFNonSpringServlet.java:159) >>> at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest( >>> AbstractHTTPServlet.java:286) >>> at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet( >>> AbstractHTTPServlet.java:211) >>> at javax.servlet.http.HttpServlet.service(HttpServlet.java:735) >>> at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service( >>> AbstractHTTPServlet.java:262) >>> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter( >>> ApplicationFilterChain.java:305) >>> 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.statistics.webapp.RequestIntercepterValve.invoke( >>> RequestIntercepterValve.java:43) >>> at org.wso2.carbon.bam.webapp.stat.publisher. >>> WebAppStatisticPublisherValve.invoke(WebAppStatisticPublisherValve.java: >>> 104) >>> 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:62) >>> 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) >>> >>> atorg.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004) >>> atorg.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589) >>> >>> atorg.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1653) >>> at java.util.concurrent.ThreadPoolExecutor$Worker.runTask( >>> ThreadPoolExecutor.java:886) >>> at java.util.concurrent.ThreadPoolExecutor$Worker.run( >>> ThreadPoolExecutor.java:908) >>> at java.lang.Thread.run(Thread.java:662) >>> Caused by: javax.naming.NameNotFoundException: Name [jdbc/IssueTrackerDB] >>> is not bound in this Context. Unable to find [jdbc]. >>> at org.apache.naming.NamingContext.lookup(NamingContext.java:820) >>> at org.apache.naming.NamingContext.lookup(NamingContext.java:168) >>> at org.wso2.carbon.tomcat.jndi.CarbonSelectorContext.lookup( >>> CarbonSelectorContext.java:67) >>> at org.wso2.carbon.context.internal. >>> CarbonContextDataHolder$CarbonInitialJNDIContext.lookup( >>> CarbonContextDataHolder.java:916) >>> at javax.naming.InitialContext.lookup(InitialContext.java:392) >>> at org.wso2.carbon.issue.tracker.util.DBConfiguration.lookupDataSource( >>> DBConfiguration.java:55) >>> ... 50 more >>> >>> >>> >>> >>> -- >>> Nihanth Joseph >>> Senior Software Engineer >>> Mob: +94719187136 >>> >> >> >> >> -- >> Ramith Jayasinghe >> Technical Lead >> WSO2 Inc., http://wso2.com >> lean.enterprise.middleware >> >> E: ram...@wso2.com >> P: +94 776715671 >> >> > > > -- > *Afkham Azeez* > Director of Architecture; WSO2, Inc.; http://wso2.com > Member; Apache Software Foundation; http://www.apache.org/ > * <http://www.apache.org/>** > email: **az...@wso2.com* <az...@wso2.com>* cell: +94 77 3320919 > blog: **http://blog.afkham.org* <http://blog.afkham.org>* > twitter: **http://twitter.com/afkham_azeez*<http://twitter.com/afkham_azeez> > * > linked-in: **http://lk.linkedin.com/in/afkhamazeez* > * > * > *Lean . Enterprise . Middleware* > -- Piyum Fernando Software Engineer Mobile: +94 77 22 93 880 Home: +94 31 22 75 715
_______________________________________________ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev