abdera-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Calavera" <david.calav...@gmail.com>
Subject Re: Not able to POST in the employee example
Date Mon, 26 May 2008 10:55:48 GMT
Hi Arjun, are you sure that your entry is well formed? try to format your
xml file input because I'm trying to reproduce it but with the trunk code it
works fine. I endose you my test:

@Test
    public void testGetEntryFromRequest() throws Exception {
        StringReader reader = new StringReader("<?xml version=\"1.0\"?>"
                + "<entry><link href=\"/employee/3-Third_Employee\""
                + " rel=\"edit\"></link><id>feed-3</id><title
type=\"text\">3"
                +
"Employee</title><updated>2008-05-26T05:49:03.453Z</updated><author><name>Acme"
                + "Industries</name></author><content type=\"text\">Third"
                + "Employee</content></entry>");
        InputStream customReader = new CustomReaderInputStream(reader);


        Abdera abdera = new Abdera();

        Parser parser = abdera.getParser();
        Document<Entry>  entry = parser.parse(customReader, "/collection",
parser.getDefaultParserOptions());
        assertNotNull(entry.clone());
    }

    private class CustomReaderInputStream extends InputStream {

        Reader reader;
        public CustomReaderInputStream(Reader reader) {
            this.reader = reader;
        }

        @Override
        public int read() throws IOException {
            return reader.read();
        }

    }

Your stacktrace shows that the method "entry.clone()" raises an exception
but in my test it railses nothing.

On Mon, May 26, 2008 at 9:33 AM, Arjun Sharma <toarjun@gmail.com> wrote:

> Hi
> I am trying to work with the Employee example of Abdera Servlet. GET method
> works fine. But when i try to POST or PUT I am getting the following
> exceptions:
>
>     [java] Method:    POST
>     [java] May 26, 2008 12:57:31 PM
> org.apache.abdera.protocol.server.impl.Abst
> ractCollectionAdapter createErrorResponse
>     [java] INFO: A ResponseException was thrown.
>     [java]
> org.apache.abdera.protocol.server.context.ResponseContextException
>     [java]     at
> org.apache.abdera.protocol.server.impl.AbstractCollectionAdap
> ter.getEntryFromRequest(AbstractCollectionAdapter.java:247)
>     [java]     at
> org.apache.abdera.protocol.server.impl.AbstractEntityCollecti
> onAdapter.postEntry(AbstractEntityCollectionAdapter.java:142)
>     [java]     at
> org.apache.abdera.protocol.server.impl.AbstractProvider.proce
> ss(AbstractProvider.java:147)
>     [java]     at
> org.apache.abdera.protocol.server.FilterChain.next(FilterChai
> n.java:42)
>     [java]     at
> org.apache.abdera.protocol.server.servlet.AbderaServlet.servi
> ce(Unknown Source)
>     [java]     at
> javax.servlet.http.HttpServlet.service(HttpServlet.java:688)
>     [java]     at
> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.
> java:487)
>     [java]     at
> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandle
> r.java:367)
>     [java]     at
> org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandle
> r.java:181)
>     [java]     at
> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandle
> r.java:712)
>     [java]     at
> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrappe
> r.java:139)
>     [java]     at org.mortbay.jetty.Server.handle(Server.java:285)
>     [java]     at
> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection
> .java:502)
>     [java]     at
> org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpC
> onnection.java:835)
>     [java]     at
> org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:641)
>     [java]     at
> org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:2
> 08)
>     [java]     at
> org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:3
> 78)
>     [java]     at
> org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketCo
> nnector.java:226)
>     [java]     at
> org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedTh
> readPool.java:442)
>     [java] Caused by: org.apache.abdera.parser.ParseException:
> javax.xml.stream
> .XMLStreamException: ParseError at [row,col]:[2,18]
>     [java] Message: XML document structures must start and end within the
> same
> entity.
>     [java]     at
> org.apache.abdera.parser.stax.FOMBuilder.next(FOMBuilder.java
> :260)
>     [java]     at
> org.apache.axiom.om.impl.llom.OMElementImpl.getNextOMSibling(
> OMElementImpl.java:265)
>     [java]     at
> org.apache.axiom.om.impl.traverse.OMChildrenIterator.next(OMC
> hildrenIterator.java:106)
>     [java]     at
> org.apache.abdera.parser.stax.FOMDocument.clone(FOMDocument.j
> ava:229)
>     [java]     at
> org.apache.abdera.protocol.server.impl.AbstractCollectionAdap
> ter.getEntryFromRequest(AbstractCollectionAdapter.java:245)
>     [java]     ... 18 more
>     [java] Caused by: javax.xml.stream.XMLStreamException: ParseError at
> [row,c
> ol]:[2,18]
>     [java] Message: XML document structures must start and end within the
> same
> entity.
>     [java]     at
> com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.n
> ext(XMLStreamReaderImpl.java:588)
>     [java]     at
> org.apache.abdera.parser.stax.FOMBuilder.getNextElementToPars
> e(FOMBuilder.java:163)
>     [java]     at
> org.apache.abdera.parser.stax.FOMBuilder.next(FOMBuilder.java
> :187)
>     [java]     ... 22 more
>
>
> My entry.xml which contains the entry to POST is:
> <?xml version="1.0"?>
> <entry><link href="/employee/3-Third_Employee"
> rel="edit"></link><id>feed-3</id><title type="text">3
>
> Employee</title><updated>2008-05-26T05:49:03.453Z</updated><author><name>Acme
> Industries</name></author><content type="text">Third
> Employee</content></entry>
>
> --
> Arjun Sharma S
>



-- 
David Calavera
http://www.thinkincode.net

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message