You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@abdera.apache.org by Todd Wells <to...@theplatform.com> on 2008/05/02 04:50:21 UTC

Re: NullPointerException when calling ClientResponse.getDocument()

Unfortunately, this problem is getting worse, but I think I know the
fundamental problem (see below).

I went halfway down the roll-my-own route:  I grabbed the XML via HTTP and
parsed it myself, then manually created a Abdera Entry in order to keep as
much of my code unchanged as possible.

Alas, there is another NullPointerException, this time when I call
abdera.newEntry()!

Caused by: java.lang.NullPointerException
        at org.apache.abdera.Abdera.newEntry(Abdera.java:114)

The code at this line is very simple:

  return getFactory().newEntry();

So that means getFactory() is returning null -- indicating that in the
Abdera class it is also possible to use getFactory() before factory is
initialized (exactly analogous to getParser(), where the other NPE is
thrown).  At this rate I'm going to need to rip out all my Abdera-dependent
code.  

Looking at the code, I¹m pretty sure I know what¹s happening ‹ the
constructor for Abdera is allowing a reference to ³this² to escape during
construction.  In the constructor, Abdera calls out to newFactory(),
newParser(), etc.  In those methods, it calls other methods passing ³this²
as an argument. Since the constructor hasn¹t finished executing yet, ³this²
is only a partially-constructed object at the point that these methods refer
to it, and so the integrity of that object can¹t be guaranteed.   I followed
one of those code paths down the rabbit hole and discovered that the
classloader gets involved at some point, so you probably have a thread
accessing the Abdera object before it¹s fully constructed.  For a more
detailed explanation, see section 3.2.1 of Brian Goetz¹s book ³Java
Concurrency in Practice², where he explicitly warns against this error.
Actually, googling I see that he had an earlier article that discusses this
same issue: http://www.ibm.com/developerworks/java/library/j-jtp0618.html

It may just be the speed of my machine or the JVM implementation (2 x 2.8
GHz quad-core Xeon running OS X) that is causing the NPE to come up in this
scenario, but the fact that ³this² is escaping during construction is a
problem that will probably cause other people grief down the road.


On 4/29/08 2:58 PM, "James M Snell" <ja...@gmail.com> wrote:

> I haven't yet had the opportunity to look at this today.  Hoping to be
> able to look later this evening.
> 
> - James
> 
> Todd Wells wrote:
>> I haven't heard any more feedback on this -- since the classpaths appear
>> identical for practical purposes, do you think my supposition of a race
>> condition is a good one?  Like I said previously, this is blocking my
>> progress, so I wouldn't mind knowing one way or the other if somebody plans
>> to investigate this further, so I can proceed with rolling my own if
>> necessary.
>> 
>> Thanks,
>> 
>> -Todd
>> 
>> 
>> 
>> On 4/28/08 4:21 PM, "Todd Wells" <to...@theplatform.com> wrote:
>> 
>>> You bet.  For what it's worth, I changed my maven dependency to Abdera 0.3.0
>>> and had the same problem.  I am suspecting this is a race condition of some
>>> sort, because analyzing line 96 in AbstractClientResponse w
>>> here the NullPointerException is thrown, it seems like it¹s probably calling
>>> parser. getDefaultParserOptions() before parser is initialized--so it¹s
>>> trying to call getDefaultParserOptions() on a null object.  It seems as if
>>> Abdera is using the Parser in a multi-threaded fashion since the getParser()
>>> method is synchronized  -- so I¹m suspecting a race condition between
>>> threads somewhere where I¹m actually managing to call getDocument() before
>>> the parser is initialized.
>>> 
>>> I wrote a little code to munge the classpaths at the command line vs. in
>>> IDEA, and it said that IDEA has the following things in the classpath that
>>> ant doesn't:
>>> 
>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/../Classes/cha
>>> rsets.jar
>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/../Classes/cla
>>> sses.jar
>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/../Classes/dt.
>>> jar
>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/../Classes/jce
>>> .jar
>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/../Classes/jco
>>> nsole.jar
>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/../Classes/jss
>>> e.jar
>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/../Classes/laf
>>> .jar
>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/../Classes/ui.
>>> jar
>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/deploy.jar
>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/dt.jar
>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/ext/apple_
>>> provider.jar
>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/ext/dnsns.
>>> jar
>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/ext/locale
>>> data.jar
>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/ext/sunjce
>>> _provider.jar
>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/ext/sunpkc
>>> s11.jar
>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/javaws.jar
>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/jce.jar
>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/plugin.jar
>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/sa-jdi.jar
>>> 
>>> Since the command-line is using the same VM (the one built in to OS X), I¹ll
>>> assume those VM jars are actually there implicitly.  There weren¹t any cases
>>> where there were mis-matched versions of jars.  The only jar that the
>>> command line class path included that isn¹t included in IDEA is the jar that
>>> contains the code which is being developed in IDEA which is the code that
>>> calls into Abdera (hence IDEA doesn¹t need a jar of it, it has the classes
>>> directly).
>>> 
>>> Below are the "raw" class paths -- they are big, my apologies in advance.
>>> 
>>> Classpath from the command line (ant):
>>> 
>>> /Users/todd.wells/.m2/repository/org/apache/maven/maven-artifact/2.0.2/maven
>>> -artifact-2.0.2.jar:/Users/todd.wells/.m2/repository/org/springframework/spr
>>> ing-beans/2.0.6/spring-beans-2.0.6.jar:/Users/todd.wells/.m2/repository/aopa
>>> lliance/aopalliance/1.0/aopalliance-1.0.jar:/Users/todd.wells/.m2/repository
>>> /org/apache/abdera/abdera-i18n/0.4.0-incubating/abdera-i18n-0.4.0-incubating
>>> .jar:/Users/todd.wells/.m2/repository/org/apache/maven/maven-error-diagnosti
>>> cs/2.0.2/maven-error-diagnostics-2.0.2.jar:/Users/todd.wells/.m2/repository/
>>> commons-httpclient/commons-httpclient/3.1-rc1/commons-httpclient-3.1-rc1.jar
>>> :/Users/todd.wells/.m2/repository/javax/servlet/servlet-api/2.4/servlet-api-
>>> 2.4.jar:/Users/todd.wells/.m2/repository/commons-logging/commons-logging/1.0
>>> .4/commons-logging-1.0.4.jar:/Users/todd.wells/.m2/repository/stax/stax-api/
>>> 1.0.1/stax-api-1.0.1.jar:/Users/todd.wells/.m2/repository/log4j/log4j/1.2.13
>>> /log4j-1.2.13.jar:/Users/todd.wells/.m2/repository/org/apache/abdera/abdera-
>>> server/0.4.0-incubating/abdera-server-0.4.0-incubating.jar:/Users/todd.wells
>>> /.m2/repository/com/theplatform/test/modules/wordgenerator/pl-test-wordgener
>>> ator/1.0.0/pl-test-wordgenerator-1.0.0.jar:/Users/todd.wells/.m2/repository/
>>> jaxen/jaxen/1.1.1/jaxen-1.1.1.jar:/Users/todd.wells/.m2/repository/org/apach
>>> e/geronimo/specs/geronimo-stax-api_1.0_spec/1.0.1/geronimo-stax-api_1.0_spec
>>> -1.0.1.jar:/Users/todd.wells/.m2/repository/org/springframework/spring-web/2
>>> .0.6/spring-web-2.0.6.jar:/Users/todd.wells/.m2/repository/org/apache/maven/
>>> maven-artifact-ant/2.0.4/maven-artifact-ant-2.0.4.jar:/Users/todd.wells/.m2/
>>> repository/com/theplatform/modules/pl-galaxy/1.1.0-SNAPSHOT/pl-galaxy-1.1.0-
>>> SNAPSHOT.jar:/Users/todd.wells/.m2/repository/xml-apis/xml-apis/1.3.03/xml-a
>>> pis-1.3.03.jar:/Users/todd.wells/.m2/repository/commons-codec/commons-codec/
>>> 1.3/commons-codec-1.3.jar:/Users/todd.wells/.m2/repository/org/codehaus/plex
>>> us/plexus-container-default/1.0-alpha-9/plexus-container-default-1.0-alpha-9
>>> .jar:/Users/todd.wells/.m2/repository/org/apache/maven/wagon/wagon-provider-
>>> api/1.0-alpha-6/wagon-provider-api-1.0-alpha-6.jar:/Users/todd.wells/.m2/rep
>>> ository/classworlds/classworlds/1.1-alpha-2/classworlds-1.1-alpha-2.jar:/Use
>>> rs/todd.wells/.m2/repository/org/apache/ws/commons/axiom/axiom-impl/1.2.5/ax
>>> iom-impl-1.2.5.jar:/Users/todd.wells/.m2/repository/org/springframework/spri
>>> ng-core/2.0.6/spring-core-2.0.6.jar:/Users/todd.wells/.m2/repository/javax/m
>>> ail/mail/1.4/mail-1.4.jar:/Users/todd.wells/.m2/repository/org/apache/abdera
>>> /abdera-parser/0.4.0-incubating/abdera-parser-0.4.0-incubating.jar:/Users/to
>>> dd.wells/.m2/repository/org/apache/maven/maven-artifact-manager/2.0.2/maven-
>>> artifact-manager-2.0.2.jar:/Users/todd.wells/.m2/repository/org/apache/maven
>>> /maven-project/2.0.2/maven-project-2.0.2.jar:/Users/todd.wells/.m2/repositor
>>> y/org/apache/maven/maven-settings/2.0.2/maven-settings-2.0.2.jar:/Users/todd
>>> .wells/.m2/repository/groovy/groovy-all/1.5.5/groovy-all-1.5.5.jar:/Users/to
>>> dd.wells/.m2/repository/org/apache/maven/maven-model/2.0.2/maven-model-2.0.2
>>> .jar:/Users/todd.wells/.m2/repository/org/apache/geronimo/specs/geronimo-act
>>> ivation_1.0.2_spec/1.1/geronimo-activation_1.0.2_spec-1.1.jar:/Users/todd.we
>>> lls/.m2/repository/org/codehaus/woodstox/wstx-asl/3.2.1/wstx-asl-3.2.1.jar:/
>>> Users/todd.wells/.m2/repository/ant/ant/1.7/ant-1.7.jar:/Users/todd.wells/.m
>>> 2/repository/org/springframework/spring-context/2.0.6/spring-context-2.0.6.j
>>> ar:/Users/todd.wells/.m2/repository/org/apache/maven/maven-repository-metada
>>> ta/2.0.2/maven-repository-metadata-2.0.2.jar:/Users/todd.wells/.m2/repositor
>>> y/xalan/xalan/2.6.0/xalan-2.6.0.jar:/Users/todd.wells/.m2/repository/com/ibm
>>> /icu/icu4j/2.6.1/icu4j-2.6.1.jar:/Users/todd.wells/.m2/repository/jdom/jdom/
>>> 1.0/jdom-1.0.jar:/Users/todd.wells/.m2/repository/org/apache/abdera/abdera-s
>>> pring/0.4.0-incubating/abdera-spring-0.4.0-incubating.jar:/Users/todd.wells/
>>> .m2/repository/junit/junit/4.0/junit-4.0.jar:/Users/todd.wells/.m2/repositor
>>> y/org/apache/maven/maven-profile/2.0.2/maven-profile-2.0.2.jar:/Users/todd.w
>>> ells/.m2/repository/com/theplatform/test/modules/datehelper/pl-test-datehelp
>>> er/1.0-SNAPSHOT/pl-test-datehelper-1.0-SNAPSHOT.jar:/Users/todd.wells/.m2/re
>>> pository/javax/activation/activation/1.1/activation-1.1.jar:/Users/todd.well
>>> s/.m2/repository/org/apache/ws/commons/axiom/axiom-api/1.2.5/axiom-api-1.2.5
>>> .jar:/Users/todd.wells/.m2/repository/org/apache/maven/wagon/wagon-file/1.0-
>>> alpha-7/wagon-file-1.0-alpha-7.jar:/Users/todd.wells/.m2/repository/org/code
>>> haus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar:/Users/todd.wells/.m2/repo
>>> sitory/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar:/Users/todd.wells/.m2/repository/an
>>> t/ant-launcher/1.7/ant-launcher-1.7.jar:/Users/todd.wells/.m2/repository/xer
>>> ces/xmlParserAPIs/2.6.2/xmlParserAPIs-2.6.2.jar:/Users/todd.wells/.m2/reposi
>>> tory/xom/xom/1.0/xom-1.0.jar:/Users/todd.wells/.m2/repository/org/apache/abd
>>> era/abdera-client/0.4.0-incubating/abdera-client-0.4.0-incubating.jar:/Users
>>> /todd.wells/.m2/repository/org/apache/abdera/abdera-core/0.4.0-incubating/ab
>>> dera-core-0.4.0-incubating.jar:/Users/todd.wells/.m2/repository/xerces/xerce
>>> sImpl/2.8.0/xercesImpl-2.8.0.jar:/Users/todd.wells/.m2/repository/org/apache
>>> /maven/wagon/wagon-http-lightweight/1.0-alpha-6/wagon-http-lightweight-1.0-a
>>> lpha-6.jar
>>> 
>>> Classpath in IDEA:
>>> 
>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/deploy.jar
>>> :/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/dt.jar:/S
>>> ystem/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/javaws.jar:/
>>> System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/jce.jar:/Sy
>>> stem/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/plugin.jar:/S
>>> ystem/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/sa-jdi.jar:/
>>> System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/../Classes/char
>>> sets.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/../Cl
>>> asses/classes.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.5/H
>>> ome/../Classes/dt.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1
>>> .5/Home/../Classes/jce.jar:/System/Library/Frameworks/JavaVM.framework/Versi
>>> ons/1.5/Home/../Classes/jconsole.jar:/System/Library/Frameworks/JavaVM.frame
>>> work/Versions/1.5/Home/../Classes/jsse.jar:/System/Library/Frameworks/JavaVM
>>> .framework/Versions/1.5/Home/../Classes/laf.jar:/System/Library/Frameworks/J
>>> avaVM.framework/Versions/1.5/Home/../Classes/ui.jar:/System/Library/Framewor
>>> ks/JavaVM.framework/Versions/1.5/Home/lib/ext/apple_provider.jar:/System/Lib
>>> rary/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/ext/dnsns.jar:/System
>>> /Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/ext/localedata.ja
>>> r:/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/ext/sunj
>>> ce_provider.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Hom
>>> e/lib/ext/sunpkcs11.jar:/depot/Tools/deploy/galaxy/main/target/classes:/User
>>> s/todd.wells/.m2/repository/junit/junit/4.0/junit-4.0.jar:/Users/todd.wells/
>>> .m2/repository/log4j/log4j/1.2.13/log4j-1.2.13.jar:/Users/todd.wells/.m2/rep
>>> ository/com/theplatform/test/modules/wordgenerator/pl-test-wordgenerator/1.0
>>> .0/pl-test-wordgenerator-1.0.0.jar:/Users/todd.wells/.m2/repository/com/thep
>>> latform/test/modules/datehelper/pl-test-datehelper/1.0-SNAPSHOT/pl-test-date
>>> helper-1.0-SNAPSHOT.jar:/Users/todd.wells/.m2/repository/org/apache/abdera/a
>>> bdera-client/0.4.0-incubating/abdera-client-0.4.0-incubating.jar:/Users/todd
>>> .wells/.m2/repository/org/apache/abdera/abdera-core/0.4.0-incubating/abdera-
>>> core-0.4.0-incubating.jar:/Users/todd.wells/.m2/repository/org/apache/abdera
>>> /abdera-i18n/0.4.0-incubating/abdera-i18n-0.4.0-incubating.jar:/Users/todd.w
>>> ells/.m2/repository/org/apache/geronimo/specs/geronimo-activation_1.0.2_spec
>>> /1.1/geronimo-activation_1.0.2_spec-1.1.jar:/Users/todd.wells/.m2/repository
>>> /commons-codec/commons-codec/1.3/commons-codec-1.3.jar:/Users/todd.wells/.m2
>>> /repository/org/apache/abdera/abdera-parser/0.4.0-incubating/abdera-parser-0
>>> .4.0-incubating.jar:/Users/todd.wells/.m2/repository/org/apache/ws/commons/a
>>> xiom/axiom-impl/1.2.5/axiom-impl-1.2.5.jar:/Users/todd.wells/.m2/repository/
>>> org/apache/ws/commons/axiom/axiom-api/1.2.5/axiom-api-1.2.5.jar:/Users/todd.
>>> wells/.m2/repository/commons-logging/commons-logging/1.0.4/commons-logging-1
>>> .0.4.jar:/Users/todd.wells/.m2/repository/jaxen/jaxen/1.1.1/jaxen-1.1.1.jar:
>>> /Users/todd.wells/.m2/repository/xerces/xercesImpl/2.8.0/xercesImpl-2.8.0.ja
>>> r:/Users/todd.wells/.m2/repository/xml-apis/xml-apis/1.3.03/xml-apis-1.3.03.
>>> jar:/Users/todd.wells/.m2/repository/org/apache/geronimo/specs/geronimo-stax
>>> -api_1.0_spec/1.0.1/geronimo-stax-api_1.0_spec-1.0.1.jar:/Users/todd.wells/.
>>> m2/repository/org/codehaus/woodstox/wstx-asl/3.2.1/wstx-asl-3.2.1.jar:/Users
>>> /todd.wells/.m2/repository/commons-httpclient/commons-httpclient/3.1-rc1/com
>>> mons-httpclient-3.1-rc1.jar:/Users/todd.wells/.m2/repository/org/apache/abde
>>> ra/abdera-server/0.4.0-incubating/abdera-server-0.4.0-incubating.jar:/Users/
>>> todd.wells/.m2/repository/javax/servlet/servlet-api/2.4/servlet-api-2.4.jar:
>>> /Users/todd.wells/.m2/repository/org/apache/abdera/abdera-spring/0.4.0-incub
>>> ating/abdera-spring-0.4.0-incubating.jar:/Users/todd.wells/.m2/repository/or
>>> g/springframework/spring-web/2.0.6/spring-web-2.0.6.jar:/Users/todd.wells/.m
>>> 2/repository/org/springframework/spring-beans/2.0.6/spring-beans-2.0.6.jar:/
>>> Users/todd.wells/.m2/repository/org/springframework/spring-core/2.0.6/spring
>>> -core-2.0.6.jar:/Users/todd.wells/.m2/repository/org/springframework/spring-
>>> context/2.0.6/spring-context-2.0.6.jar:/Users/todd.wells/.m2/repository/aopa
>>> lliance/aopalliance/1.0/aopalliance-1.0.jar:/Users/todd.wells/.m2/repository
>>> /org/apache/maven/maven-artifact-ant/2.0.4/maven-artifact-ant-2.0.4.jar:/Use
>>> rs/todd.wells/.m2/repository/org/apache/maven/maven-project/2.0.2/maven-proj
>>> ect-2.0.2.jar:/Users/todd.wells/.m2/repository/org/apache/maven/maven-profil
>>> e/2.0.2/maven-profile-2.0.2.jar:/Users/todd.wells/.m2/repository/org/apache/
>>> maven/maven-model/2.0.2/maven-model-2.0.2.jar:/Users/todd.wells/.m2/reposito
>>> ry/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar:/Users/todd.wel
>>> ls/.m2/repository/org/codehaus/plexus/plexus-container-default/1.0-alpha-9/p
>>> lexus-container-default-1.0-alpha-9.jar:/Users/todd.wells/.m2/repository/cla
>>> ssworlds/classworlds/1.1-alpha-2/classworlds-1.1-alpha-2.jar:/Users/todd.wel
>>> ls/.m2/repository/org/apache/maven/maven-artifact-manager/2.0.2/maven-artifa
>>> ct-manager-2.0.2.jar:/Users/todd.wells/.m2/repository/org/apache/maven/maven
>>> -repository-metadata/2.0.2/maven-repository-metadata-2.0.2.jar:/Users/todd.w
>>> ells/.m2/repository/org/apache/maven/maven-artifact/2.0.2/maven-artifact-2.0
>>> .2.jar:/Users/todd.wells/.m2/repository/org/apache/maven/wagon/wagon-provide
>>> r-api/1.0-alpha-6/wagon-provider-api-1.0-alpha-6.jar:/Users/todd.wells/.m2/r
>>> epository/org/apache/maven/maven-error-diagnostics/2.0.2/maven-error-diagnos
>>> tics-2.0.2.jar:/Users/todd.wells/.m2/repository/org/apache/maven/maven-setti
>>> ngs/2.0.2/maven-settings-2.0.2.jar:/Users/todd.wells/.m2/repository/org/apac
>>> he/maven/wagon/wagon-file/1.0-alpha-7/wagon-file-1.0-alpha-7.jar:/Users/todd
>>> .wells/.m2/repository/org/apache/maven/wagon/wagon-http-lightweight/1.0-alph
>>> a-6/wagon-http-lightweight-1.0-alpha-6.jar:/Users/todd.wells/.m2/repository/
>>> ant/ant/1.7/ant-1.7.jar:/Users/todd.wells/.m2/repository/groovy/groovy-all/1
>>> .5.5/groovy-all-1.5.5.jar:/Users/todd.wells/.m2/repository/javax/mail/mail/1
>>> .4/mail-1.4.jar:/Users/todd.wells/.m2/repository/javax/activation/activation
>>> /1.1/activation-1.1.jar:/Users/todd.wells/.m2/repository/stax/stax-api/1.0.1
>>> /stax-api-1.0.1.jar:/Users/todd.wells/.m2/repository/dom4j/dom4j/1.6.1/dom4j
>>> -1.6.1.jar:/Users/todd.wells/.m2/repository/jdom/jdom/1.0/jdom-1.0.jar:/User
>>> s/todd.wells/.m2/repository/xom/xom/1.0/xom-1.0.jar:/Users/todd.wells/.m2/re
>>> pository/xerces/xmlParserAPIs/2.6.2/xmlParserAPIs-2.6.2.jar:/Users/todd.well
>>> s/.m2/repository/xalan/xalan/2.6.0/xalan-2.6.0.jar:/Users/todd.wells/.m2/rep
>>> ository/com/ibm/icu/icu4j/2.6.1/icu4j-2.6.1.jar:/Users/todd.wells/.m2/reposi
>>> tory/ant/ant-launcher/1.7/ant-launcher-1.7.jar
>>> 
>>> 
>>> 
>>> 
>>> On 4/28/08 2:56 PM, "Dan Diephouse" <da...@mulesource.com> wrote:
>>> 
>>>> Well I'll be honest, I'm stumped too. This is with 0.4.0 right? Any
>>>> chance you can print out the classpath?
>>>> 
>>>> Dan
>>>> 
>>>> Todd Wells wrote:
>>>>> I1m stumped.  I have this repeatable case where
>>>>> ClientResponse.getDocument()
>>>>> results in a NullPointerException, even though a fully-formed atom
>>>>> document
>>>>> was successfully retrieved.
>>>>> 
>>>>> Here1s the weird part Ð and sorry there are so many caveats here Ð this is
>>>>> running from inside an ant task that I1ve written.  When I run it inside
>>>>> of
>>>>> the debugger or IDE (while not debugging) it works just fine.  When I run
>>>>> it
>>>>> via the command line I get the NPE every time.  I1m routing both attempts
>>>>> through an HTTP proxy (fiddler) and I can see that the HTTP request and
>>>>> response are the same in both cases , but in the one case Abdera throws
>>>>> the
>>>>> NPE.  I1ve been poking at this for several hours now and I1m at my wit1s
>>>>> end.  Here1s the stack trace I1m getting.  Any idea how I could further
>>>>> nail
>>>>> this down?
>>>>> 
>>>>> Caused by: java.lang.NullPointerException
>>>>>         at 
>>>>> org.apache.abdera.protocol.client.AbstractClientResponse.getDocument(Abstr
>>>>> ac
>>>>> tClientResponse.java:96)
>>>>>         at 
>>>>> org.apache.abdera.protocol.client.AbstractClientResponse.getDocument(Abstr
>>>>> ac
>>>>> tClientResponse.java:74)
>>>>>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>>>         at 
>>>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
>>>>> 39
>>>>> )
>>>>>         at 
>>>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorIm
>>>>> pl
>>>>> .java:25)
>>>>>         at java.lang.reflect.Method.invoke(Method.java:585)
>>>>>         at 
>>>>> org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)
>>>>>         at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:226)
>>>>>         at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:910)
>>>>>         at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:754)
>>>>>         at 
>>>>> org.codehaus.groovy.runtime.InvokerHelper.invokePojoMethod(InvokerHelper.j
>>>>> av
>>>>> a:765)
>>>>>         at 
>>>>> org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:
>>>>> 75
>>>>> 3)
>>>>>         at 
>>>>> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptByte
>>>>> co
>>>>> deAdapter.java:167)
>>>>> 
>>>>> My best (and somewhat feeble) guess is that there1s something different in
>>>>> the class paths that is causing the difference in behavior.  What that
>>>>> might
>>>>> be, I have no idea.
>>>>> 
>>>>>   
>> 
>> 


