On Sun, Jul 10, 2011 at 12:58 AM, Anjana Fernando <[email protected]> wrote:
> Again, just to clarify, I did not test this with other possibilities, it > was a quick fix to get distributed transactions working. And the sole reason > for starting this mail thread was not to force anyone to commit my code, but > to tell if it's wrong or not, or for anyone else to suggest a fix for the > potential problem. > > So anyways, in the offline chat I'd with Senaka, after understanding the > problem properly, we thought that it would be best to ship this as a known > issue for Stratos. And to test that code thoroughly later to see if it does > not break anything, and also to check later in Tomcat code to see if there's > anything wrong in their side, which maybe we can fix possibly. > +1. Thanks, Senaka. > Cheers, > Anjana. > > > On Sat, Jul 9, 2011 at 8:20 PM, Senaka Fernando <[email protected]> wrote: > >> Hi Anjana, >> >> On Sat, Jul 9, 2011 at 11:26 PM, Anjana Fernando <[email protected]> wrote: >> >>> Hi Senaka, >>> >>> On Sat, Jul 9, 2011 at 12:32 PM, Senaka Fernando <[email protected]>wrote: >>> >>>> Hi Anjana, >>>> >>>> On Sat, Jul 9, 2011 at 3:51 PM, Anjana Fernando <[email protected]>wrote: >>>> >>>>> >>>>> >>>>> On Sat, Jul 9, 2011 at 11:59 AM, Senaka Fernando <[email protected]>wrote: >>>>> >>>>>> >>>>>> >>>>>> Nothing will magically happen unless you write code to do it. So, if >>>> you could point me to some instructions on how you think this should >>>> happen, >>>> that would be great. AFAIU, there is no such way that this happens right >>>> now >>>> in Carbon since we don't have any application-specific JNDI properties >>>> right >>>> now. >>>> >>> >>> Yes, I was thinking in the lines of, Tomcat would be doing this, setting >>> these initial properties. And I wasn't also much sure how the internals >>> work, that's why I told for someone to review it, since I guess you wrote >>> this part of the code, or else, I would have directly committed it myself :) >>> .. >>> >> >> No its not the matter of checking this in, IMO, its just a easy-fix, :-). >> But, after going through it, it does not seem to be correct, :-(. >> >> >>> >>>> >>>> >>>>> >>>>> The code that you provided might work for your case, but it will >>>>> definitely break code that has been written properly using new >>>>> InitialContext(environment), since you are making a substitution inside >>>>> the >>>>> code. I highlighted this in my previous response in bold. Can you suggest >>>>> a >>>>> better way of doing that? Plus, it would be great if you could point to >>>>> some >>>>> documentation which justifies what you've done is correct. Because, AFAIU, >>>>> this is just a hack to get another bug fixed, from what I see. >>>>> >>>> >>> The stuff you showed in bold is where they access the environment >>> hashtable values, so they are the values, that was suppose to be coming from >>> the encapsulated InitialContext object. But as I experienced, sometimes they >>> empties out the passed in Hashtable object (not just not using it). So I was >>> thinking, what's passed into our "CarbonInitialJNDIContext" could be used as >>> the same as it was passed into the InitialContext object, here in this case, >>> they do something wrong, and as it's says in the javadoc, they should not be >>> doing that, so there's something wrong in that. So it was just a workaround. >>> Anyways, I agree with you in the suggestion that we should merge the >>> environment values, since it could be that in some other cases, the >>> InitialContext object could have added it's own properties later, where in >>> that case, the merge should be more appropriate. >>> >>> In your last mail, you said, they intentionally doesn't add the >>> environment properties to the InitialContext, but the problem is, >>> intentially or not, at the end, they do something that violates the spec, >>> which is changing the passed in object. So we've to do something to overcome >>> that, may it be a hack or not. I was checking the code for >>> "javaURLContextFactory" [1], but couldn't see any code that could actually >>> do what we experience. >>> >> >> If it is wrong in Tomcat, we need to fix the code in apache.naming. I'm >> not sure whether this is the right time for that. >> >>> >>> Anyways, it will be best if you can run the new ESB 4.0.0 and just use >>> the Transaction mediator and see how this work. Simply debug the code in the >>> CarbonContextHolder, and you will see the path of this happening. I guess >>> this would be more useful to understand the situation. >>> >> >> I agree. But, your fix is dangerous since it has the potential of breaking >> existing code that use the "new InitialContext(environment)" constructor. >> IMO, testing this only in the Transaction mediator and proving it works >> won't help. We need to be sure that this does not break all of LDAP, JMS, >> DB-lookup, and any generic J2EE web-app code that uses JNDI. So, unless its >> proven that nothing existing breaks, we should not go ahead with this fix. >> >> Further, if we are to fix this according to what you say, you need to >> justify what you say. The code written in the Carbon Kernel was written >> according the way in which it has been specified in the J2EE-world. So, if >> you are to introduce any changes, you will have to justify it. If not, there >> is a potential of it breaking other functionality. For example, the same >> code is expected to run on other Application Servers. Fixing it in Tomcat, >> and being sure that it just works, will not help right? You'll have to test >> the same for other Application Servers too. That's why I was reluctant to >> commit it right away. >> >> So, are you sure that this breaks nothing? Have you tested it? >> >> Besides that, AFAIU, this is broken in the TransactionMediator only. Why >> can't that be fixed properly? Why do you want to hack the core-JNDI code? >> >> Thanks, >> Senaka. >> >>> >>> [1] >>> http://grepcode.com/file/repository.jboss.org/nexus/content/repositories/releases/jboss.web/jbossweb/2.1.6.GA/org/apache/naming/java/javaURLContextFactory.java#javaURLContextFactory.getInitialContext%28java.util.Hashtable%29 >>> >>> Cheers, >>> Anjana. >>> >>> >>>> >>>>> Thanks, >>>>> Senaka. >>>>> >>>>> >>>>> Cheers, >>>>> Anjana. >>>>> >>>>> >>>>>> >>>>>> +++++++++++++++++++++++++ >>>>>> 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 >>>>>>>>>> <[email protected]>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 <[email protected] >>>>>>>>>>> > wrote: >>>>>>>>>>> >>>>>>>>>>>> Hi Amila, >>>>>>>>>>>> >>>>>>>>>>>> On Sat, Jul 2, 2011 at 11:20 PM, Amila Jayasekara < >>>>>>>>>>>> [email protected]> 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 >>>>>>>>>>>>> > [email protected] >>>>>>>>>>>>> > http://mail.wso2.org/cgi-bin/mailman/listinfo/carbon-dev >>>>>>>>>>>>> > >>>>>>>>>>>>> > >>>>>>>>>>>>> _______________________________________________ >>>>>>>>>>>>> Carbon-dev mailing list >>>>>>>>>>>>> [email protected] >>>>>>>>>>>>> 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 >>>>>> >>>>>> >>>>> >>>>> >>>>> -- >>>>> *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 [email protected] http://mail.wso2.org/cgi-bin/mailman/listinfo/carbon-dev
