Hi there,

This is weird indeed. Which HTTP server connector were you using?

I suggest trying again with a recent snapshot as we fixed some related
issues recently. There is also the Restlet extension for JAXB that you might
want to leverage.

Best regards,
Jerome Louvel
--
Restlet ~ Founder and Technical Lead ~ http://www.restlet.org
Noelios Technologies ~ http://www.noelios.com




-----Message d'origine-----
De : webp...@tigris.org [mailto:webp...@tigris.org] 
Envoyé : vendredi 23 avril 2010 14:05
À : discuss@restlet.tigris.org
Objet : getRequestEntity().getStream() -> Premature end of file.

Hi everyone,

I'm using restlet-2.0 SNAPSHOT from the 15 feb 2010. I have a resource with
this code :
== 8< =========================================================
  @Post("xml")
  public Representation create() throws ResourceException {
    try {
      InputStream in = getRequestEntity().getStream();
      JAXBContext context =
JAXBContext.newInstance(TemplateCreateQuery.class);
      TemplateCreateQuery query = (TemplateCreateQuery) context
          .createUnmarshaller().unmarshal(in);
      ...
  }
---------------------------------------------------------------

But the "unmarshal(in)" methd always throw an exeception with the message
"Premature end of file" (full trace is attached to this question).
For debugging purpose, I have put the stream content in a StringBuffer and
now, the exeception is never thrown.. 

== 8< =========================================================
  @Post("xml")
  public Representation create() throws ResourceException {
    try {
      InputStream in = getRequestEntity().getStream();
      BufferedReader br = new BufferedReader(new InputStreamReader(in));
      String line;
      StringBuffer content = new StringBuffer();
      while ( (line = br.readLine())!=null )
        content.append(line);
      JAXBContext context =
JAXBContext.newInstance(TemplateCreateQuery.class);
      TemplateCreateQuery query = (TemplateCreateQuery) context
          .createUnmarshaller().unmarshal(new
StringReader(content.toString()));
      ...
  }
---------------------------------------------------------------

I absolutely understand nothing.. Can you help me ?

Thanks

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=25934
47

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2611179

Reply via email to