Hi Anjana, On Sat, Jul 9, 2011 at 2:54 PM, Anjana Fernando <anj...@wso2.com> wrote:
> Hi Senaka, > > On Sat, Jul 9, 2011 at 11:00 AM, Senaka Fernando <sen...@wso2.com> wrote: > >> >> Nope it is not supposed to work like that. See [1 - 2]. >> > > So, I guess that says, it loads the properties from a resource file and > makes them readily available?, so they don't actually need to pass those > into InitialContext constructor explicitly. Anyways, we'll put that aside > for the moment. > Tried to locate the resource file inside the binary but never found one. Where did you find this? > > >> >> Assume what you say is correct for some reason, though the spec does not >> say anything. In that case, your fix is still a hack, and is not generic, >> and will also break some other code. This is because you are actually using >> the wrong environment. If the InitialContext ever had an environment when it >> was created, it would get replaced by the one which was used when the >> factory was created. So, if we are to fix this we need to find a proper >> solution. >> > > I'm not saving the properties in the factory, I'm saving it in the > "CarbonInitialJNDIContext" class, I guess we use it as a wrapper to > InitialContext. So it's just local to that InitialContext instance. see [1], > where it says, it will not modify the Hashtable in anyway, but in our case > it does, which is what I explained earlier. It's happening at > "CarbonInitialJNDIContextFactory", in the following method, > Not really, see the difference of the code what you've written (focusing on the sections in bold). If someone passed the environment when creating a new initial context, that would get replaced with the one you pass when creating the factory. Note that I applied the latest fix that you sent a few minutes ago, and it still remains the same. +++++++++++++++++++++++++ private static class CarbonInitialJNDIContext implements EventDirContext, LdapContext { private Context initialContext; + private Hashtable<?, ?> environment; private Map<String, Context> contextCache = Collections.synchronizedMap(new HashMap<String, Context>()); private static ContextCleanupTask contextCleanupTask; @@ -777,7 +778,8 @@ "JNDI.Restrictions.AllTenants.UrlContexts.UrlContext.Scheme")); } - public CarbonInitialJNDIContext(Context initialContext) throws NamingException { + public CarbonInitialJNDIContext(Hashtable<?, ?> environment, Context initialContext) throws NamingException { + this.environment = environment; this.initialContext = initialContext; } @@ -815,7 +817,7 @@ private boolean isBaseContextRequested() { try { *- String baseContextRequested = (String) this.initialContext.getEnvironment(). + String baseContextRequested = (String) this.getEnvironment().* get(CarbonConstants.REQUEST_BASE_CONTEXT); if (baseContextRequested != null && baseContextRequested.equals("true")) { return true; @@ -849,7 +851,7 @@ } else { try { Context urlContext = NamingManager.getURLContext(scheme, *- initialContext.getEnvironment()); + this.getEnvironment());* if (urlContext != null) { contextCache.put(scheme, urlContext); base = urlContext; @@ -1043,7 +1045,8 @@ if (isSubTenant(getCurrentCarbonContextHolder().getTenantId())) { throw new NamingException("Tenants cannot retrieve the environment."); } *- return getInitialContext().getEnvironment(); + //return getInitialContext().getEnvironment(); + return environment;* } +++++++++++++++++++++++++ Thanks, Senaka. > public Context getInitialContext(Hashtable<?, ?> h) throws NamingException > { > return new CarbonInitialJNDIContext((Hashtable<?, ?>) > h.clone(), > factory.getInitialContext(h)); > } > > That's the modified method of mine, there it seems > "factory.getInitialContext(h)" changes "h". That's why I did a clone of it > and saved elsewhere (maybe we should also give a clone to the 2'nd > parameter, since he's the one changing it). > > [1] > http://download.oracle.com/javase/1.4.2/docs/api/javax/naming/spi/InitialContextFactory.html#getInitialContext%28java.util.Hashtable%29 > > Cheers, > Anjana. > > > >> >> [1] >> http://download.oracle.com/javase/6/docs/api/javax/naming/InitialContext.html#InitialContext%28%29 >> [2] >> http://download.oracle.com/javase/6/docs/api/javax/naming/Context.html#RESOURCEFILES >> >> Thanks, >> Senaka. >> >>> >>> Cheers, >>> Anjana. >>> >>> >>>> >>>> Thanks, >>>> Senaka. >>>> >>>> >>>> On Fri, Jul 8, 2011 at 9:22 PM, Anjana Fernando <anj...@wso2.com>wrote: >>>> >>>>> Reminder, this issue should be fixed for the Stratos release. I've >>>>> created a JIRA here [1]. >>>>> >>>>> [1] https://wso2.org/jira/browse/CARBON-10975 >>>>> >>>>> Cheers, >>>>> Anjana. >>>>> >>>>> >>>>> On Sun, Jul 3, 2011 at 4:33 PM, Anjana Fernando <anj...@wso2.com>wrote: >>>>> >>>>>> Hi Amila, >>>>>> >>>>>> On Sat, Jul 2, 2011 at 11:20 PM, Amila Jayasekara <ami...@wso2.com>wrote: >>>>>> >>>>>>> >>>>>>> Any idea, which call causes CarbonInitialJNDIContextFactory to pass >>>>>>> an >>>>>>> empty hash table ? >>>>>>> >>>>>> >>>>>> Passed the empty hashtable as in, a proper one is passed into the >>>>>> place at line 755 (in the code that's in svn). There it says >>>>>> "factory.getInitialContext(h)", and creates an InitialContext object, >>>>>> that >>>>>> object in the construction somehow empties out the hashtable as given as >>>>>> "h" >>>>>> here. Anyhow, the result is at line 852, the expression >>>>>> "initialContext.getEnvironment()" returns an empty Hashtable object. >>>>>> >>>>>> Cheers, >>>>>> Anjana. >>>>>> >>>>>> >>>>>>> >>>>>>> Thanks >>>>>>> AmilaJ >>>>>>> >>>>>>> > >>>>>>> > Another thing to note is, the ESB has the geronimo-jta lib. This >>>>>>> causes >>>>>>> > Atomikos to not to work properly, since the JDK also has these >>>>>>> libs, and you >>>>>>> > will ultimately get an ClassCastException. So I simply deleted this >>>>>>> jar and >>>>>>> > it worked without any issues. >>>>>>> > >>>>>>> > Cheers, >>>>>>> > Anjana. >>>>>>> > >>>>>>> > -- >>>>>>> > Anjana Fernando >>>>>>> > Senior Software Engineer >>>>>>> > WSO2 Inc. | http://wso2.com >>>>>>> > lean . enterprise . middleware >>>>>>> > >>>>>>> > _______________________________________________ >>>>>>> > Carbon-dev mailing list >>>>>>> > Carbon-dev@wso2.org >>>>>>> > http://mail.wso2.org/cgi-bin/mailman/listinfo/carbon-dev >>>>>>> > >>>>>>> > >>>>>>> _______________________________________________ >>>>>>> Carbon-dev mailing list >>>>>>> Carbon-dev@wso2.org >>>>>>> http://mail.wso2.org/cgi-bin/mailman/listinfo/carbon-dev >>>>>>> >>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> *Anjana Fernando* >>>>>> Senior Software Engineer >>>>>> WSO2 Inc. | http://wso2.com >>>>>> lean . enterprise . middleware >>>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> *Anjana Fernando* >>>>> Senior Software Engineer >>>>> WSO2 Inc. | http://wso2.com >>>>> lean . enterprise . middleware >>>>> >>>> >>>> >>>> >>>> -- >>>> *Senaka Fernando* >>>> Product Manager - WSO2 Governance Registry; >>>> Associate Technical Lead; WSO2 Inc.; http://wso2.com* >>>> Member; Apache Software Foundation; http://apache.org >>>> >>>> E-mail: senaka AT wso2.com >>>> **P: +1 408 754 7388; ext: 51736*; *M: +94 77 322 1818 >>>> Linked-In: http://linkedin.com/in/senakafernando >>>> >>>> *Lean . Enterprise . Middleware >>>> >>>> >>> >>> >>> -- >>> *Anjana Fernando* >>> Senior Software Engineer >>> WSO2 Inc. | http://wso2.com >>> lean . enterprise . middleware >>> >> >> >> >> >> -- >> *Senaka Fernando* >> Product Manager - WSO2 Governance Registry; >> Associate Technical Lead; WSO2 Inc.; http://wso2.com* >> Member; Apache Software Foundation; http://apache.org >> >> E-mail: senaka AT wso2.com >> **P: +1 408 754 7388; ext: 51736*; *M: +94 77 322 1818 >> Linked-In: http://linkedin.com/in/senakafernando >> >> *Lean . Enterprise . Middleware >> >> > > > -- > *Anjana Fernando* > Senior Software Engineer > WSO2 Inc. | http://wso2.com > lean . enterprise . middleware > -- *Senaka Fernando* Product Manager - WSO2 Governance Registry; Associate Technical Lead; WSO2 Inc.; http://wso2.com* Member; Apache Software Foundation; http://apache.org E-mail: senaka AT wso2.com **P: +1 408 754 7388; ext: 51736*; *M: +94 77 322 1818 Linked-In: http://linkedin.com/in/senakafernando *Lean . Enterprise . Middleware
_______________________________________________ Carbon-dev mailing list Carbon-dev@wso2.org http://mail.wso2.org/cgi-bin/mailman/listinfo/carbon-dev