Stephan,

Sorry about the horrible error message.  I'll change it to print
something more comprehensible.

The obvious problem is that you are using 0 instead of 1 to access the
first element of the collection (I know, I know... I hate that too. But
it's XPath standard - what are you gonna do?)

I hope this helps.

- Dmitri


--- Stephan Mikaty <[EMAIL PROTECTED]> wrote:
> Hi everyone, 
> 
> I've been trying to use xpath expressions against
> a javax.mail.internet.MimeMessage with attachments.
> Thi allows me to shorten my junit test cases:
> 
> JXPathContext ctx = JXPathContext.newContext(message);
> assertEquals("text/plain",
> ctx.getValue("content/bodyPart[0]/contentType"));
> 
> I get the following trace:
> 
> java.lang.NullPointerException
>       at
>
org.apache.commons.jxpath.util.ValueUtils.getCollectionHint(ValueUtils.java:
> 112)
>       at
>
org.apache.commons.jxpath.ri.model.beans.BeanPropertyPointer.isCollection(Be
> anPropertyPointer.java:201)
>       at
>
org.apache.commons.jxpath.ri.axes.SimplePathInterpreter.isCollectionElement(
> SimplePathInterpreter.java:770)
>       at
>
org.apache.commons.jxpath.ri.axes.SimplePathInterpreter.doPredicateIndex(Sim
> plePathInterpreter.java:674)
>       at
>
org.apache.commons.jxpath.ri.axes.SimplePathInterpreter.doPredicate(SimplePa
> thInterpreter.java:487)
>       at
>
org.apache.commons.jxpath.ri.axes.SimplePathInterpreter.doStepPredicatesProp
> ertyOwner(SimplePathInterpreter.java:353)
>       at
>
org.apache.commons.jxpath.ri.axes.SimplePathInterpreter.doStep(SimplePathInt
> erpreter.java:194)
>       at
>
org.apache.commons.jxpath.ri.axes.SimplePathInterpreter.doStepNoPredicatesPr
> opertyOwner(SimplePathInterpreter.java:276)
>       at
>
org.apache.commons.jxpath.ri.axes.SimplePathInterpreter.doStep(SimplePathInt
> erpreter.java:187)
>       at
>
org.apache.commons.jxpath.ri.axes.SimplePathInterpreter.interpretSimpleLocat
> ionPath(SimplePathInterpreter.java:122)
>       at
>
org.apache.commons.jxpath.ri.compiler.Path.getSingleNodePointerForSteps(Path
> .java:186)
>       at
>
org.apache.commons.jxpath.ri.compiler.LocationPath.computeValue(LocationPath
> .java:128)
>       at
>
org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.getValue(JXPathConte
> xtReferenceImpl.java:287)
>       at
>
org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.getValue(JXPathConte
> xtReferenceImpl.java:283)
> 
> 
> Am i doing something wrong? I looked a the code and tried a few
> changes,
> but couldn't come up with any obvious fix.
> 
> Any help appreciated,
> 
> Stephane
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to