Re: NullPointerException when calling ClientResponse.getDocument()

Posted by Todd Wells <to...@theplatform.com>.
Sure, I can file a Jira.  The frustrating thing is that there is no special
test case to repro this.  I'm simply doing the following steps (in this case
from groovy):

def abdera = new Abdera()
Entry entry = abdera.newEntry()

When I run it in IDEA (calling from a unit test or executing a custom ant
task) it works fine. When I'm calling it from inside of a custom ant task
running at the command line, I get the null pointer exceptions that I've
described.  This supports the notion of it being a race condition -- it's
highly squirrelly and environment-specific.

Sorry some of my characters in the email below got a little munged, the
Entourage email client that I'm stuck using at the moment is awful.  I never
thought I would miss Outlook ;-)




On 5/1/08 9:13 PM, "James M Snell" <ja...@gmail.com> wrote:

> Ok, thank you for investigating further.  I've been having to devote the
> overwhelming majority of my time to completing a couple of day job
> projects so I haven't been able to investigate this.  Tomorrow I should
> be available in the afternoon to look it over and try to get it fixed.
> If you haven't done so already, please file an issue in Jira for this.
> It would also be helpful if you could provide or describe the test case
> so I can reproduce the error and verify the fix.
> 
> - James
> 
> Todd Wells wrote:
>> Unfortunately, this problem is getting worse, but I think I know the
>> fundamental problem (see below).
>> 
>> I went halfway down the roll-my-own route:  I grabbed the XML via HTTP and
>> parsed it myself, then manually created a Abdera Entry in order to keep as
>> much of my code unchanged as possible.
>> 
>> Alas, there is another NullPointerException, this time when I call
>> abdera.newEntry()!
>> 
>> Caused by: java.lang.NullPointerException
>>         at org.apache.abdera.Abdera.newEntry(Abdera.java:114)
>> 
>> The code at this line is very simple:
>> 
>>   return getFactory().newEntry();
>> 
>> So that means getFactory() is returning null -- indicating that in the
>> Abdera class it is also possible to use getFactory() before factory is
>> initialized (exactly analogous to getParser(), where the other NPE is
>> thrown).  At this rate I'm going to need to rip out all my Abdera-dependent
>> code.  
>> 
>> Looking at the code, I¹m pretty sure I know what¹s happening ‹ the
>> constructor for Abdera is allowing a reference to ³this² to escape during
>> construction.  In the constructor, Abdera calls out to newFactory(),
>> newParser(), etc.  In those methods, it calls other methods passing ³this²
>> as an argument. Since the constructor hasn¹t finished executing yet, ³this²
>> is only a partially-constructed object at the point that these methods refer
>> to it, and so the integrity of that object can¹t be guaranteed.   I followed
>> one of those code paths down the rabbit hole and discovered that the
>> classloader gets involved at some point, so you probably have a thread
>> accessing the Abdera object before it¹s fully constructed.  For a more
>> detailed explanation, see section 3.2.1 of Brian Goetz¹s book ³Java
>> Concurrency in Practice², where he explicitly warns against this error.
>> Actually, googling I see that he had an earlier article that discusses this
>> same issue: http://www.ibm.com/developerworks/java/library/j-jtp0618.html
>> 
>> It may just be the speed of my machine or the JVM implementation (2 x 2.8
>> GHz quad-core Xeon running OS X) that is causing the NPE to come up in this
>> scenario, but the fact that ³this² is escaping during construction is a
>> problem that will probably cause other people grief down the road.
>> 
>> 
>> On 4/29/08 2:58 PM, "James M Snell" <ja...@gmail.com> wrote:
>> 
>>> I haven't yet had the opportunity to look at this today.  Hoping to be
>>> able to look later this evening.
>>> 
>>> - James
>>> 
>>> Todd Wells wrote:
>>>> I haven't heard any more feedback on this -- since the classpaths appear
>>>> identical for practical purposes, do you think my supposition of a race
>>>> condition is a good one?  Like I said previously, this is blocking my
>>>> progress, so I wouldn't mind knowing one way or the other if somebody plans
>>>> to investigate this further, so I can proceed with rolling my own if
>>>> necessary.
>>>> 
>>>> Thanks,
>>>> 
>>>> -Todd
>>>> 
>>>> 
>>>> 
>>>> On 4/28/08 4:21 PM, "Todd Wells" <to...@theplatform.com> wrote:
>>>> 
>>>>> You bet.  For what it's worth, I changed my maven dependency to Abdera
>>>>> 0.3.0
>>>>> and had the same problem.  I am suspecting this is a race condition of
>>>>> some
>>>>> sort, because analyzing line 96 in AbstractClientResponse w
>>>>> here the NullPointerException is thrown, it seems like it¹s probably
>>>>> calling
>>>>> parser. getDefaultParserOptions() before parser is initialized--so it¹s
>>>>> trying to call getDefaultParserOptions() on a null object.  It seems as if
>>>>> Abdera is using the Parser in a multi-threaded fashion since the
>>>>> getParser()
>>>>> method is synchronized  -- so I¹m suspecting a race condition between
>>>>> threads somewhere where I¹m actually managing to call getDocument() before
>>>>> the parser is initialized.
>>>>> 
>>>>> I wrote a little code to munge the classpaths at the command line vs. in
>>>>> IDEA, and it said that IDEA has the following things in the classpath that
>>>>> ant doesn't:
>>>>> 
>>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/../Classes/c
>>>>> ha
>>>>> rsets.jar
>>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/../Classes/c
>>>>> la
>>>>> sses.jar
>>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/../Classes/d
>>>>> t.
>>>>> jar
>>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/../Classes/j
>>>>> ce
>>>>> .jar
>>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/../Classes/j
>>>>> co
>>>>> nsole.jar
>>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/../Classes/j
>>>>> ss
>>>>> e.jar
>>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/../Classes/l
>>>>> af
>>>>> .jar
>>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/../Classes/u
>>>>> i.
>>>>> jar
>>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/deploy.j
>>>>> ar
>>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/dt.jar
>>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/ext/appl
>>>>> e_
>>>>> provider.jar
>>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/ext/dnsn
>>>>> s.
>>>>> jar
>>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/ext/loca
>>>>> le
>>>>> data.jar
>>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/ext/sunj
>>>>> ce
>>>>> _provider.jar
>>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/ext/sunp
>>>>> kc
>>>>> s11.jar
>>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/javaws.j
>>>>> ar
>>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/jce.jar
>>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/plugin.j
>>>>> ar
>>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/sa-jdi.j
>>>>> ar
>>>>> 
>>>>> Since the command-line is using the same VM (the one built in to OS X),
>>>>> I¹ll
>>>>> assume those VM jars are actually there implicitly.  There weren¹t any
>>>>> cases
>>>>> where there were mis-matched versions of jars.  The only jar that the
>>>>> command line class path included that isn¹t included in IDEA is the jar
>>>>> that
>>>>> contains the code which is being developed in IDEA which is the code that
>>>>> calls into Abdera (hence IDEA doesn¹t need a jar of it, it has the classes
>>>>> directly).
>>>>> 
>>>>> Below are the "raw" class paths -- they are big, my apologies in advance.
>>>>> 
>>>>> Classpath from the command line (ant):
>>>>> 
>>>>> /Users/todd.wells/.m2/repository/org/apache/maven/maven-artifact/2.0.2/mav
>>>>> en
>>>>> -artifact-2.0.2.jar:/Users/todd.wells/.m2/repository/org/springframework/s
>>>>> pr
>>>>> ing-beans/2.0.6/spring-beans-2.0.6.jar:/Users/todd.wells/.m2/repository/ao
>>>>> pa
>>>>> lliance/aopalliance/1.0/aopalliance-1.0.jar:/Users/todd.wells/.m2/reposito
>>>>> ry
>>>>> /org/apache/abdera/abdera-i18n/0.4.0-incubating/abdera-i18n-0.4.0-incubati
>>>>> ng
>>>>> .jar:/Users/todd.wells/.m2/repository/org/apache/maven/maven-error-diagnos
>>>>> ti
>>>>> cs/2.0.2/maven-error-diagnostics-2.0.2.jar:/Users/todd.wells/.m2/repositor
>>>>> y/
>>>>> commons-httpclient/commons-httpclient/3.1-rc1/commons-httpclient-3.1-rc1.j
>>>>> ar
>>>>> :/Users/todd.wells/.m2/repository/javax/servlet/servlet-api/2.4/servlet-ap
>>>>> i-
>>>>> 2.4.jar:/Users/todd.wells/.m2/repository/commons-logging/commons-logging/1
>>>>> .0
>>>>> .4/commons-logging-1.0.4.jar:/Users/todd.wells/.m2/repository/stax/stax-ap
>>>>> i/
>>>>> 1.0.1/stax-api-1.0.1.jar:/Users/todd.wells/.m2/repository/log4j/log4j/1.2.
>>>>> 13
>>>>> /log4j-1.2.13.jar:/Users/todd.wells/.m2/repository/org/apache/abdera/abder
>>>>> a-
>>>>> server/0.4.0-incubating/abdera-server-0.4.0-incubating.jar:/Users/todd.wel
>>>>> ls
>>>>> /.m2/repository/com/theplatform/test/modules/wordgenerator/pl-test-wordgen
>>>>> er
>>>>> ator/1.0.0/pl-test-wordgenerator-1.0.0.jar:/Users/todd.wells/.m2/repositor
>>>>> y/
>>>>> jaxen/jaxen/1.1.1/jaxen-1.1.1.jar:/Users/todd.wells/.m2/repository/org/apa
>>>>> ch
>>>>> e/geronimo/specs/geronimo-stax-api_1.0_spec/1.0.1/geronimo-stax-api_1.0_sp
>>>>> ec
>>>>> -1.0.1.jar:/Users/todd.wells/.m2/repository/org/springframework/spring-web
>>>>> /2
>>>>> .0.6/spring-web-2.0.6.jar:/Users/todd.wells/.m2/repository/org/apache/mave
>>>>> n/
>>>>> maven-artifact-ant/2.0.4/maven-artifact-ant-2.0.4.jar:/Users/todd.wells/.m
>>>>> 2/
>>>>> repository/com/theplatform/modules/pl-galaxy/1.1.0-SNAPSHOT/pl-galaxy-1.1.
>>>>> 0-
>>>>> SNAPSHOT.jar:/Users/todd.wells/.m2/repository/xml-apis/xml-apis/1.3.03/xml
>>>>> -a
>>>>> pis-1.3.03.jar:/Users/todd.wells/.m2/repository/commons-codec/commons-code
>>>>> c/
>>>>> 1.3/commons-codec-1.3.jar:/Users/todd.wells/.m2/repository/org/codehaus/pl
>>>>> ex
>>>>> us/plexus-container-default/1.0-alpha-9/plexus-container-default-1.0-alpha
>>>>> -9
>>>>> .jar:/Users/todd.wells/.m2/repository/org/apache/maven/wagon/wagon-provide
>>>>> r-
>>>>> api/1.0-alpha-6/wagon-provider-api-1.0-alpha-6.jar:/Users/todd.wells/.m2/r
>>>>> ep
>>>>> ository/classworlds/classworlds/1.1-alpha-2/classworlds-1.1-alpha-2.jar:/U
>>>>> se
>>>>> rs/todd.wells/.m2/repository/org/apache/ws/commons/axiom/axiom-impl/1.2.5/
>>>>> ax
>>>>> iom-impl-1.2.5.jar:/Users/todd.wells/.m2/repository/org/springframework/sp
>>>>> ri
>>>>> ng-core/2.0.6/spring-core-2.0.6.jar:/Users/todd.wells/.m2/repository/javax
>>>>> /m
>>>>> ail/mail/1.4/mail-1.4.jar:/Users/todd.wells/.m2/repository/org/apache/abde
>>>>> ra
>>>>> /abdera-parser/0.4.0-incubating/abdera-parser-0.4.0-incubating.jar:/Users/
>>>>> to
>>>>> dd.wells/.m2/repository/org/apache/maven/maven-artifact-manager/2.0.2/mave
>>>>> n-
>>>>> artifact-manager-2.0.2.jar:/Users/todd.wells/.m2/repository/org/apache/mav
>>>>> en
>>>>> /maven-project/2.0.2/maven-project-2.0.2.jar:/Users/todd.wells/.m2/reposit
>>>>> or
>>>>> y/org/apache/maven/maven-settings/2.0.2/maven-settings-2.0.2.jar:/Users/to
>>>>> dd
>>>>> .wells/.m2/repository/groovy/groovy-all/1.5.5/groovy-all-1.5.5.jar:/Users/
>>>>> to
>>>>> dd.wells/.m2/repository/org/apache/maven/maven-model/2.0.2/maven-model-2.0
>>>>> .2
>>>>> .jar:/Users/todd.wells/.m2/repository/org/apache/geronimo/specs/geronimo-a
>>>>> ct
>>>>> ivation_1.0.2_spec/1.1/geronimo-activation_1.0.2_spec-1.1.jar:/Users/todd.
>>>>> we
>>>>> lls/.m2/repository/org/codehaus/woodstox/wstx-asl/3.2.1/wstx-asl-3.2.1.jar
>>>>> :/
>>>>> Users/todd.wells/.m2/repository/ant/ant/1.7/ant-1.7.jar:/Users/todd.wells/
>>>>> .m
>>>>> 2/repository/org/springframework/spring-context/2.0.6/spring-context-2.0.6
>>>>> .j
>>>>> ar:/Users/todd.wells/.m2/repository/org/apache/maven/maven-repository-meta
>>>>> da
>>>>> ta/2.0.2/maven-repository-metadata-2.0.2.jar:/Users/todd.wells/.m2/reposit
>>>>> or
>>>>> y/xalan/xalan/2.6.0/xalan-2.6.0.jar:/Users/todd.wells/.m2/repository/com/i
>>>>> bm
>>>>> /icu/icu4j/2.6.1/icu4j-2.6.1.jar:/Users/todd.wells/.m2/repository/jdom/jdo
>>>>> m/
>>>>> 1.0/jdom-1.0.jar:/Users/todd.wells/.m2/repository/org/apache/abdera/abdera
>>>>> -s
>>>>> pring/0.4.0-incubating/abdera-spring-0.4.0-incubating.jar:/Users/todd.well
>>>>> s/
>>>>> .m2/repository/junit/junit/4.0/junit-4.0.jar:/Users/todd.wells/.m2/reposit
>>>>> or
>>>>> y/org/apache/maven/maven-profile/2.0.2/maven-profile-2.0.2.jar:/Users/todd
>>>>> .w
>>>>> ells/.m2/repository/com/theplatform/test/modules/datehelper/pl-test-datehe
>>>>> lp
>>>>> er/1.0-SNAPSHOT/pl-test-datehelper-1.0-SNAPSHOT.jar:/Users/todd.wells/.m2/
>>>>> re
>>>>> pository/javax/activation/activation/1.1/activation-1.1.jar:/Users/todd.we
>>>>> ll
>>>>> s/.m2/repository/org/apache/ws/commons/axiom/axiom-api/1.2.5/axiom-api-1.2
>>>>> .5
>>>>> .jar:/Users/todd.wells/.m2/repository/org/apache/maven/wagon/wagon-file/1.
>>>>> 0-
>>>>> alpha-7/wagon-file-1.0-alpha-7.jar:/Users/todd.wells/.m2/repository/org/co
>>>>> de
>>>>> haus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar:/Users/todd.wells/.m2/re
>>>>> po
>>>>> sitory/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar:/Users/todd.wells/.m2/repository/
>>>>> an
>>>>> t/ant-launcher/1.7/ant-launcher-1.7.jar:/Users/todd.wells/.m2/repository/x
>>>>> er
>>>>> ces/xmlParserAPIs/2.6.2/xmlParserAPIs-2.6.2.jar:/Users/todd.wells/.m2/repo
>>>>> si
>>>>> tory/xom/xom/1.0/xom-1.0.jar:/Users/todd.wells/.m2/repository/org/apache/a
>>>>> bd
>>>>> era/abdera-client/0.4.0-incubating/abdera-client-0.4.0-incubating.jar:/Use
>>>>> rs
>>>>> /todd.wells/.m2/repository/org/apache/abdera/abdera-core/0.4.0-incubating/
>>>>> ab
>>>>> dera-core-0.4.0-incubating.jar:/Users/todd.wells/.m2/repository/xerces/xer
>>>>> ce
>>>>> sImpl/2.8.0/xercesImpl-2.8.0.jar:/Users/todd.wells/.m2/repository/org/apac
>>>>> he
>>>>> /maven/wagon/wagon-http-lightweight/1.0-alpha-6/wagon-http-lightweight-1.0
>>>>> -a
>>>>> lpha-6.jar
>>>>> 
>>>>> Classpath in IDEA:
>>>>> 
>>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/deploy.j
>>>>> ar
>>>>> :/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/dt.jar:
>>>>> /S
>>>>> ystem/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/javaws.jar
>>>>> :/
>>>>> System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/jce.jar:/
>>>>> Sy
>>>>> stem/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/plugin.jar:
>>>>> /S
>>>>> ystem/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/sa-jdi.jar
>>>>> :/
>>>>> System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/../Classes/ch
>>>>> ar
>>>>> sets.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/../
>>>>> Cl
>>>>> asses/classes.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.5
>>>>> /H
>>>>> ome/../Classes/dt.jar:/System/Library/Frameworks/JavaVM.framework/Versions
>>>>> /1
>>>>> .5/Home/../Classes/jce.jar:/System/Library/Frameworks/JavaVM.framework/Ver
>>>>> si
>>>>> ons/1.5/Home/../Classes/jconsole.jar:/System/Library/Frameworks/JavaVM.fra
>>>>> me
>>>>> work/Versions/1.5/Home/../Classes/jsse.jar:/System/Library/Frameworks/Java
>>>>> VM
>>>>> .framework/Versions/1.5/Home/../Classes/laf.jar:/System/Library/Frameworks
>>>>> /J
>>>>> avaVM.framework/Versions/1.5/Home/../Classes/ui.jar:/System/Library/Framew
>>>>> or
>>>>> ks/JavaVM.framework/Versions/1.5/Home/lib/ext/apple_provider.jar:/System/L
>>>>> ib
>>>>> rary/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/ext/dnsns.jar:/Syst
>>>>> em
>>>>> /Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/ext/localedata.
>>>>> ja
>>>>> r:/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/ext/su
>>>>> nj
>>>>> ce_provider.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.5/H
>>>>> om
>>>>> e/lib/ext/sunpkcs11.jar:/depot/Tools/deploy/galaxy/main/target/classes:/Us
>>>>> er
>>>>> s/todd.wells/.m2/repository/junit/junit/4.0/junit-4.0.jar:/Users/todd.well
>>>>> s/
>>>>> .m2/repository/log4j/log4j/1.2.13/log4j-1.2.13.jar:/Users/todd.wells/.m2/r
>>>>> ep
>>>>> ository/com/theplatform/test/modules/wordgenerator/pl-test-wordgenerator/1
>>>>> .0
>>>>> .0/pl-test-wordgenerator-1.0.0.jar:/Users/todd.wells/.m2/repository/com/th
>>>>> ep
>>>>> latform/test/modules/datehelper/pl-test-datehelper/1.0-SNAPSHOT/pl-test-da
>>>>> te
>>>>> helper-1.0-SNAPSHOT.jar:/Users/todd.wells/.m2/repository/org/apache/abdera
>>>>> /a
>>>>> bdera-client/0.4.0-incubating/abdera-client-0.4.0-incubating.jar:/Users/to
>>>>> dd
>>>>> .wells/.m2/repository/org/apache/abdera/abdera-core/0.4.0-incubating/abder
>>>>> a-
>>>>> core-0.4.0-incubating.jar:/Users/todd.wells/.m2/repository/org/apache/abde
>>>>> ra
>>>>> /abdera-i18n/0.4.0-incubating/abdera-i18n-0.4.0-incubating.jar:/Users/todd
>>>>> .w
>>>>> ells/.m2/repository/org/apache/geronimo/specs/geronimo-activation_1.0.2_sp
>>>>> ec
>>>>> /1.1/geronimo-activation_1.0.2_spec-1.1.jar:/Users/todd.wells/.m2/reposito
>>>>> ry
>>>>> /commons-codec/commons-codec/1.3/commons-codec-1.3.jar:/Users/todd.wells/.
>>>>> m2
>>>>> /repository/org/apache/abdera/abdera-parser/0.4.0-incubating/abdera-parser
>>>>> -0
>>>>> .4.0-incubating.jar:/Users/todd.wells/.m2/repository/org/apache/ws/commons
>>>>> /a
>>>>> xiom/axiom-impl/1.2.5/axiom-impl-1.2.5.jar:/Users/todd.wells/.m2/repositor
>>>>> y/
>>>>> org/apache/ws/commons/axiom/axiom-api/1.2.5/axiom-api-1.2.5.jar:/Users/tod
>>>>> d.
>>>>> wells/.m2/repository/commons-logging/commons-logging/1.0.4/commons-logging
>>>>> -1
>>>>> .0.4.jar:/Users/todd.wells/.m2/repository/jaxen/jaxen/1.1.1/jaxen-1.1.1.ja
>>>>> r:
>>>>> /Users/todd.wells/.m2/repository/xerces/xercesImpl/2.8.0/xercesImpl-2.8.0.
>>>>> ja
>>>>> r:/Users/todd.wells/.m2/repository/xml-apis/xml-apis/1.3.03/xml-apis-1.3.0
>>>>> 3.
>>>>> jar:/Users/todd.wells/.m2/repository/org/apache/geronimo/specs/geronimo-st
>>>>> ax
>>>>> -api_1.0_spec/1.0.1/geronimo-stax-api_1.0_spec-1.0.1.jar:/Users/todd.wells
>>>>> /.
>>>>> m2/repository/org/codehaus/woodstox/wstx-asl/3.2.1/wstx-asl-3.2.1.jar:/Use
>>>>> rs
>>>>> /todd.wells/.m2/repository/commons-httpclient/commons-httpclient/3.1-rc1/c
>>>>> om
>>>>> mons-httpclient-3.1-rc1.jar:/Users/todd.wells/.m2/repository/org/apache/ab
>>>>> de
>>>>> ra/abdera-server/0.4.0-incubating/abdera-server-0.4.0-incubating.jar:/User
>>>>> s/
>>>>> todd.wells/.m2/repository/javax/servlet/servlet-api/2.4/servlet-api-2.4.ja
>>>>> r:
>>>>> /Users/todd.wells/.m2/repository/org/apache/abdera/abdera-spring/0.4.0-inc
>>>>> ub
>>>>> ating/abdera-spring-0.4.0-incubating.jar:/Users/todd.wells/.m2/repository/
>>>>> or
>>>>> g/springframework/spring-web/2.0.6/spring-web-2.0.6.jar:/Users/todd.wells/
>>>>> .m
>>>>> 2/repository/org/springframework/spring-beans/2.0.6/spring-beans-2.0.6.jar
>>>>> :/
>>>>> Users/todd.wells/.m2/repository/org/springframework/spring-core/2.0.6/spri
>>>>> ng
>>>>> -core-2.0.6.jar:/Users/todd.wells/.m2/repository/org/springframework/sprin
>>>>> g-
>>>>> context/2.0.6/spring-context-2.0.6.jar:/Users/todd.wells/.m2/repository/ao
>>>>> pa
>>>>> lliance/aopalliance/1.0/aopalliance-1.0.jar:/Users/todd.wells/.m2/reposito
>>>>> ry
>>>>> /org/apache/maven/maven-artifact-ant/2.0.4/maven-artifact-ant-2.0.4.jar:/U
>>>>> se
>>>>> rs/todd.wells/.m2/repository/org/apache/maven/maven-project/2.0.2/maven-pr
>>>>> oj
>>>>> ect-2.0.2.jar:/Users/todd.wells/.m2/repository/org/apache/maven/maven-prof
>>>>> il
>>>>> e/2.0.2/maven-profile-2.0.2.jar:/Users/todd.wells/.m2/repository/org/apach
>>>>> e/
>>>>> maven/maven-model/2.0.2/maven-model-2.0.2.jar:/Users/todd.wells/.m2/reposi
>>>>> to
>>>>> ry/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar:/Users/todd.w
>>>>> el
>>>>> ls/.m2/repository/org/codehaus/plexus/plexus-container-default/1.0-alpha-9
>>>>> /p
>>>>> lexus-container-default-1.0-alpha-9.jar:/Users/todd.wells/.m2/repository/c
>>>>> la
>>>>> ssworlds/classworlds/1.1-alpha-2/classworlds-1.1-alpha-2.jar:/Users/todd.w
>>>>> el
>>>>> ls/.m2/repository/org/apache/maven/maven-artifact-manager/2.0.2/maven-arti
>>>>> fa
>>>>> ct-manager-2.0.2.jar:/Users/todd.wells/.m2/repository/org/apache/maven/mav
>>>>> en
>>>>> -repository-metadata/2.0.2/maven-repository-metadata-2.0.2.jar:/Users/todd
>>>>> .w
>>>>> ells/.m2/repository/org/apache/maven/maven-artifact/2.0.2/maven-artifact-2
>>>>> .0
>>>>> .2.jar:/Users/todd.wells/.m2/repository/org/apache/maven/wagon/wagon-provi
>>>>> de
>>>>> r-api/1.0-alpha-6/wagon-provider-api-1.0-alpha-6.jar:/Users/todd.wells/.m2
>>>>> /r
>>>>> epository/org/apache/maven/maven-error-diagnostics/2.0.2/maven-error-diagn
>>>>> os
>>>>> tics-2.0.2.jar:/Users/todd.wells/.m2/repository/org/apache/maven/maven-set
>>>>> ti
>>>>> ngs/2.0.2/maven-settings-2.0.2.jar:/Users/todd.wells/.m2/repository/org/ap
>>>>> ac
>>>>> he/maven/wagon/wagon-file/1.0-alpha-7/wagon-file-1.0-alpha-7.jar:/Users/to
>>>>> dd
>>>>> .wells/.m2/repository/org/apache/maven/wagon/wagon-http-lightweight/1.0-al
>>>>> ph
>>>>> a-6/wagon-http-lightweight-1.0-alpha-6.jar:/Users/todd.wells/.m2/repositor
>>>>> y/
>>>>> ant/ant/1.7/ant-1.7.jar:/Users/todd.wells/.m2/repository/groovy/groovy-all
>>>>> /1
>>>>> .5.5/groovy-all-1.5.5.jar:/Users/todd.wells/.m2/repository/javax/mail/mail
>>>>> /1
>>>>> .4/mail-1.4.jar:/Users/todd.wells/.m2/repository/javax/activation/activati
>>>>> on
>>>>> /1.1/activation-1.1.jar:/Users/todd.wells/.m2/repository/stax/stax-api/1.0
>>>>> .1
>>>>> /stax-api-1.0.1.jar:/Users/todd.wells/.m2/repository/dom4j/dom4j/1.6.1/dom
>>>>> 4j
>>>>> -1.6.1.jar:/Users/todd.wells/.m2/repository/jdom/jdom/1.0/jdom-1.0.jar:/Us
>>>>> er
>>>>> s/todd.wells/.m2/repository/xom/xom/1.0/xom-1.0.jar:/Users/todd.wells/.m2/
>>>>> re
>>>>> pository/xerces/xmlParserAPIs/2.6.2/xmlParserAPIs-2.6.2.jar:/Users/todd.we
>>>>> ll
>>>>> s/.m2/repository/xalan/xalan/2.6.0/xalan-2.6.0.jar:/Users/todd.wells/.m2/r
>>>>> ep
>>>>> ository/com/ibm/icu/icu4j/2.6.1/icu4j-2.6.1.jar:/Users/todd.wells/.m2/repo
>>>>> si
>>>>> tory/ant/ant-launcher/1.7/ant-launcher-1.7.jar
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> On 4/28/08 2:56 PM, "Dan Diephouse" <da...@mulesource.com> wrote:
>>>>> 
>>>>>> Well I'll be honest, I'm stumped too. This is with 0.4.0 right? Any
>>>>>> chance you can print out the classpath?
>>>>>> 
>>>>>> Dan
>>>>>> 
>>>>>> Todd Wells wrote:
>>>>>>> I1m stumped.  I have this repeatable case where
>>>>>>> ClientResponse.getDocument()
>>>>>>> results in a NullPointerException, even though a fully-formed atom
>>>>>>> document
>>>>>>> was successfully retrieved.
>>>>>>> 
>>>>>>> Here1s the weird part Ð and sorry there are so many caveats here Ð this
>>>>>>> is
>>>>>>> running from inside an ant task that I1ve written.  When I run it inside
>>>>>>> of
>>>>>>> the debugger or IDE (while not debugging) it works just fine.  When I
>>>>>>> run
>>>>>>> it
>>>>>>> via the command line I get the NPE every time.  I1m routing both
>>>>>>> attempts
>>>>>>> through an HTTP proxy (fiddler) and I can see that the HTTP request and
>>>>>>> response are the same in both cases , but in the one case Abdera throws
>>>>>>> the
>>>>>>> NPE.  I1ve been poking at this for several hours now and I1m at my wit1s
>>>>>>> end.  Here1s the stack trace I1m getting.  Any idea how I could further
>>>>>>> nail
>>>>>>> this down?
>>>>>>> 
>>>>>>> Caused by: java.lang.NullPointerException
>>>>>>>         at 
>>>>>>> org.apache.abdera.protocol.client.AbstractClientResponse.getDocument(Abs
>>>>>>> tr
>>>>>>> ac
>>>>>>> tClientResponse.java:96)
>>>>>>>         at 
>>>>>>> org.apache.abdera.protocol.client.AbstractClientResponse.getDocument(Abs
>>>>>>> tr
>>>>>>> ac
>>>>>>> tClientResponse.java:74)
>>>>>>>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>>>>>         at 
>>>>>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
>>>>>>> a:
>>>>>>> 39
>>>>>>> )
>>>>>>>         at 
>>>>>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
>>>>>>> Im
>>>>>>> pl
>>>>>>> .java:25)
>>>>>>>         at java.lang.reflect.Method.invoke(Method.java:585)
>>>>>>>         at 
>>>>>>> org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)
>>>>>>>         at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:226)
>>>>>>>         at 
>>>>>>> groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:910)
>>>>>>>         at 
>>>>>>> groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:754)
>>>>>>>         at 
>>>>>>> org.codehaus.groovy.runtime.InvokerHelper.invokePojoMethod(InvokerHelper
>>>>>>> .j
>>>>>>> av
>>>>>>> a:765)
>>>>>>>         at 
>>>>>>> org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.jav
>>>>>>> a:
>>>>>>> 75
>>>>>>> 3)
>>>>>>>         at 
>>>>>>> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBy
>>>>>>> te
>>>>>>> co
>>>>>>> deAdapter.java:167)
>>>>>>> 
>>>>>>> My best (and somewhat feeble) guess is that there1s something different
>>>>>>> in
>>>>>>> the class paths that is causing the difference in behavior.  What that
>>>>>>> might
>>>>>>> be, I have no idea.
>>>>>>> 
>>>>>>>   
>>>> 
>> 
>> 


