Yeah, I can now see where the problem is.  This property has a
getBodyPart(i) method, but no getBodyPart(), so the
propertyDescriptor.getPropertyType() call returns null.  JXPath is not
prepared to handle this.

I'll check a fix in tonight.  You will need to switch to the nightly
build temporarily.

Thanks for reporting the bug.

- Dmitri

--- Stephan Mikaty <[EMAIL PROTECTED]> wrote:
> Hi there,
> 
> Thanks for the reply. I tried to use 1 instead of 0,
> to no avail. The exception is identical to the one
> i submitted previously. Here is a test case that
> exhibits the problem:
> 
>     public void testJXPath() throws Exception {
>         BodyPart textPart = new MimeBodyPart();
>         textPart.setContent("plain", "text/plain");
>         MimeMultipart mp = new MimeMultipart("alternative");
>         mp.addBodyPart(textPart);
>         assertEquals(1, mp.getCount());
>         assertEquals("text/plain",
> mp.getBodyPart(0).getContentType());
>         
>         JXPathContext ctx = JXPathContext.newContext(mp);
>         assertEquals(new Integer(1), ctx.getValue("count"));
> !!!!    assertEquals("text/plain",
> ctx.getValue("bodyPart[1]/contentType"));
> // Failure here
>     }
> 
> I have to stress that i didn't write any special (X)BeanInfo for
> any of the classes in the standard javax.mail package. When stepping
> through the code, "bodyPart" is correctly discovered as an indexed
> property, so i'm at a loss as to what causes the problem.
> 
> The version i tested this on was commons-jxpath-1.1.
> 
> Stephane
> 
> > -----Ursprungliche Nachricht-----
> > Von: Dmitri Plotnikov [mailto:[EMAIL PROTECTED]
> > Gesendet: Freitag, 13. Juni 2003 23:07
> > An: Jakarta Commons Users List
> > Betreff: Re: [jxpath] querying a javamail Message
> > 
> > 
> > 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(Va
> > lueUtils.java:
> > > 112)
> > >   at
> > >
> > org.apache.commons.jxpath.ri.model.beans.BeanPropertyPointer.i
> > sCollection(Be
> > > anPropertyPointer.java:201)
> > >   at
> > >
> > org.apache.commons.jxpath.ri.axes.SimplePathInterpreter.isColl
> > ectionElement(
> > > SimplePathInterpreter.java:770)
> > >   at
> > >
> > org.apache.commons.jxpath.ri.axes.SimplePathInterpreter.doPred
> > icateIndex(Sim
> > > plePathInterpreter.java:674)
> > >   at
> > >
> > org.apache.commons.jxpath.ri.axes.SimplePathInterpreter.doPred
> > icate(SimplePa
> > > thInterpreter.java:487)
> > >   at
> > >
> > org.apache.commons.jxpath.ri.axes.SimplePathInterpreter.doStep
> > PredicatesProp
> > > 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.doStep
> > NoPredicatesPr
> > > 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.interp
> > retSimpleLocat
> > > ionPath(SimplePathInterpreter.java:122)
> > >   at
> > >
> > org.apache.commons.jxpath.ri.compiler.Path.getSingleNodePointe
> > rForSteps(Path
> > > .java:186)
> > >   at
> > >
> > org.apache.commons.jxpath.ri.compiler.LocationPath.computeValu
> > e(LocationPath
> > > .java:128)
> > >   at
> > >
> > org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.getVal
> > ue(JXPathConte
> > > xtReferenceImpl.java:287)
> > >   at
> > >
> > org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.getVal
> > ue(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]
> > 


__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

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

Reply via email to