Re: NullPointerException when calling ClientResponse.getDocument()

Posted by Todd Wells <to...@theplatform.com>.
Sure, I can file a Jira.  The frustrating thing is that there is no special
test case to repro this.  I'm simply doing the following steps (in this case
from groovy):

def abdera = new Abdera()
Entry entry = abdera.newEntry()

When I run it in IDEA (calling from a unit test or executing a custom ant
task) it works fine. When I'm calling it from inside of a custom ant task
running at the command line, I get the null pointer exceptions that I've
described.  This supports the notion of it being a race condition -- it's
highly squirrelly and environment-specific.

Sorry some of my characters in the email below got a little munged, the
Entourage email client that I'm stuck using at the moment is awful.  I never
thought I would miss Outlook ;-)




On 5/1/08 9:13 PM, "James M Snell" <ja...@gmail.com> wrote:

> Ok, thank you for investigating further.  I've been having to devote the
> overwhelming majority of my time to completing a couple of day job
> projects so I haven't been able to investigate this.  Tomorrow I should
> be available in the afternoon to look it over and try to get it fixed.
> If you haven't done so already, please file an issue in Jira for this.
> It would also be helpful if you could provide or describe the test case
> so I can reproduce the error and verify the fix.
> 
> - James
> 
> Todd Wells wrote:
>> Unfortunately, this problem is getting worse, but I think I know the
>> fundamental problem (see below).
>> 
>> I went halfway down the roll-my-own route:  I grabbed the XML via HTTP and
>> parsed it myself, then manually created a Abdera Entry in order to keep as
>> much of my code unchanged as possible.
>> 
>> Alas, there is another NullPointerException, this time when I call
>> abdera.newEntry()!
>> 
>> Caused by: java.lang.NullPointerException
>>         at org.apache.abdera.Abdera.newEntry(Abdera.java:114)
>> 
>> The code at this line is very simple:
>> 
>>   return getFactory().newEntry();
>> 
>> So that means getFactory() is returning null -- indicating that in the
>> Abdera class it is also possible to use getFactory() before factory is
>> initialized (exactly analogous to getParser(), where the other NPE is
>> thrown).  At this rate I'm going to need to rip out all my Abdera-dependent
>> code.  
>> 
>> Looking at the code, I¹m pretty sure I know what¹s happening ‹ the
>> constructor for Abdera is allowing a reference to ³this² to escape during
>> construction.  In the constructor, Abdera calls out to newFactory(),
>> newParser(), etc.  In those methods, it calls other methods passing ³this²
>> as an argument. Since the constructor hasn¹t finished executing yet, ³this²
>> is only a partially-constructed object at the point that these methods refer
>> to it, and so the integrity of that object can¹t be guaranteed.   I followed
>> one of those code paths down the rabbit hole and discovered that the
>> classloader gets involved at some point, so you probably have a thread
>> accessing the Abdera object before it¹s fully constructed.  For a more
>> detailed explanation, see section 3.2.1 of Brian Goetz¹s book ³Java
>> Concurrency in Practice², where he explicitly warns against this error.
>> Actually, googling I see that he had an earlier article that discusses this
>> same issue: http://www.ibm.com/developerworks/java/library/j-jtp0618.html
>> 
>> It may just be the speed of my machine or the JVM implementation (2 x 2.8
>> GHz quad-core Xeon running OS X) that is causing the NPE to come up in this
>> scenario, but the fact that ³this² is escaping during construction is a
>> problem that will probably cause other people grief down the road.
>> 
>> 
>> On 4/29/08 2:58 PM, "James M Snell" <ja...@gmail.com> wrote:
>> 
>>> I haven't yet had the opportunity to look at this today.  Hoping to be
>>> able to look later this evening.
>>> 
>>> - James
>>> 
>>> Todd Wells wrote:
>>>> I haven't heard any more feedback on this -- since the classpaths appear
>>>> identical for practical purposes, do you think my supposition of a race
>>>> condition is a good one?  Like I said previously, this is blocking my
>>>> progress, so I wouldn't mind knowing one way or the other if somebody plans
>>>> to investigate this further, so I can proceed with rolling my own if
>>>> necessary.
>>>> 
>>>> Thanks,
>>>> 
>>>> -Todd
>>>> 
>>>> 
>>>> 
>>>> On 4/28/08 4:21 PM, "Todd Wells" <to...@theplatform.com> wrote:
>>>> 
>>>>> You bet.  For what it's worth, I changed my maven dependency to Abdera
>>>>> 0.3.0
>>>>> and had the same problem.  I am suspecting this is a race condition of
>>>>> some
>>>>> sort, because analyzing line 96 in AbstractClientResponse w
>>>>> here the NullPointerException is thrown, it seems like it¹s probably
>>>>> calling
>>>>> parser. getDefaultParserOptions() before parser is initialized--so it¹s
>>>>> trying to call getDefaultParserOptions() on a null object.  It seems as if
>>>>> Abdera is using the Parser in a multi-threaded fashion since the
>>>>> getParser()
>>>>> method is synchronized  -- so I¹m suspecting a race condition between
>>>>> threads somewhere where I¹m actually managing to call getDocument() before
>>>>> the parser is initialized.
>>>>> 
>>>>> I wrote a little code to munge the classpaths at the command line vs. in
>>>>> IDEA, and it said that IDEA has the following things in the classpath that
>>>>> ant doesn't:
>>>>> 
>>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/../Classes/c
>>>>> ha
>>>>> rsets.jar
>>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/../Classes/c
>>>>> la
>>>>> sses.jar
>>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/../Classes/d
>>>>> t.
>>>>> jar
>>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/../Classes/j
>>>>> ce
>>>>> .jar
>>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/../Classes/j
>>>>> co
>>>>> nsole.jar
>>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/../Classes/j
>>>>> ss
>>>>> e.jar
>>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/../Classes/l
>>>>> af
>>>>> .jar
>>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/../Classes/u
>>>>> i.
>>>>> jar
>>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/deploy.j
>>>>> ar
>>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/dt.jar
>>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/ext/appl
>>>>> e_
>>>>> provider.jar
>>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/ext/dnsn
>>>>> s.
>>>>> jar
>>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/ext/loca
>>>>> le
>>>>> data.jar
>>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/ext/sunj
>>>>> ce
>>>>> _provider.jar
>>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/ext/sunp
>>>>> kc
>>>>> s11.jar
>>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/javaws.j
>>>>> ar
>>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/jce.jar
>>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/plugin.j
>>>>> ar
>>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/sa-jdi.j
>>>>> ar
>>>>> 
>>>>> Since the command-line is using the same VM (the one built in to OS X),
>>>>> I¹ll
>>>>> assume those VM jars are actually there implicitly.  There weren¹t any
>>>>> cases
>>>>> where there were mis-matched versions of jars.  The only jar that the
>>>>> command line class path included that isn¹t included in IDEA is the jar
>>>>> that
>>>>> contains the code which is being developed in IDEA which is the code that
>>>>> calls into Abdera (hence IDEA doesn¹t need a jar of it, it has the classes
>>>>> directly).
>>>>> 
>>>>> Below are the "raw" class paths -- they are big, my apologies in advance.
>>>>> 
>>>>> Classpath from the command line (ant):
>>>>> 
>>>>> /Users/todd.wells/.m2/repository/org/apache/maven/maven-artifact/2.0.2/mav
>>>>> en
>>>>> -artifact-2.0.2.jar:/Users/todd.wells/.m2/repository/org/springframework/s
>>>>> pr
>>>>> ing-beans/2.0.6/spring-beans-2.0.6.jar:/Users/todd.wells/.m2/repository/ao
>>>>> pa
>>>>> lliance/aopalliance/1.0/aopalliance-1.0.jar:/Users/todd.wells/.m2/reposito
>>>>> ry
>>>>> /org/apache/abdera/abdera-i18n/0.4.0-incubating/abdera-i18n-0.4.0-incubati
>>>>> ng
>>>>> .jar:/Users/todd.wells/.m2/repository/org/apache/maven/maven-error-diagnos
>>>>> ti
>>>>> cs/2.0.2/maven-error-diagnostics-2.0.2.jar:/Users/todd.wells/.m2/repositor
>>>>> y/
>>>>> commons-httpclient/commons-httpclient/3.1-rc1/commons-httpclient-3.1-rc1.j
>>>>> ar
>>>>> :/Users/todd.wells/.m2/repository/javax/servlet/servlet-api/2.4/servlet-ap
>>>>> i-
>>>>> 2.4.jar:/Users/todd.wells/.m2/repository/commons-logging/commons-logging/1
>>>>> .0
>>>>> .4/commons-logging-1.0.4.jar:/Users/todd.wells/.m2/repository/stax/stax-ap
>>>>> i/
>>>>> 1.0.1/stax-api-1.0.1.jar:/Users/todd.wells/.m2/repository/log4j/log4j/1.2.
>>>>> 13
>>>>> /log4j-1.2.13.jar:/Users/todd.wells/.m2/repository/org/apache/abdera/abder
>>>>> a-
>>>>> server/0.4.0-incubating/abdera-server-0.4.0-incubating.jar:/Users/todd.wel
>>>>> ls
>>>>> /.m2/repository/com/theplatform/test/modules/wordgenerator/pl-test-wordgen
>>>>> er
>>>>> ator/1.0.0/pl-test-wordgenerator-1.0.0.jar:/Users/todd.wells/.m2/repositor
>>>>> y/
>>>>> jaxen/jaxen/1.1.1/jaxen-1.1.1.jar:/Users/todd.wells/.m2/repository/org/apa
>>>>> ch
>>>>> e/geronimo/specs/geronimo-stax-api_1.0_spec/1.0.1/geronimo-stax-api_1.0_sp
>>>>> ec
>>>>> -1.0.1.jar:/Users/todd.wells/.m2/repository/org/springframework/spring-web
>>>>> /2
>>>>> .0.6/spring-web-2.0.6.jar:/Users/todd.wells/.m2/repository/org/apache/mave
>>>>> n/
>>>>> maven-artifact-ant/2.0.4/maven-artifact-ant-2.0.4.jar:/Users/todd.wells/.m
>>>>> 2/
>>>>> repository/com/theplatform/modules/pl-galaxy/1.1.0-SNAPSHOT/pl-galaxy-1.1.
>>>>> 0-
>>>>> SNAPSHOT.jar:/Users/todd.wells/.m2/repository/xml-apis/xml-apis/1.3.03/xml
>>>>> -a
>>>>> pis-1.3.03.jar:/Users/todd.wells/.m2/repository/commons-codec/commons-code
>>>>> c/
>>>>> 1.3/commons-codec-1.3.jar:/Users/todd.wells/.m2/repository/org/codehaus/pl
>>>>> ex
>>>>> us/plexus-container-default/1.0-alpha-9/plexus-container-default-1.0-alpha
>>>>> -9
>>>>> .jar:/Users/todd.wells/.m2/repository/org/apache/maven/wagon/wagon-provide
>>>>> r-
>>>>> api/1.0-alpha-6/wagon-provider-api-1.0-alpha-6.jar:/Users/todd.wells/.m2/r
>>>>> ep
>>>>> ository/classworlds/classworlds/1.1-alpha-2/classworlds-1.1-alpha-2.jar:/U
>>>>> se
>>>>> rs/todd.wells/.m2/repository/org/apache/ws/commons/axiom/axiom-impl/1.2.5/
>>>>> ax
>>>>> iom-impl-1.2.5.jar:/Users/todd.wells/.m2/repository/org/springframework/sp
>>>>> ri
>>>>> ng-core/2.0.6/spring-core-2.0.6.jar:/Users/todd.wells/.m2/repository/javax
>>>>> /m
>>>>> ail/mail/1.4/mail-1.4.jar:/Users/todd.wells/.m2/repository/org/apache/abde
>>>>> ra
>>>>> /abdera-parser/0.4.0-incubating/abdera-parser-0.4.0-incubating.jar:/Users/
>>>>> to
>>>>> dd.wells/.m2/repository/org/apache/maven/maven-artifact-manager/2.0.2/mave
>>>>> n-
>>>>> artifact-manager-2.0.2.jar:/Users/todd.wells/.m2/repository/org/apache/mav
>>>>> en
>>>>> /maven-project/2.0.2/maven-project-2.0.2.jar:/Users/todd.wells/.m2/reposit
>>>>> or
>>>>> y/org/apache/maven/maven-settings/2.0.2/maven-settings-2.0.2.jar:/Users/to
>>>>> dd
>>>>> .wells/.m2/repository/groovy/groovy-all/1.5.5/groovy-all-1.5.5.jar:/Users/
>>>>> to
>>>>> dd.wells/.m2/repository/org/apache/maven/maven-model/2.0.2/maven-model-2.0
>>>>> .2
>>>>> .jar:/Users/todd.wells/.m2/repository/org/apache/geronimo/specs/geronimo-a
>>>>> ct
>>>>> ivation_1.0.2_spec/1.1/geronimo-activation_1.0.2_spec-1.1.jar:/Users/todd.
>>>>> we
>>>>> lls/.m2/repository/org/codehaus/woodstox/wstx-asl/3.2.1/wstx-asl-3.2.1.jar
>>>>> :/
>>>>> Users/todd.wells/.m2/repository/ant/ant/1.7/ant-1.7.jar:/Users/todd.wells/
>>>>> .m
>>>>> 2/repository/org/springframework/spring-context/2.0.6/spring-context-2.0.6
>>>>> .j
>>>>> ar:/Users/todd.wells/.m2/repository/org/apache/maven/maven-repository-meta
>>>>> da
>>>>> ta/2.0.2/maven-repository-metadata-2.0.2.jar:/Users/todd.wells/.m2/reposit
>>>>> or
>>>>> y/xalan/xalan/2.6.0/xalan-2.6.0.jar:/Users/todd.wells/.m2/repository/com/i
>>>>> bm
>>>>> /icu/icu4j/2.6.1/icu4j-2.6.1.jar:/Users/todd.wells/.m2/repository/jdom/jdo
>>>>> m/
>>>>> 1.0/jdom-1.0.jar:/Users/todd.wells/.m2/repository/org/apache/abdera/abdera
>>>>> -s
>>>>> pring/0.4.0-incubating/abdera-spring-0.4.0-incubating.jar:/Users/todd.well
>>>>> s/
>>>>> .m2/repository/junit/junit/4.0/junit-4.0.jar:/Users/todd.wells/.m2/reposit
>>>>> or
>>>>> y/org/apache/maven/maven-profile/2.0.2/maven-profile-2.0.2.jar:/Users/todd
>>>>> .w
>>>>> ells/.m2/repository/com/theplatform/test/modules/datehelper/pl-test-datehe
>>>>> lp
>>>>> er/1.0-SNAPSHOT/pl-test-datehelper-1.0-SNAPSHOT.jar:/Users/todd.wells/.m2/
>>>>> re
>>>>> pository/javax/activation/activation/1.1/activation-1.1.jar:/Users/todd.we
>>>>> ll
>>>>> s/.m2/repository/org/apache/ws/commons/axiom/axiom-api/1.2.5/axiom-api-1.2
>>>>> .5
>>>>> .jar:/Users/todd.wells/.m2/repository/org/apache/maven/wagon/wagon-file/1.
>>>>> 0-
>>>>> alpha-7/wagon-file-1.0-alpha-7.jar:/Users/todd.wells/.m2/repository/org/co
>>>>> de
>>>>> haus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar:/Users/todd.wells/.m2/re
>>>>> po
>>>>> sitory/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar:/Users/todd.wells/.m2/repository/
>>>>> an
>>>>> t/ant-launcher/1.7/ant-launcher-1.7.jar:/Users/todd.wells/.m2/repository/x
>>>>> er
>>>>> ces/xmlParserAPIs/2.6.2/xmlParserAPIs-2.6.2.jar:/Users/todd.wells/.m2/repo
>>>>> si
>>>>> tory/xom/xom/1.0/xom-1.0.jar:/Users/todd.wells/.m2/repository/org/apache/a
>>>>> bd
>>>>> era/abdera-client/0.4.0-incubating/abdera-client-0.4.0-incubating.jar:/Use
>>>>> rs
>>>>> /todd.wells/.m2/repository/org/apache/abdera/abdera-core/0.4.0-incubating/
>>>>> ab
>>>>> dera-core-0.4.0-incubating.jar:/Users/todd.wells/.m2/repository/xerces/xer
>>>>> ce
>>>>> sImpl/2.8.0/xercesImpl-2.8.0.jar:/Users/todd.wells/.m2/repository/org/apac
>>>>> he
>>>>> /maven/wagon/wagon-http-lightweight/1.0-alpha-6/wagon-http-lightweight-1.0
>>>>> -a
>>>>> lpha-6.jar
>>>>> 
>>>>> Classpath in IDEA:
>>>>> 
>>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/deploy.j
>>>>> ar
>>>>> :/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/dt.jar:
>>>>> /S
>>>>> ystem/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/javaws.jar
>>>>> :/
>>>>> System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/jce.jar:/
>>>>> Sy
>>>>> stem/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/plugin.jar:
>>>>> /S
>>>>> ystem/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/sa-jdi.jar
>>>>> :/
>>>>> System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/../Classes/ch
>>>>> ar
>>>>> sets.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/../
>>>>> Cl
>>>>> asses/classes.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.5
>>>>> /H
>>>>> ome/../Classes/dt.jar:/System/Library/Frameworks/JavaVM.framework/Versions
>>>>> /1
>>>>> .5/Home/../Classes/jce.jar:/System/Library/Frameworks/JavaVM.framework/Ver
>>>>> si
>>>>> ons/1.5/Home/../Classes/jconsole.jar:/System/Library/Frameworks/JavaVM.fra
>>>>> me
>>>>> work/Versions/1.5/Home/../Classes/jsse.jar:/System/Library/Frameworks/Java
>>>>> VM
>>>>> .framework/Versions/1.5/Home/../Classes/laf.jar:/System/Library/Frameworks
>>>>> /J
>>>>> avaVM.framework/Versions/1.5/Home/../Classes/ui.jar:/System/Library/Framew
>>>>> or
>>>>> ks/JavaVM.framework/Versions/1.5/Home/lib/ext/apple_provider.jar:/System/L
>>>>> ib
>>>>> rary/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/ext/dnsns.jar:/Syst
>>>>> em
>>>>> /Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/ext/localedata.
>>>>> ja
>>>>> r:/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/ext/su
>>>>> nj
>>>>> ce_provider.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.5/H
>>>>> om
>>>>> e/lib/ext/sunpkcs11.jar:/depot/Tools/deploy/galaxy/main/target/classes:/Us
>>>>> er
>>>>> s/todd.wells/.m2/repository/junit/junit/4.0/junit-4.0.jar:/Users/todd.well
>>>>> s/
>>>>> .m2/repository/log4j/log4j/1.2.13/log4j-1.2.13.jar:/Users/todd.wells/.m2/r
>>>>> ep
>>>>> ository/com/theplatform/test/modules/wordgenerator/pl-test-wordgenerator/1
>>>>> .0
>>>>> .0/pl-test-wordgenerator-1.0.0.jar:/Users/todd.wells/.m2/repository/com/th
>>>>> ep
>>>>> latform/test/modules/datehelper/pl-test-datehelper/1.0-SNAPSHOT/pl-test-da
>>>>> te
>>>>> helper-1.0-SNAPSHOT.jar:/Users/todd.wells/.m2/repository/org/apache/abdera
>>>>> /a
>>>>> bdera-client/0.4.0-incubating/abdera-client-0.4.0-incubating.jar:/Users/to
>>>>> dd
>>>>> .wells/.m2/repository/org/apache/abdera/abdera-core/0.4.0-incubating/abder
>>>>> a-
>>>>> core-0.4.0-incubating.jar:/Users/todd.wells/.m2/repository/org/apache/abde
>>>>> ra
>>>>> /abdera-i18n/0.4.0-incubating/abdera-i18n-0.4.0-incubating.jar:/Users/todd
>>>>> .w
>>>>> ells/.m2/repository/org/apache/geronimo/specs/geronimo-activation_1.0.2_sp
>>>>> ec
>>>>> /1.1/geronimo-activation_1.0.2_spec-1.1.jar:/Users/todd.wells/.m2/reposito
>>>>> ry
>>>>> /commons-codec/commons-codec/1.3/commons-codec-1.3.jar:/Users/todd.wells/.
>>>>> m2
>>>>> /repository/org/apache/abdera/abdera-parser/0.4.0-incubating/abdera-parser
>>>>> -0
>>>>> .4.0-incubating.jar:/Users/todd.wells/.m2/repository/org/apache/ws/commons
>>>>> /a
>>>>> xiom/axiom-impl/1.2.5/axiom-impl-1.2.5.jar:/Users/todd.wells/.m2/repositor
>>>>> y/
>>>>> org/apache/ws/commons/axiom/axiom-api/1.2.5/axiom-api-1.2.5.jar:/Users/tod
>>>>> d.
>>>>> wells/.m2/repository/commons-logging/commons-logging/1.0.4/commons-logging
>>>>> -1
>>>>> .0.4.jar:/Users/todd.wells/.m2/repository/jaxen/jaxen/1.1.1/jaxen-1.1.1.ja
>>>>> r:
>>>>> /Users/todd.wells/.m2/repository/xerces/xercesImpl/2.8.0/xercesImpl-2.8.0.
>>>>> ja
>>>>> r:/Users/todd.wells/.m2/repository/xml-apis/xml-apis/1.3.03/xml-apis-1.3.0
>>>>> 3.
>>>>> jar:/Users/todd.wells/.m2/repository/org/apache/geronimo/specs/geronimo-st
>>>>> ax
>>>>> -api_1.0_spec/1.0.1/geronimo-stax-api_1.0_spec-1.0.1.jar:/Users/todd.wells
>>>>> /.
>>>>> m2/repository/org/codehaus/woodstox/wstx-asl/3.2.1/wstx-asl-3.2.1.jar:/Use
>>>>> rs
>>>>> /todd.wells/.m2/repository/commons-httpclient/commons-httpclient/3.1-rc1/c
>>>>> om
>>>>> mons-httpclient-3.1-rc1.jar:/Users/todd.wells/.m2/repository/org/apache/ab
>>>>> de
>>>>> ra/abdera-server/0.4.0-incubating/abdera-server-0.4.0-incubating.jar:/User
>>>>> s/
>>>>> todd.wells/.m2/repository/javax/servlet/servlet-api/2.4/servlet-api-2.4.ja
>>>>> r:
>>>>> /Users/todd.wells/.m2/repository/org/apache/abdera/abdera-spring/0.4.0-inc
>>>>> ub
>>>>> ating/abdera-spring-0.4.0-incubating.jar:/Users/todd.wells/.m2/repository/
>>>>> or
>>>>> g/springframework/spring-web/2.0.6/spring-web-2.0.6.jar:/Users/todd.wells/
>>>>> .m
>>>>> 2/repository/org/springframework/spring-beans/2.0.6/spring-beans-2.0.6.jar
>>>>> :/
>>>>> Users/todd.wells/.m2/repository/org/springframework/spring-core/2.0.6/spri
>>>>> ng
>>>>> -core-2.0.6.jar:/Users/todd.wells/.m2/repository/org/springframework/sprin
>>>>> g-
>>>>> context/2.0.6/spring-context-2.0.6.jar:/Users/todd.wells/.m2/repository/ao
>>>>> pa
>>>>> lliance/aopalliance/1.0/aopalliance-1.0.jar:/Users/todd.wells/.m2/reposito
>>>>> ry
>>>>> /org/apache/maven/maven-artifact-ant/2.0.4/maven-artifact-ant-2.0.4.jar:/U
>>>>> se
>>>>> rs/todd.wells/.m2/repository/org/apache/maven/maven-project/2.0.2/maven-pr
>>>>> oj
>>>>> ect-2.0.2.jar:/Users/todd.wells/.m2/repository/org/apache/maven/maven-prof
>>>>> il
>>>>> e/2.0.2/maven-profile-2.0.2.jar:/Users/todd.wells/.m2/repository/org/apach
>>>>> e/
>>>>> maven/maven-model/2.0.2/maven-model-2.0.2.jar:/Users/todd.wells/.m2/reposi
>>>>> to
>>>>> ry/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar:/Users/todd.w
>>>>> el
>>>>> ls/.m2/repository/org/codehaus/plexus/plexus-container-default/1.0-alpha-9
>>>>> /p
>>>>> lexus-container-default-1.0-alpha-9.jar:/Users/todd.wells/.m2/repository/c
>>>>> la
>>>>> ssworlds/classworlds/1.1-alpha-2/classworlds-1.1-alpha-2.jar:/Users/todd.w
>>>>> el
>>>>> ls/.m2/repository/org/apache/maven/maven-artifact-manager/2.0.2/maven-arti
>>>>> fa
>>>>> ct-manager-2.0.2.jar:/Users/todd.wells/.m2/repository/org/apache/maven/mav
>>>>> en
>>>>> -repository-metadata/2.0.2/maven-repository-metadata-2.0.2.jar:/Users/todd
>>>>> .w
>>>>> ells/.m2/repository/org/apache/maven/maven-artifact/2.0.2/maven-artifact-2
>>>>> .0
>>>>> .2.jar:/Users/todd.wells/.m2/repository/org/apache/maven/wagon/wagon-provi
>>>>> de
>>>>> r-api/1.0-alpha-6/wagon-provider-api-1.0-alpha-6.jar:/Users/todd.wells/.m2
>>>>> /r
>>>>> epository/org/apache/maven/maven-error-diagnostics/2.0.2/maven-error-diagn
>>>>> os
>>>>> tics-2.0.2.jar:/Users/todd.wells/.m2/repository/org/apache/maven/maven-set
>>>>> ti
>>>>> ngs/2.0.2/maven-settings-2.0.2.jar:/Users/todd.wells/.m2/repository/org/ap
>>>>> ac
>>>>> he/maven/wagon/wagon-file/1.0-alpha-7/wagon-file-1.0-alpha-7.jar:/Users/to
>>>>> dd
>>>>> .wells/.m2/repository/org/apache/maven/wagon/wagon-http-lightweight/1.0-al
>>>>> ph
>>>>> a-6/wagon-http-lightweight-1.0-alpha-6.jar:/Users/todd.wells/.m2/repositor
>>>>> y/
>>>>> ant/ant/1.7/ant-1.7.jar:/Users/todd.wells/.m2/repository/groovy/groovy-all
>>>>> /1
>>>>> .5.5/groovy-all-1.5.5.jar:/Users/todd.wells/.m2/repository/javax/mail/mail
>>>>> /1
>>>>> .4/mail-1.4.jar:/Users/todd.wells/.m2/repository/javax/activation/activati
>>>>> on
>>>>> /1.1/activation-1.1.jar:/Users/todd.wells/.m2/repository/stax/stax-api/1.0
>>>>> .1
>>>>> /stax-api-1.0.1.jar:/Users/todd.wells/.m2/repository/dom4j/dom4j/1.6.1/dom
>>>>> 4j
>>>>> -1.6.1.jar:/Users/todd.wells/.m2/repository/jdom/jdom/1.0/jdom-1.0.jar:/Us
>>>>> er
>>>>> s/todd.wells/.m2/repository/xom/xom/1.0/xom-1.0.jar:/Users/todd.wells/.m2/
>>>>> re
>>>>> pository/xerces/xmlParserAPIs/2.6.2/xmlParserAPIs-2.6.2.jar:/Users/todd.we
>>>>> ll
>>>>> s/.m2/repository/xalan/xalan/2.6.0/xalan-2.6.0.jar:/Users/todd.wells/.m2/r
>>>>> ep
>>>>> ository/com/ibm/icu/icu4j/2.6.1/icu4j-2.6.1.jar:/Users/todd.wells/.m2/repo
>>>>> si
>>>>> tory/ant/ant-launcher/1.7/ant-launcher-1.7.jar
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> On 4/28/08 2:56 PM, "Dan Diephouse" <da...@mulesource.com> wrote:
>>>>> 
>>>>>> Well I'll be honest, I'm stumped too. This is with 0.4.0 right? Any
>>>>>> chance you can print out the classpath?
>>>>>> 
>>>>>> Dan
>>>>>> 
>>>>>> Todd Wells wrote:
>>>>>>> I1m stumped.  I have this repeatable case where
>>>>>>> ClientResponse.getDocument()
>>>>>>> results in a NullPointerException, even though a fully-formed atom
>>>>>>> document
>>>>>>> was successfully retrieved.
>>>>>>> 
>>>>>>> Here1s the weird part Ð and sorry there are so many caveats here Ð this
>>>>>>> is
>>>>>>> running from inside an ant task that I1ve written.  When I run it inside
>>>>>>> of
>>>>>>> the debugger or IDE (while not debugging) it works just fine.  When I
>>>>>>> run
>>>>>>> it
>>>>>>> via the command line I get the NPE every time.  I1m routing both
>>>>>>> attempts
>>>>>>> through an HTTP proxy (fiddler) and I can see that the HTTP request and
>>>>>>> response are the same in both cases , but in the one case Abdera throws
>>>>>>> the
>>>>>>> NPE.  I1ve been poking at this for several hours now and I1m at my wit1s
>>>>>>> end.  Here1s the stack trace I1m getting.  Any idea how I could further
>>>>>>> nail
>>>>>>> this down?
>>>>>>> 
>>>>>>> Caused by: java.lang.NullPointerException
>>>>>>>         at 
>>>>>>> org.apache.abdera.protocol.client.AbstractClientResponse.getDocument(Abs
>>>>>>> tr
>>>>>>> ac
>>>>>>> tClientResponse.java:96)
>>>>>>>         at 
>>>>>>> org.apache.abdera.protocol.client.AbstractClientResponse.getDocument(Abs
>>>>>>> tr
>>>>>>> ac
>>>>>>> tClientResponse.java:74)
>>>>>>>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>>>>>         at 
>>>>>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
>>>>>>> a:
>>>>>>> 39
>>>>>>> )
>>>>>>>         at 
>>>>>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
>>>>>>> Im
>>>>>>> pl
>>>>>>> .java:25)
>>>>>>>         at java.lang.reflect.Method.invoke(Method.java:585)
>>>>>>>         at 
>>>>>>> org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)
>>>>>>>         at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:226)
>>>>>>>         at 
>>>>>>> groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:910)
>>>>>>>         at 
>>>>>>> groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:754)
>>>>>>>         at 
>>>>>>> org.codehaus.groovy.runtime.InvokerHelper.invokePojoMethod(InvokerHelper
>>>>>>> .j
>>>>>>> av
>>>>>>> a:765)
>>>>>>>         at 
>>>>>>> org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.jav
>>>>>>> a:
>>>>>>> 75
>>>>>>> 3)
>>>>>>>         at 
>>>>>>> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBy
>>>>>>> te
>>>>>>> co
>>>>>>> deAdapter.java:167)
>>>>>>> 
>>>>>>> My best (and somewhat feeble) guess is that there1s something different
>>>>>>> in
>>>>>>> the class paths that is causing the difference in behavior.  What that
>>>>>>> might
>>>>>>> be, I have no idea.
>>>>>>> 
>>>>>>>   
>>>> 
>> 
>> 


Re: NullPointerException when calling ClientResponse.getDocument()

Posted by James M Snell <ja...@gmail.com>.
Ok, thank you for investigating further.  I've been having to devote the 
overwhelming majority of my time to completing a couple of day job 
projects so I haven't been able to investigate this.  Tomorrow I should 
be available in the afternoon to look it over and try to get it fixed. 
If you haven't done so already, please file an issue in Jira for this. 
It would also be helpful if you could provide or describe the test case 
so I can reproduce the error and verify the fix.

- James

Todd Wells wrote:
> Unfortunately, this problem is getting worse, but I think I know the
> fundamental problem (see below).
> 
> I went halfway down the roll-my-own route:  I grabbed the XML via HTTP and
> parsed it myself, then manually created a Abdera Entry in order to keep as
> much of my code unchanged as possible.
> 
> Alas, there is another NullPointerException, this time when I call
> abdera.newEntry()!
> 
> Caused by: java.lang.NullPointerException
>         at org.apache.abdera.Abdera.newEntry(Abdera.java:114)
> 
> The code at this line is very simple:
> 
>   return getFactory().newEntry();
> 
> So that means getFactory() is returning null -- indicating that in the
> Abdera class it is also possible to use getFactory() before factory is
> initialized (exactly analogous to getParser(), where the other NPE is
> thrown).  At this rate I'm going to need to rip out all my Abdera-dependent
> code.  
> 
> Looking at the code, I¹m pretty sure I know what¹s happening ‹ the
> constructor for Abdera is allowing a reference to ³this² to escape during
> construction.  In the constructor, Abdera calls out to newFactory(),
> newParser(), etc.  In those methods, it calls other methods passing ³this²
> as an argument. Since the constructor hasn¹t finished executing yet, ³this²
> is only a partially-constructed object at the point that these methods refer
> to it, and so the integrity of that object can¹t be guaranteed.   I followed
> one of those code paths down the rabbit hole and discovered that the
> classloader gets involved at some point, so you probably have a thread
> accessing the Abdera object before it¹s fully constructed.  For a more
> detailed explanation, see section 3.2.1 of Brian Goetz¹s book ³Java
> Concurrency in Practice², where he explicitly warns against this error.
> Actually, googling I see that he had an earlier article that discusses this
> same issue: http://www.ibm.com/developerworks/java/library/j-jtp0618.html
> 
> It may just be the speed of my machine or the JVM implementation (2 x 2.8
> GHz quad-core Xeon running OS X) that is causing the NPE to come up in this
> scenario, but the fact that ³this² is escaping during construction is a
> problem that will probably cause other people grief down the road.
> 
> 
> On 4/29/08 2:58 PM, "James M Snell" <ja...@gmail.com> wrote:
> 
>> I haven't yet had the opportunity to look at this today.  Hoping to be
>> able to look later this evening.
>>
>> - James
>>
>> Todd Wells wrote:
>>> I haven't heard any more feedback on this -- since the classpaths appear
>>> identical for practical purposes, do you think my supposition of a race
>>> condition is a good one?  Like I said previously, this is blocking my
>>> progress, so I wouldn't mind knowing one way or the other if somebody plans
>>> to investigate this further, so I can proceed with rolling my own if
>>> necessary.
>>>
>>> Thanks,
>>>
>>> -Todd
>>>
>>>
>>>
>>> On 4/28/08 4:21 PM, "Todd Wells" <to...@theplatform.com> wrote:
>>>
>>>> You bet.  For what it's worth, I changed my maven dependency to Abdera 0.3.0
>>>> and had the same problem.  I am suspecting this is a race condition of some
>>>> sort, because analyzing line 96 in AbstractClientResponse w
>>>> here the NullPointerException is thrown, it seems like it¹s probably calling
>>>> parser. getDefaultParserOptions() before parser is initialized--so it¹s
>>>> trying to call getDefaultParserOptions() on a null object.  It seems as if
>>>> Abdera is using the Parser in a multi-threaded fashion since the getParser()
>>>> method is synchronized  -- so I¹m suspecting a race condition between
>>>> threads somewhere where I¹m actually managing to call getDocument() before
>>>> the parser is initialized.
>>>>
>>>> I wrote a little code to munge the classpaths at the command line vs. in
>>>> IDEA, and it said that IDEA has the following things in the classpath that
>>>> ant doesn't:
>>>>
>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/../Classes/cha
>>>> rsets.jar
>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/../Classes/cla
>>>> sses.jar
>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/../Classes/dt.
>>>> jar
>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/../Classes/jce
>>>> .jar
>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/../Classes/jco
>>>> nsole.jar
>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/../Classes/jss
>>>> e.jar
>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/../Classes/laf
>>>> .jar
>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/../Classes/ui.
>>>> jar
>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/deploy.jar
>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/dt.jar
>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/ext/apple_
>>>> provider.jar
>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/ext/dnsns.
>>>> jar
>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/ext/locale
>>>> data.jar
>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/ext/sunjce
>>>> _provider.jar
>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/ext/sunpkc
>>>> s11.jar
>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/javaws.jar
>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/jce.jar
>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/plugin.jar
>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/sa-jdi.jar
>>>>
>>>> Since the command-line is using the same VM (the one built in to OS X), I¹ll
>>>> assume those VM jars are actually there implicitly.  There weren¹t any cases
>>>> where there were mis-matched versions of jars.  The only jar that the
>>>> command line class path included that isn¹t included in IDEA is the jar that
>>>> contains the code which is being developed in IDEA which is the code that
>>>> calls into Abdera (hence IDEA doesn¹t need a jar of it, it has the classes
>>>> directly).
>>>>
>>>> Below are the "raw" class paths -- they are big, my apologies in advance.
>>>>
>>>> Classpath from the command line (ant):
>>>>
>>>> /Users/todd.wells/.m2/repository/org/apache/maven/maven-artifact/2.0.2/maven
>>>> -artifact-2.0.2.jar:/Users/todd.wells/.m2/repository/org/springframework/spr
>>>> ing-beans/2.0.6/spring-beans-2.0.6.jar:/Users/todd.wells/.m2/repository/aopa
>>>> lliance/aopalliance/1.0/aopalliance-1.0.jar:/Users/todd.wells/.m2/repository
>>>> /org/apache/abdera/abdera-i18n/0.4.0-incubating/abdera-i18n-0.4.0-incubating
>>>> .jar:/Users/todd.wells/.m2/repository/org/apache/maven/maven-error-diagnosti
>>>> cs/2.0.2/maven-error-diagnostics-2.0.2.jar:/Users/todd.wells/.m2/repository/
>>>> commons-httpclient/commons-httpclient/3.1-rc1/commons-httpclient-3.1-rc1.jar
>>>> :/Users/todd.wells/.m2/repository/javax/servlet/servlet-api/2.4/servlet-api-
>>>> 2.4.jar:/Users/todd.wells/.m2/repository/commons-logging/commons-logging/1.0
>>>> .4/commons-logging-1.0.4.jar:/Users/todd.wells/.m2/repository/stax/stax-api/
>>>> 1.0.1/stax-api-1.0.1.jar:/Users/todd.wells/.m2/repository/log4j/log4j/1.2.13
>>>> /log4j-1.2.13.jar:/Users/todd.wells/.m2/repository/org/apache/abdera/abdera-
>>>> server/0.4.0-incubating/abdera-server-0.4.0-incubating.jar:/Users/todd.wells
>>>> /.m2/repository/com/theplatform/test/modules/wordgenerator/pl-test-wordgener
>>>> ator/1.0.0/pl-test-wordgenerator-1.0.0.jar:/Users/todd.wells/.m2/repository/
>>>> jaxen/jaxen/1.1.1/jaxen-1.1.1.jar:/Users/todd.wells/.m2/repository/org/apach
>>>> e/geronimo/specs/geronimo-stax-api_1.0_spec/1.0.1/geronimo-stax-api_1.0_spec
>>>> -1.0.1.jar:/Users/todd.wells/.m2/repository/org/springframework/spring-web/2
>>>> .0.6/spring-web-2.0.6.jar:/Users/todd.wells/.m2/repository/org/apache/maven/
>>>> maven-artifact-ant/2.0.4/maven-artifact-ant-2.0.4.jar:/Users/todd.wells/.m2/
>>>> repository/com/theplatform/modules/pl-galaxy/1.1.0-SNAPSHOT/pl-galaxy-1.1.0-
>>>> SNAPSHOT.jar:/Users/todd.wells/.m2/repository/xml-apis/xml-apis/1.3.03/xml-a
>>>> pis-1.3.03.jar:/Users/todd.wells/.m2/repository/commons-codec/commons-codec/
>>>> 1.3/commons-codec-1.3.jar:/Users/todd.wells/.m2/repository/org/codehaus/plex
>>>> us/plexus-container-default/1.0-alpha-9/plexus-container-default-1.0-alpha-9
>>>> .jar:/Users/todd.wells/.m2/repository/org/apache/maven/wagon/wagon-provider-
>>>> api/1.0-alpha-6/wagon-provider-api-1.0-alpha-6.jar:/Users/todd.wells/.m2/rep
>>>> ository/classworlds/classworlds/1.1-alpha-2/classworlds-1.1-alpha-2.jar:/Use
>>>> rs/todd.wells/.m2/repository/org/apache/ws/commons/axiom/axiom-impl/1.2.5/ax
>>>> iom-impl-1.2.5.jar:/Users/todd.wells/.m2/repository/org/springframework/spri
>>>> ng-core/2.0.6/spring-core-2.0.6.jar:/Users/todd.wells/.m2/repository/javax/m
>>>> ail/mail/1.4/mail-1.4.jar:/Users/todd.wells/.m2/repository/org/apache/abdera
>>>> /abdera-parser/0.4.0-incubating/abdera-parser-0.4.0-incubating.jar:/Users/to
>>>> dd.wells/.m2/repository/org/apache/maven/maven-artifact-manager/2.0.2/maven-
>>>> artifact-manager-2.0.2.jar:/Users/todd.wells/.m2/repository/org/apache/maven
>>>> /maven-project/2.0.2/maven-project-2.0.2.jar:/Users/todd.wells/.m2/repositor
>>>> y/org/apache/maven/maven-settings/2.0.2/maven-settings-2.0.2.jar:/Users/todd
>>>> .wells/.m2/repository/groovy/groovy-all/1.5.5/groovy-all-1.5.5.jar:/Users/to
>>>> dd.wells/.m2/repository/org/apache/maven/maven-model/2.0.2/maven-model-2.0.2
>>>> .jar:/Users/todd.wells/.m2/repository/org/apache/geronimo/specs/geronimo-act
>>>> ivation_1.0.2_spec/1.1/geronimo-activation_1.0.2_spec-1.1.jar:/Users/todd.we
>>>> lls/.m2/repository/org/codehaus/woodstox/wstx-asl/3.2.1/wstx-asl-3.2.1.jar:/
>>>> Users/todd.wells/.m2/repository/ant/ant/1.7/ant-1.7.jar:/Users/todd.wells/.m
>>>> 2/repository/org/springframework/spring-context/2.0.6/spring-context-2.0.6.j
>>>> ar:/Users/todd.wells/.m2/repository/org/apache/maven/maven-repository-metada
>>>> ta/2.0.2/maven-repository-metadata-2.0.2.jar:/Users/todd.wells/.m2/repositor
>>>> y/xalan/xalan/2.6.0/xalan-2.6.0.jar:/Users/todd.wells/.m2/repository/com/ibm
>>>> /icu/icu4j/2.6.1/icu4j-2.6.1.jar:/Users/todd.wells/.m2/repository/jdom/jdom/
>>>> 1.0/jdom-1.0.jar:/Users/todd.wells/.m2/repository/org/apache/abdera/abdera-s
>>>> pring/0.4.0-incubating/abdera-spring-0.4.0-incubating.jar:/Users/todd.wells/
>>>> .m2/repository/junit/junit/4.0/junit-4.0.jar:/Users/todd.wells/.m2/repositor
>>>> y/org/apache/maven/maven-profile/2.0.2/maven-profile-2.0.2.jar:/Users/todd.w
>>>> ells/.m2/repository/com/theplatform/test/modules/datehelper/pl-test-datehelp
>>>> er/1.0-SNAPSHOT/pl-test-datehelper-1.0-SNAPSHOT.jar:/Users/todd.wells/.m2/re
>>>> pository/javax/activation/activation/1.1/activation-1.1.jar:/Users/todd.well
>>>> s/.m2/repository/org/apache/ws/commons/axiom/axiom-api/1.2.5/axiom-api-1.2.5
>>>> .jar:/Users/todd.wells/.m2/repository/org/apache/maven/wagon/wagon-file/1.0-
>>>> alpha-7/wagon-file-1.0-alpha-7.jar:/Users/todd.wells/.m2/repository/org/code
>>>> haus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar:/Users/todd.wells/.m2/repo
>>>> sitory/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar:/Users/todd.wells/.m2/repository/an
>>>> t/ant-launcher/1.7/ant-launcher-1.7.jar:/Users/todd.wells/.m2/repository/xer
>>>> ces/xmlParserAPIs/2.6.2/xmlParserAPIs-2.6.2.jar:/Users/todd.wells/.m2/reposi
>>>> tory/xom/xom/1.0/xom-1.0.jar:/Users/todd.wells/.m2/repository/org/apache/abd
>>>> era/abdera-client/0.4.0-incubating/abdera-client-0.4.0-incubating.jar:/Users
>>>> /todd.wells/.m2/repository/org/apache/abdera/abdera-core/0.4.0-incubating/ab
>>>> dera-core-0.4.0-incubating.jar:/Users/todd.wells/.m2/repository/xerces/xerce
>>>> sImpl/2.8.0/xercesImpl-2.8.0.jar:/Users/todd.wells/.m2/repository/org/apache
>>>> /maven/wagon/wagon-http-lightweight/1.0-alpha-6/wagon-http-lightweight-1.0-a
>>>> lpha-6.jar
>>>>
>>>> Classpath in IDEA:
>>>>
>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/deploy.jar
>>>> :/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/dt.jar:/S
>>>> ystem/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/javaws.jar:/
>>>> System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/jce.jar:/Sy
>>>> stem/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/plugin.jar:/S
>>>> ystem/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/sa-jdi.jar:/
>>>> System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/../Classes/char
>>>> sets.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/../Cl
>>>> asses/classes.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.5/H
>>>> ome/../Classes/dt.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1
>>>> .5/Home/../Classes/jce.jar:/System/Library/Frameworks/JavaVM.framework/Versi
>>>> ons/1.5/Home/../Classes/jconsole.jar:/System/Library/Frameworks/JavaVM.frame
>>>> work/Versions/1.5/Home/../Classes/jsse.jar:/System/Library/Frameworks/JavaVM
>>>> .framework/Versions/1.5/Home/../Classes/laf.jar:/System/Library/Frameworks/J
>>>> avaVM.framework/Versions/1.5/Home/../Classes/ui.jar:/System/Library/Framewor
>>>> ks/JavaVM.framework/Versions/1.5/Home/lib/ext/apple_provider.jar:/System/Lib
>>>> rary/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/ext/dnsns.jar:/System
>>>> /Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/ext/localedata.ja
>>>> r:/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/ext/sunj
>>>> ce_provider.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Hom
>>>> e/lib/ext/sunpkcs11.jar:/depot/Tools/deploy/galaxy/main/target/classes:/User
>>>> s/todd.wells/.m2/repository/junit/junit/4.0/junit-4.0.jar:/Users/todd.wells/
>>>> .m2/repository/log4j/log4j/1.2.13/log4j-1.2.13.jar:/Users/todd.wells/.m2/rep
>>>> ository/com/theplatform/test/modules/wordgenerator/pl-test-wordgenerator/1.0
>>>> .0/pl-test-wordgenerator-1.0.0.jar:/Users/todd.wells/.m2/repository/com/thep
>>>> latform/test/modules/datehelper/pl-test-datehelper/1.0-SNAPSHOT/pl-test-date
>>>> helper-1.0-SNAPSHOT.jar:/Users/todd.wells/.m2/repository/org/apache/abdera/a
>>>> bdera-client/0.4.0-incubating/abdera-client-0.4.0-incubating.jar:/Users/todd
>>>> .wells/.m2/repository/org/apache/abdera/abdera-core/0.4.0-incubating/abdera-
>>>> core-0.4.0-incubating.jar:/Users/todd.wells/.m2/repository/org/apache/abdera
>>>> /abdera-i18n/0.4.0-incubating/abdera-i18n-0.4.0-incubating.jar:/Users/todd.w
>>>> ells/.m2/repository/org/apache/geronimo/specs/geronimo-activation_1.0.2_spec
>>>> /1.1/geronimo-activation_1.0.2_spec-1.1.jar:/Users/todd.wells/.m2/repository
>>>> /commons-codec/commons-codec/1.3/commons-codec-1.3.jar:/Users/todd.wells/.m2
>>>> /repository/org/apache/abdera/abdera-parser/0.4.0-incubating/abdera-parser-0
>>>> .4.0-incubating.jar:/Users/todd.wells/.m2/repository/org/apache/ws/commons/a
>>>> xiom/axiom-impl/1.2.5/axiom-impl-1.2.5.jar:/Users/todd.wells/.m2/repository/
>>>> org/apache/ws/commons/axiom/axiom-api/1.2.5/axiom-api-1.2.5.jar:/Users/todd.
>>>> wells/.m2/repository/commons-logging/commons-logging/1.0.4/commons-logging-1
>>>> .0.4.jar:/Users/todd.wells/.m2/repository/jaxen/jaxen/1.1.1/jaxen-1.1.1.jar:
>>>> /Users/todd.wells/.m2/repository/xerces/xercesImpl/2.8.0/xercesImpl-2.8.0.ja
>>>> r:/Users/todd.wells/.m2/repository/xml-apis/xml-apis/1.3.03/xml-apis-1.3.03.
>>>> jar:/Users/todd.wells/.m2/repository/org/apache/geronimo/specs/geronimo-stax
>>>> -api_1.0_spec/1.0.1/geronimo-stax-api_1.0_spec-1.0.1.jar:/Users/todd.wells/.
>>>> m2/repository/org/codehaus/woodstox/wstx-asl/3.2.1/wstx-asl-3.2.1.jar:/Users
>>>> /todd.wells/.m2/repository/commons-httpclient/commons-httpclient/3.1-rc1/com
>>>> mons-httpclient-3.1-rc1.jar:/Users/todd.wells/.m2/repository/org/apache/abde
>>>> ra/abdera-server/0.4.0-incubating/abdera-server-0.4.0-incubating.jar:/Users/
>>>> todd.wells/.m2/repository/javax/servlet/servlet-api/2.4/servlet-api-2.4.jar:
>>>> /Users/todd.wells/.m2/repository/org/apache/abdera/abdera-spring/0.4.0-incub
>>>> ating/abdera-spring-0.4.0-incubating.jar:/Users/todd.wells/.m2/repository/or
>>>> g/springframework/spring-web/2.0.6/spring-web-2.0.6.jar:/Users/todd.wells/.m
>>>> 2/repository/org/springframework/spring-beans/2.0.6/spring-beans-2.0.6.jar:/
>>>> Users/todd.wells/.m2/repository/org/springframework/spring-core/2.0.6/spring
>>>> -core-2.0.6.jar:/Users/todd.wells/.m2/repository/org/springframework/spring-
>>>> context/2.0.6/spring-context-2.0.6.jar:/Users/todd.wells/.m2/repository/aopa
>>>> lliance/aopalliance/1.0/aopalliance-1.0.jar:/Users/todd.wells/.m2/repository
>>>> /org/apache/maven/maven-artifact-ant/2.0.4/maven-artifact-ant-2.0.4.jar:/Use
>>>> rs/todd.wells/.m2/repository/org/apache/maven/maven-project/2.0.2/maven-proj
>>>> ect-2.0.2.jar:/Users/todd.wells/.m2/repository/org/apache/maven/maven-profil
>>>> e/2.0.2/maven-profile-2.0.2.jar:/Users/todd.wells/.m2/repository/org/apache/
>>>> maven/maven-model/2.0.2/maven-model-2.0.2.jar:/Users/todd.wells/.m2/reposito
>>>> ry/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar:/Users/todd.wel
>>>> ls/.m2/repository/org/codehaus/plexus/plexus-container-default/1.0-alpha-9/p
>>>> lexus-container-default-1.0-alpha-9.jar:/Users/todd.wells/.m2/repository/cla
>>>> ssworlds/classworlds/1.1-alpha-2/classworlds-1.1-alpha-2.jar:/Users/todd.wel
>>>> ls/.m2/repository/org/apache/maven/maven-artifact-manager/2.0.2/maven-artifa
>>>> ct-manager-2.0.2.jar:/Users/todd.wells/.m2/repository/org/apache/maven/maven
>>>> -repository-metadata/2.0.2/maven-repository-metadata-2.0.2.jar:/Users/todd.w
>>>> ells/.m2/repository/org/apache/maven/maven-artifact/2.0.2/maven-artifact-2.0
>>>> .2.jar:/Users/todd.wells/.m2/repository/org/apache/maven/wagon/wagon-provide
>>>> r-api/1.0-alpha-6/wagon-provider-api-1.0-alpha-6.jar:/Users/todd.wells/.m2/r
>>>> epository/org/apache/maven/maven-error-diagnostics/2.0.2/maven-error-diagnos
>>>> tics-2.0.2.jar:/Users/todd.wells/.m2/repository/org/apache/maven/maven-setti
>>>> ngs/2.0.2/maven-settings-2.0.2.jar:/Users/todd.wells/.m2/repository/org/apac
>>>> he/maven/wagon/wagon-file/1.0-alpha-7/wagon-file-1.0-alpha-7.jar:/Users/todd
>>>> .wells/.m2/repository/org/apache/maven/wagon/wagon-http-lightweight/1.0-alph
>>>> a-6/wagon-http-lightweight-1.0-alpha-6.jar:/Users/todd.wells/.m2/repository/
>>>> ant/ant/1.7/ant-1.7.jar:/Users/todd.wells/.m2/repository/groovy/groovy-all/1
>>>> .5.5/groovy-all-1.5.5.jar:/Users/todd.wells/.m2/repository/javax/mail/mail/1
>>>> .4/mail-1.4.jar:/Users/todd.wells/.m2/repository/javax/activation/activation
>>>> /1.1/activation-1.1.jar:/Users/todd.wells/.m2/repository/stax/stax-api/1.0.1
>>>> /stax-api-1.0.1.jar:/Users/todd.wells/.m2/repository/dom4j/dom4j/1.6.1/dom4j
>>>> -1.6.1.jar:/Users/todd.wells/.m2/repository/jdom/jdom/1.0/jdom-1.0.jar:/User
>>>> s/todd.wells/.m2/repository/xom/xom/1.0/xom-1.0.jar:/Users/todd.wells/.m2/re
>>>> pository/xerces/xmlParserAPIs/2.6.2/xmlParserAPIs-2.6.2.jar:/Users/todd.well
>>>> s/.m2/repository/xalan/xalan/2.6.0/xalan-2.6.0.jar:/Users/todd.wells/.m2/rep
>>>> ository/com/ibm/icu/icu4j/2.6.1/icu4j-2.6.1.jar:/Users/todd.wells/.m2/reposi
>>>> tory/ant/ant-launcher/1.7/ant-launcher-1.7.jar
>>>>
>>>>
>>>>
>>>>
>>>> On 4/28/08 2:56 PM, "Dan Diephouse" <da...@mulesource.com> wrote:
>>>>
>>>>> Well I'll be honest, I'm stumped too. This is with 0.4.0 right? Any
>>>>> chance you can print out the classpath?
>>>>>
>>>>> Dan
>>>>>
>>>>> Todd Wells wrote:
>>>>>> I1m stumped.  I have this repeatable case where
>>>>>> ClientResponse.getDocument()
>>>>>> results in a NullPointerException, even though a fully-formed atom
>>>>>> document
>>>>>> was successfully retrieved.
>>>>>>
>>>>>> Here1s the weird part Ð and sorry there are so many caveats here Ð this is
>>>>>> running from inside an ant task that I1ve written.  When I run it inside
>>>>>> of
>>>>>> the debugger or IDE (while not debugging) it works just fine.  When I run
>>>>>> it
>>>>>> via the command line I get the NPE every time.  I1m routing both attempts
>>>>>> through an HTTP proxy (fiddler) and I can see that the HTTP request and
>>>>>> response are the same in both cases , but in the one case Abdera throws
>>>>>> the
>>>>>> NPE.  I1ve been poking at this for several hours now and I1m at my wit1s
>>>>>> end.  Here1s the stack trace I1m getting.  Any idea how I could further
>>>>>> nail
>>>>>> this down?
>>>>>>
>>>>>> Caused by: java.lang.NullPointerException
>>>>>>         at 
>>>>>> org.apache.abdera.protocol.client.AbstractClientResponse.getDocument(Abstr
>>>>>> ac
>>>>>> tClientResponse.java:96)
>>>>>>         at 
>>>>>> org.apache.abdera.protocol.client.AbstractClientResponse.getDocument(Abstr
>>>>>> ac
>>>>>> tClientResponse.java:74)
>>>>>>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>>>>         at 
>>>>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
>>>>>> 39
>>>>>> )
>>>>>>         at 
>>>>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorIm
>>>>>> pl
>>>>>> .java:25)
>>>>>>         at java.lang.reflect.Method.invoke(Method.java:585)
>>>>>>         at 
>>>>>> org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)
>>>>>>         at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:226)
>>>>>>         at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:910)
>>>>>>         at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:754)
>>>>>>         at 
>>>>>> org.codehaus.groovy.runtime.InvokerHelper.invokePojoMethod(InvokerHelper.j
>>>>>> av
>>>>>> a:765)
>>>>>>         at 
>>>>>> org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:
>>>>>> 75
>>>>>> 3)
>>>>>>         at 
>>>>>> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptByte
>>>>>> co
>>>>>> deAdapter.java:167)
>>>>>>
>>>>>> My best (and somewhat feeble) guess is that there1s something different in
>>>>>> the class paths that is causing the difference in behavior.  What that
>>>>>> might
>>>>>> be, I have no idea.
>>>>>>
>>>>>>   
>>>
> 
> 

Re: NullPointerException when calling ClientResponse.getDocument()

Posted by James M Snell <ja...@gmail.com>.
Ok, thank you for investigating further.  I've been having to devote the 
overwhelming majority of my time to completing a couple of day job 
projects so I haven't been able to investigate this.  Tomorrow I should 
be available in the afternoon to look it over and try to get it fixed. 
If you haven't done so already, please file an issue in Jira for this. 
It would also be helpful if you could provide or describe the test case 
so I can reproduce the error and verify the fix.

- James

Todd Wells wrote:
> Unfortunately, this problem is getting worse, but I think I know the
> fundamental problem (see below).
> 
> I went halfway down the roll-my-own route:  I grabbed the XML via HTTP and
> parsed it myself, then manually created a Abdera Entry in order to keep as
> much of my code unchanged as possible.
> 
> Alas, there is another NullPointerException, this time when I call
> abdera.newEntry()!
> 
> Caused by: java.lang.NullPointerException
>         at org.apache.abdera.Abdera.newEntry(Abdera.java:114)
> 
> The code at this line is very simple:
> 
>   return getFactory().newEntry();
> 
> So that means getFactory() is returning null -- indicating that in the
> Abdera class it is also possible to use getFactory() before factory is
> initialized (exactly analogous to getParser(), where the other NPE is
> thrown).  At this rate I'm going to need to rip out all my Abdera-dependent
> code.  
> 
> Looking at the code, I¹m pretty sure I know what¹s happening ‹ the
> constructor for Abdera is allowing a reference to ³this² to escape during
> construction.  In the constructor, Abdera calls out to newFactory(),
> newParser(), etc.  In those methods, it calls other methods passing ³this²
> as an argument. Since the constructor hasn¹t finished executing yet, ³this²
> is only a partially-constructed object at the point that these methods refer
> to it, and so the integrity of that object can¹t be guaranteed.   I followed
> one of those code paths down the rabbit hole and discovered that the
> classloader gets involved at some point, so you probably have a thread
> accessing the Abdera object before it¹s fully constructed.  For a more
> detailed explanation, see section 3.2.1 of Brian Goetz¹s book ³Java
> Concurrency in Practice², where he explicitly warns against this error.
> Actually, googling I see that he had an earlier article that discusses this
> same issue: http://www.ibm.com/developerworks/java/library/j-jtp0618.html
> 
> It may just be the speed of my machine or the JVM implementation (2 x 2.8
> GHz quad-core Xeon running OS X) that is causing the NPE to come up in this
> scenario, but the fact that ³this² is escaping during construction is a
> problem that will probably cause other people grief down the road.
> 
> 
> On 4/29/08 2:58 PM, "James M Snell" <ja...@gmail.com> wrote:
> 
>> I haven't yet had the opportunity to look at this today.  Hoping to be
>> able to look later this evening.
>>
>> - James
>>
>> Todd Wells wrote:
>>> I haven't heard any more feedback on this -- since the classpaths appear
>>> identical for practical purposes, do you think my supposition of a race
>>> condition is a good one?  Like I said previously, this is blocking my
>>> progress, so I wouldn't mind knowing one way or the other if somebody plans
>>> to investigate this further, so I can proceed with rolling my own if
>>> necessary.
>>>
>>> Thanks,
>>>
>>> -Todd
>>>
>>>
>>>
>>> On 4/28/08 4:21 PM, "Todd Wells" <to...@theplatform.com> wrote:
>>>
>>>> You bet.  For what it's worth, I changed my maven dependency to Abdera 0.3.0
>>>> and had the same problem.  I am suspecting this is a race condition of some
>>>> sort, because analyzing line 96 in AbstractClientResponse w
>>>> here the NullPointerException is thrown, it seems like it¹s probably calling
>>>> parser. getDefaultParserOptions() before parser is initialized--so it¹s
>>>> trying to call getDefaultParserOptions() on a null object.  It seems as if
>>>> Abdera is using the Parser in a multi-threaded fashion since the getParser()
>>>> method is synchronized  -- so I¹m suspecting a race condition between
>>>> threads somewhere where I¹m actually managing to call getDocument() before
>>>> the parser is initialized.
>>>>
>>>> I wrote a little code to munge the classpaths at the command line vs. in
>>>> IDEA, and it said that IDEA has the following things in the classpath that
>>>> ant doesn't:
>>>>
>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/../Classes/cha
>>>> rsets.jar
>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/../Classes/cla
>>>> sses.jar
>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/../Classes/dt.
>>>> jar
>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/../Classes/jce
>>>> .jar
>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/../Classes/jco
>>>> nsole.jar
>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/../Classes/jss
>>>> e.jar
>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/../Classes/laf
>>>> .jar
>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/../Classes/ui.
>>>> jar
>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/deploy.jar
>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/dt.jar
>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/ext/apple_
>>>> provider.jar
>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/ext/dnsns.
>>>> jar
>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/ext/locale
>>>> data.jar
>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/ext/sunjce
>>>> _provider.jar
>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/ext/sunpkc
>>>> s11.jar
>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/javaws.jar
>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/jce.jar
>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/plugin.jar
>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/sa-jdi.jar
>>>>
>>>> Since the command-line is using the same VM (the one built in to OS X), I¹ll
>>>> assume those VM jars are actually there implicitly.  There weren¹t any cases
>>>> where there were mis-matched versions of jars.  The only jar that the
>>>> command line class path included that isn¹t included in IDEA is the jar that
>>>> contains the code which is being developed in IDEA which is the code that
>>>> calls into Abdera (hence IDEA doesn¹t need a jar of it, it has the classes
>>>> directly).
>>>>
>>>> Below are the "raw" class paths -- they are big, my apologies in advance.
>>>>
>>>> Classpath from the command line (ant):
>>>>
>>>> /Users/todd.wells/.m2/repository/org/apache/maven/maven-artifact/2.0.2/maven
>>>> -artifact-2.0.2.jar:/Users/todd.wells/.m2/repository/org/springframework/spr
>>>> ing-beans/2.0.6/spring-beans-2.0.6.jar:/Users/todd.wells/.m2/repository/aopa
>>>> lliance/aopalliance/1.0/aopalliance-1.0.jar:/Users/todd.wells/.m2/repository
>>>> /org/apache/abdera/abdera-i18n/0.4.0-incubating/abdera-i18n-0.4.0-incubating
>>>> .jar:/Users/todd.wells/.m2/repository/org/apache/maven/maven-error-diagnosti
>>>> cs/2.0.2/maven-error-diagnostics-2.0.2.jar:/Users/todd.wells/.m2/repository/
>>>> commons-httpclient/commons-httpclient/3.1-rc1/commons-httpclient-3.1-rc1.jar
>>>> :/Users/todd.wells/.m2/repository/javax/servlet/servlet-api/2.4/servlet-api-
>>>> 2.4.jar:/Users/todd.wells/.m2/repository/commons-logging/commons-logging/1.0
>>>> .4/commons-logging-1.0.4.jar:/Users/todd.wells/.m2/repository/stax/stax-api/
>>>> 1.0.1/stax-api-1.0.1.jar:/Users/todd.wells/.m2/repository/log4j/log4j/1.2.13
>>>> /log4j-1.2.13.jar:/Users/todd.wells/.m2/repository/org/apache/abdera/abdera-
>>>> server/0.4.0-incubating/abdera-server-0.4.0-incubating.jar:/Users/todd.wells
>>>> /.m2/repository/com/theplatform/test/modules/wordgenerator/pl-test-wordgener
>>>> ator/1.0.0/pl-test-wordgenerator-1.0.0.jar:/Users/todd.wells/.m2/repository/
>>>> jaxen/jaxen/1.1.1/jaxen-1.1.1.jar:/Users/todd.wells/.m2/repository/org/apach
>>>> e/geronimo/specs/geronimo-stax-api_1.0_spec/1.0.1/geronimo-stax-api_1.0_spec
>>>> -1.0.1.jar:/Users/todd.wells/.m2/repository/org/springframework/spring-web/2
>>>> .0.6/spring-web-2.0.6.jar:/Users/todd.wells/.m2/repository/org/apache/maven/
>>>> maven-artifact-ant/2.0.4/maven-artifact-ant-2.0.4.jar:/Users/todd.wells/.m2/
>>>> repository/com/theplatform/modules/pl-galaxy/1.1.0-SNAPSHOT/pl-galaxy-1.1.0-
>>>> SNAPSHOT.jar:/Users/todd.wells/.m2/repository/xml-apis/xml-apis/1.3.03/xml-a
>>>> pis-1.3.03.jar:/Users/todd.wells/.m2/repository/commons-codec/commons-codec/
>>>> 1.3/commons-codec-1.3.jar:/Users/todd.wells/.m2/repository/org/codehaus/plex
>>>> us/plexus-container-default/1.0-alpha-9/plexus-container-default-1.0-alpha-9
>>>> .jar:/Users/todd.wells/.m2/repository/org/apache/maven/wagon/wagon-provider-
>>>> api/1.0-alpha-6/wagon-provider-api-1.0-alpha-6.jar:/Users/todd.wells/.m2/rep
>>>> ository/classworlds/classworlds/1.1-alpha-2/classworlds-1.1-alpha-2.jar:/Use
>>>> rs/todd.wells/.m2/repository/org/apache/ws/commons/axiom/axiom-impl/1.2.5/ax
>>>> iom-impl-1.2.5.jar:/Users/todd.wells/.m2/repository/org/springframework/spri
>>>> ng-core/2.0.6/spring-core-2.0.6.jar:/Users/todd.wells/.m2/repository/javax/m
>>>> ail/mail/1.4/mail-1.4.jar:/Users/todd.wells/.m2/repository/org/apache/abdera
>>>> /abdera-parser/0.4.0-incubating/abdera-parser-0.4.0-incubating.jar:/Users/to
>>>> dd.wells/.m2/repository/org/apache/maven/maven-artifact-manager/2.0.2/maven-
>>>> artifact-manager-2.0.2.jar:/Users/todd.wells/.m2/repository/org/apache/maven
>>>> /maven-project/2.0.2/maven-project-2.0.2.jar:/Users/todd.wells/.m2/repositor
>>>> y/org/apache/maven/maven-settings/2.0.2/maven-settings-2.0.2.jar:/Users/todd
>>>> .wells/.m2/repository/groovy/groovy-all/1.5.5/groovy-all-1.5.5.jar:/Users/to
>>>> dd.wells/.m2/repository/org/apache/maven/maven-model/2.0.2/maven-model-2.0.2
>>>> .jar:/Users/todd.wells/.m2/repository/org/apache/geronimo/specs/geronimo-act
>>>> ivation_1.0.2_spec/1.1/geronimo-activation_1.0.2_spec-1.1.jar:/Users/todd.we
>>>> lls/.m2/repository/org/codehaus/woodstox/wstx-asl/3.2.1/wstx-asl-3.2.1.jar:/
>>>> Users/todd.wells/.m2/repository/ant/ant/1.7/ant-1.7.jar:/Users/todd.wells/.m
>>>> 2/repository/org/springframework/spring-context/2.0.6/spring-context-2.0.6.j
>>>> ar:/Users/todd.wells/.m2/repository/org/apache/maven/maven-repository-metada
>>>> ta/2.0.2/maven-repository-metadata-2.0.2.jar:/Users/todd.wells/.m2/repositor
>>>> y/xalan/xalan/2.6.0/xalan-2.6.0.jar:/Users/todd.wells/.m2/repository/com/ibm
>>>> /icu/icu4j/2.6.1/icu4j-2.6.1.jar:/Users/todd.wells/.m2/repository/jdom/jdom/
>>>> 1.0/jdom-1.0.jar:/Users/todd.wells/.m2/repository/org/apache/abdera/abdera-s
>>>> pring/0.4.0-incubating/abdera-spring-0.4.0-incubating.jar:/Users/todd.wells/
>>>> .m2/repository/junit/junit/4.0/junit-4.0.jar:/Users/todd.wells/.m2/repositor
>>>> y/org/apache/maven/maven-profile/2.0.2/maven-profile-2.0.2.jar:/Users/todd.w
>>>> ells/.m2/repository/com/theplatform/test/modules/datehelper/pl-test-datehelp
>>>> er/1.0-SNAPSHOT/pl-test-datehelper-1.0-SNAPSHOT.jar:/Users/todd.wells/.m2/re
>>>> pository/javax/activation/activation/1.1/activation-1.1.jar:/Users/todd.well
>>>> s/.m2/repository/org/apache/ws/commons/axiom/axiom-api/1.2.5/axiom-api-1.2.5
>>>> .jar:/Users/todd.wells/.m2/repository/org/apache/maven/wagon/wagon-file/1.0-
>>>> alpha-7/wagon-file-1.0-alpha-7.jar:/Users/todd.wells/.m2/repository/org/code
>>>> haus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar:/Users/todd.wells/.m2/repo
>>>> sitory/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar:/Users/todd.wells/.m2/repository/an
>>>> t/ant-launcher/1.7/ant-launcher-1.7.jar:/Users/todd.wells/.m2/repository/xer
>>>> ces/xmlParserAPIs/2.6.2/xmlParserAPIs-2.6.2.jar:/Users/todd.wells/.m2/reposi
>>>> tory/xom/xom/1.0/xom-1.0.jar:/Users/todd.wells/.m2/repository/org/apache/abd
>>>> era/abdera-client/0.4.0-incubating/abdera-client-0.4.0-incubating.jar:/Users
>>>> /todd.wells/.m2/repository/org/apache/abdera/abdera-core/0.4.0-incubating/ab
>>>> dera-core-0.4.0-incubating.jar:/Users/todd.wells/.m2/repository/xerces/xerce
>>>> sImpl/2.8.0/xercesImpl-2.8.0.jar:/Users/todd.wells/.m2/repository/org/apache
>>>> /maven/wagon/wagon-http-lightweight/1.0-alpha-6/wagon-http-lightweight-1.0-a
>>>> lpha-6.jar
>>>>
>>>> Classpath in IDEA:
>>>>
>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/deploy.jar
>>>> :/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/dt.jar:/S
>>>> ystem/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/javaws.jar:/
>>>> System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/jce.jar:/Sy
>>>> stem/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/plugin.jar:/S
>>>> ystem/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/sa-jdi.jar:/
>>>> System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/../Classes/char
>>>> sets.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/../Cl
>>>> asses/classes.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.5/H
>>>> ome/../Classes/dt.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1
>>>> .5/Home/../Classes/jce.jar:/System/Library/Frameworks/JavaVM.framework/Versi
>>>> ons/1.5/Home/../Classes/jconsole.jar:/System/Library/Frameworks/JavaVM.frame
>>>> work/Versions/1.5/Home/../Classes/jsse.jar:/System/Library/Frameworks/JavaVM
>>>> .framework/Versions/1.5/Home/../Classes/laf.jar:/System/Library/Frameworks/J
>>>> avaVM.framework/Versions/1.5/Home/../Classes/ui.jar:/System/Library/Framewor
>>>> ks/JavaVM.framework/Versions/1.5/Home/lib/ext/apple_provider.jar:/System/Lib
>>>> rary/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/ext/dnsns.jar:/System
>>>> /Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/ext/localedata.ja
>>>> r:/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/lib/ext/sunj
>>>> ce_provider.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Hom
>>>> e/lib/ext/sunpkcs11.jar:/depot/Tools/deploy/galaxy/main/target/classes:/User
>>>> s/todd.wells/.m2/repository/junit/junit/4.0/junit-4.0.jar:/Users/todd.wells/
>>>> .m2/repository/log4j/log4j/1.2.13/log4j-1.2.13.jar:/Users/todd.wells/.m2/rep
>>>> ository/com/theplatform/test/modules/wordgenerator/pl-test-wordgenerator/1.0
>>>> .0/pl-test-wordgenerator-1.0.0.jar:/Users/todd.wells/.m2/repository/com/thep
>>>> latform/test/modules/datehelper/pl-test-datehelper/1.0-SNAPSHOT/pl-test-date
>>>> helper-1.0-SNAPSHOT.jar:/Users/todd.wells/.m2/repository/org/apache/abdera/a
>>>> bdera-client/0.4.0-incubating/abdera-client-0.4.0-incubating.jar:/Users/todd
>>>> .wells/.m2/repository/org/apache/abdera/abdera-core/0.4.0-incubating/abdera-
>>>> core-0.4.0-incubating.jar:/Users/todd.wells/.m2/repository/org/apache/abdera
>>>> /abdera-i18n/0.4.0-incubating/abdera-i18n-0.4.0-incubating.jar:/Users/todd.w
>>>> ells/.m2/repository/org/apache/geronimo/specs/geronimo-activation_1.0.2_spec
>>>> /1.1/geronimo-activation_1.0.2_spec-1.1.jar:/Users/todd.wells/.m2/repository
>>>> /commons-codec/commons-codec/1.3/commons-codec-1.3.jar:/Users/todd.wells/.m2
>>>> /repository/org/apache/abdera/abdera-parser/0.4.0-incubating/abdera-parser-0
>>>> .4.0-incubating.jar:/Users/todd.wells/.m2/repository/org/apache/ws/commons/a
>>>> xiom/axiom-impl/1.2.5/axiom-impl-1.2.5.jar:/Users/todd.wells/.m2/repository/
>>>> org/apache/ws/commons/axiom/axiom-api/1.2.5/axiom-api-1.2.5.jar:/Users/todd.
>>>> wells/.m2/repository/commons-logging/commons-logging/1.0.4/commons-logging-1
>>>> .0.4.jar:/Users/todd.wells/.m2/repository/jaxen/jaxen/1.1.1/jaxen-1.1.1.jar:
>>>> /Users/todd.wells/.m2/repository/xerces/xercesImpl/2.8.0/xercesImpl-2.8.0.ja
>>>> r:/Users/todd.wells/.m2/repository/xml-apis/xml-apis/1.3.03/xml-apis-1.3.03.
>>>> jar:/Users/todd.wells/.m2/repository/org/apache/geronimo/specs/geronimo-stax
>>>> -api_1.0_spec/1.0.1/geronimo-stax-api_1.0_spec-1.0.1.jar:/Users/todd.wells/.
>>>> m2/repository/org/codehaus/woodstox/wstx-asl/3.2.1/wstx-asl-3.2.1.jar:/Users
>>>> /todd.wells/.m2/repository/commons-httpclient/commons-httpclient/3.1-rc1/com
>>>> mons-httpclient-3.1-rc1.jar:/Users/todd.wells/.m2/repository/org/apache/abde
>>>> ra/abdera-server/0.4.0-incubating/abdera-server-0.4.0-incubating.jar:/Users/
>>>> todd.wells/.m2/repository/javax/servlet/servlet-api/2.4/servlet-api-2.4.jar:
>>>> /Users/todd.wells/.m2/repository/org/apache/abdera/abdera-spring/0.4.0-incub
>>>> ating/abdera-spring-0.4.0-incubating.jar:/Users/todd.wells/.m2/repository/or
>>>> g/springframework/spring-web/2.0.6/spring-web-2.0.6.jar:/Users/todd.wells/.m
>>>> 2/repository/org/springframework/spring-beans/2.0.6/spring-beans-2.0.6.jar:/
>>>> Users/todd.wells/.m2/repository/org/springframework/spring-core/2.0.6/spring
>>>> -core-2.0.6.jar:/Users/todd.wells/.m2/repository/org/springframework/spring-
>>>> context/2.0.6/spring-context-2.0.6.jar:/Users/todd.wells/.m2/repository/aopa
>>>> lliance/aopalliance/1.0/aopalliance-1.0.jar:/Users/todd.wells/.m2/repository
>>>> /org/apache/maven/maven-artifact-ant/2.0.4/maven-artifact-ant-2.0.4.jar:/Use
>>>> rs/todd.wells/.m2/repository/org/apache/maven/maven-project/2.0.2/maven-proj
>>>> ect-2.0.2.jar:/Users/todd.wells/.m2/repository/org/apache/maven/maven-profil
>>>> e/2.0.2/maven-profile-2.0.2.jar:/Users/todd.wells/.m2/repository/org/apache/
>>>> maven/maven-model/2.0.2/maven-model-2.0.2.jar:/Users/todd.wells/.m2/reposito
>>>> ry/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar:/Users/todd.wel
>>>> ls/.m2/repository/org/codehaus/plexus/plexus-container-default/1.0-alpha-9/p
>>>> lexus-container-default-1.0-alpha-9.jar:/Users/todd.wells/.m2/repository/cla
>>>> ssworlds/classworlds/1.1-alpha-2/classworlds-1.1-alpha-2.jar:/Users/todd.wel
>>>> ls/.m2/repository/org/apache/maven/maven-artifact-manager/2.0.2/maven-artifa
>>>> ct-manager-2.0.2.jar:/Users/todd.wells/.m2/repository/org/apache/maven/maven
>>>> -repository-metadata/2.0.2/maven-repository-metadata-2.0.2.jar:/Users/todd.w
>>>> ells/.m2/repository/org/apache/maven/maven-artifact/2.0.2/maven-artifact-2.0
>>>> .2.jar:/Users/todd.wells/.m2/repository/org/apache/maven/wagon/wagon-provide
>>>> r-api/1.0-alpha-6/wagon-provider-api-1.0-alpha-6.jar:/Users/todd.wells/.m2/r
>>>> epository/org/apache/maven/maven-error-diagnostics/2.0.2/maven-error-diagnos
>>>> tics-2.0.2.jar:/Users/todd.wells/.m2/repository/org/apache/maven/maven-setti
>>>> ngs/2.0.2/maven-settings-2.0.2.jar:/Users/todd.wells/.m2/repository/org/apac
>>>> he/maven/wagon/wagon-file/1.0-alpha-7/wagon-file-1.0-alpha-7.jar:/Users/todd
>>>> .wells/.m2/repository/org/apache/maven/wagon/wagon-http-lightweight/1.0-alph
>>>> a-6/wagon-http-lightweight-1.0-alpha-6.jar:/Users/todd.wells/.m2/repository/
>>>> ant/ant/1.7/ant-1.7.jar:/Users/todd.wells/.m2/repository/groovy/groovy-all/1
>>>> .5.5/groovy-all-1.5.5.jar:/Users/todd.wells/.m2/repository/javax/mail/mail/1
>>>> .4/mail-1.4.jar:/Users/todd.wells/.m2/repository/javax/activation/activation
>>>> /1.1/activation-1.1.jar:/Users/todd.wells/.m2/repository/stax/stax-api/1.0.1
>>>> /stax-api-1.0.1.jar:/Users/todd.wells/.m2/repository/dom4j/dom4j/1.6.1/dom4j
>>>> -1.6.1.jar:/Users/todd.wells/.m2/repository/jdom/jdom/1.0/jdom-1.0.jar:/User
>>>> s/todd.wells/.m2/repository/xom/xom/1.0/xom-1.0.jar:/Users/todd.wells/.m2/re
>>>> pository/xerces/xmlParserAPIs/2.6.2/xmlParserAPIs-2.6.2.jar:/Users/todd.well
>>>> s/.m2/repository/xalan/xalan/2.6.0/xalan-2.6.0.jar:/Users/todd.wells/.m2/rep
>>>> ository/com/ibm/icu/icu4j/2.6.1/icu4j-2.6.1.jar:/Users/todd.wells/.m2/reposi
>>>> tory/ant/ant-launcher/1.7/ant-launcher-1.7.jar
>>>>
>>>>
>>>>
>>>>
>>>> On 4/28/08 2:56 PM, "Dan Diephouse" <da...@mulesource.com> wrote:
>>>>
>>>>> Well I'll be honest, I'm stumped too. This is with 0.4.0 right? Any
>>>>> chance you can print out the classpath?
>>>>>
>>>>> Dan
>>>>>
>>>>> Todd Wells wrote:
>>>>>> I1m stumped.  I have this repeatable case where
>>>>>> ClientResponse.getDocument()
>>>>>> results in a NullPointerException, even though a fully-formed atom
>>>>>> document
>>>>>> was successfully retrieved.
>>>>>>
>>>>>> Here1s the weird part Ð and sorry there are so many caveats here Ð this is
>>>>>> running from inside an ant task that I1ve written.  When I run it inside
>>>>>> of
>>>>>> the debugger or IDE (while not debugging) it works just fine.  When I run
>>>>>> it
>>>>>> via the command line I get the NPE every time.  I1m routing both attempts
>>>>>> through an HTTP proxy (fiddler) and I can see that the HTTP request and
>>>>>> response are the same in both cases , but in the one case Abdera throws
>>>>>> the
>>>>>> NPE.  I1ve been poking at this for several hours now and I1m at my wit1s
>>>>>> end.  Here1s the stack trace I1m getting.  Any idea how I could further
>>>>>> nail
>>>>>> this down?
>>>>>>
>>>>>> Caused by: java.lang.NullPointerException
>>>>>>         at 
>>>>>> org.apache.abdera.protocol.client.AbstractClientResponse.getDocument(Abstr
>>>>>> ac
>>>>>> tClientResponse.java:96)
>>>>>>         at 
>>>>>> org.apache.abdera.protocol.client.AbstractClientResponse.getDocument(Abstr
>>>>>> ac
>>>>>> tClientResponse.java:74)
>>>>>>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>>>>         at 
>>>>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
>>>>>> 39
>>>>>> )
>>>>>>         at 
>>>>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorIm
>>>>>> pl
>>>>>> .java:25)
>>>>>>         at java.lang.reflect.Method.invoke(Method.java:585)
>>>>>>         at 
>>>>>> org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)
>>>>>>         at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:226)
>>>>>>         at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:910)
>>>>>>         at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:754)
>>>>>>         at 
>>>>>> org.codehaus.groovy.runtime.InvokerHelper.invokePojoMethod(InvokerHelper.j
>>>>>> av
>>>>>> a:765)
>>>>>>         at 
>>>>>> org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:
>>>>>> 75
>>>>>> 3)
>>>>>>         at 
>>>>>> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptByte
>>>>>> co
>>>>>> deAdapter.java:167)
>>>>>>
>>>>>> My best (and somewhat feeble) guess is that there1s something different in
>>>>>> the class paths that is causing the difference in behavior.  What that
>>>>>> might
>>>>>> be, I have no idea.
>>>>>>
>>>>>>   
>>>
> 
>