Paul,
thank you for this idea! I replaced HttpServer by Grizzly and now it works perfectly (no more result of -1 but always 204 as expected). :-)
Regards
Markus
> -----Original Message-----
> From: Paul.Sandoz_at_Sun.COM [mailto:Paul.Sandoz_at_Sun.COM]
> Sent: Freitag, 19. Dezember 2008 09:19
> To: dev_at_jersey.dev.java.net
> Subject: Re: [Jersey] HTTP Result Code "-1"
>
>
> On Dec 18, 2008, at 8:00 PM, Markus KARG wrote:
>
> > Paul,
> >
> > thank you for helping us. More inlined. :-)
> >
> >> What standalone server are you using? the LW HTTP server? Is the
> >> server side handling concurrent requests from multiple clients?
> >
> > The standalone server is this small piece of code:
> >
> > import com.sun.jersey.api.container.httpserver.HttpServerFactory;
> > import com.sun.net.httpserver.HttpServer;
> > public final class Main {
> > public static final void main(final String[] args) throws
> > IOException,
> > InterruptedException {
> > final HttpServer server =
> > HttpServerFactory.create("http://localhost:80/");
> > server.start();
> > Thread.sleep(Long.MAX_VALUE);
> > }
> > }
> >
>
> I recommend you try with the Grizzly container instead. In the past we
> have found using the LW HTTP server to be very unreliable, we have
> disabled the automatic testing because it can lock up, and i never run
> it on the Mac because of locking up.
>
> You can do:
>
> final SelectorThread st =
> GrizzlyServerFactory.create("http://localhost:80/
> ")
> Thread.sleep(Long.MAX_VALUE);
>
> which also starts the Grizzly server.
>
>
> > The @PUT method is this one:
> >
> > @PUT
> > @Path("/quipsy/manufacturedAmount/{fileName}.xml")
> > @Consumes("application/manufacturedAmountXML+xml")
> > public void putPpm(final InputStream ppm) throws IOException {
> > for (int c = ppm.read(); c != -1; c = ppm.read())
> > System.out.print((char) c);
> > System.out.println();
> > }
> >
> > As you can see, it is the at-most simple code that I could imagine.
> > Also the
> > last "System.out.println" actually is printed, so it cannot be a bug
> > inside
> > of the putPpm method.
> >
> >> My guess is it is more likely to be a bug in the standalone server
> >> (or
> >> Jersey's interaction with it).
> >
> > Maybe. But where?
> >
>
> My guess is in the LW HTTP server.
>
>
> >> Do have a restriction that you cannot depend on the Jersey client
> >> API?
> >> if not it could make things easier for you.
> >
> > Yes there is such a restriction. We have to ensure that the software
> > will
> > run fine at each of the hundreds of enterprises we will ship it to.
> > Since
> > Jersey is not part of GlassFish v2, Java SE, or any other supported
> > Sun
> > product, there is no support available for it. So we think the risk
> > of using
> > this parts of Jersey (those parts that are not covered by JSR311)
> > are not
> > outwighted by the small benefit of having a slightly shorter code. I
> > really
> > love the client API, but I want to have it (A) being part of JSR311
> > and (B)
> > covered by a support contract.
> >
>
> OK.
>
> Paul.
>
> >> You could test with curl logging output to try and debug further. If
> >> you are not familiar with curl i can send you an example.
> >
> > cURL is a great idea! I'll try it tomorrow!
> >
> > Thanks! :-)
> > Markus
> >
> >>
> >> Paul.
> >>
> >> On Dec 18, 2008, at 3:56 PM, Markus Karg wrote:
> >>
> >>> I am not sure whether this is a bug that should be reported using
> >>> the issue tracker, so before typing in a potentially non-existing
> >>> bug, I'd rather like to ask you whether that is a bug at all... ;-)
> >>>
> >>> I just discovered (Jersey-1.0.1) that sometimes I get a Result Code
> >>> of -1 from the following code:
> >>>
> >>> private final void saveModifiedData(final
> >>> ManufacturedAmountXML producedData) throws IOException,
> >>> JAXBException {
> >>> final HttpURLConnection urlConnection =
> >>> (HttpURLConnection) newURL(String.format("http://%s/quipsy/
> >>> manufacturedAmount/Amount.xml", this.host))
> >>> .openConnection();
> >>> try {
> >>> urlConnection.setDoOutput(true);
> >>> urlConnection.setRequestMethod("PUT");
> >>> final OutputStream outputStream =
> >>> urlConnection.getOutputStream();
> >>> try {
> >>>
> >>> JAXBContext
> >>> .newInstance
> >>> (ManufacturedAmountXML
> >>> .class).createMarshaller().marshal(producedData, outputStream);
> >>>
> >>> System.out.println(urlConnection.getResponseCode());
> >>> } finally {
> >>> outputStream.close();
> >>> }
> >>> } finally {
> >>> urlConnection.disconnect();
> >>> }
> >>> }
> >>>
> >>> when executing it agains a Jersey-1.0.1 standalone server (not
> >>> GlassFish).
> >>>
> >>> The PUT is correctly processed in my JAX-RS resource and the body
> is
> >>> completely transfered, it is just the response code that is
> >>> "strange". Typically I get a 204 No Content (what is OK) but
> >>> sometimes I get -1.
> >>>
> >>> Is that a bug in Jersey or is it my fault?
> >>>
> >>> Thanks
> >>> Markus
> >>>
> >>> QUIPSY QUALITY GmbH & Co. KG
> >>> Ein Unternehmen der MES-Gruppe
> >>> Stuttgarter Strasse 23
> >>> D-75179 Pforzheim
> >>> Tel: 07231-9189-52
> >>> Fax: 07231-9189-59
> >>> www.quipsy.de
> >>> karg_at_quipsy.de
> >>> Registergericht Mannheim HRA 701214
> >>> Geschäftsführer: Nils Schroeder
> >>>
> >>> Diese E-Mail enthält persönliche, vertrauliche und vor Weitergabe
> >>> geschützte Informationen und ist ausschließlich für den
> vorgesehenen
> >>> o.g. Empfänger (Adressaten) bestimmt. Falls Sie diese E-Mail
> >>> versehentlich erhalten haben und nicht der vorgesehene Empfänger
> >>> sind, bitten wir Sie, die E-Mail und deren Anhänge nicht
> >>> aufzubewahren, nicht zu vervielfältigen, nicht zu nutzen und nicht
> >>> weiterzugeben. Bitte informieren Sie uns als Absender über diesen
> >>> Zustellungsfehler und löschen Sie die E-Mail.
> >>>
> >>>
> >>> <image001.jpg>
> >>>
> >>> <Markus KARG.vcf>
> >>> -------------------------------------------------------------------
> --
> >>> To unsubscribe, e-mail: dev-unsubscribe_at_jersey.dev.java.net
> >>> For additional commands, e-mail: dev-help_at_jersey.dev.java.net
> >>
> >>
> >> --------------------------------------------------------------------
> -
> >> To unsubscribe, e-mail: dev-unsubscribe_at_jersey.dev.java.net
> >> For additional commands, e-mail: dev-help_at_jersey.dev.java.net
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe_at_jersey.dev.java.net
> > For additional commands, e-mail: dev-help_at_jersey.dev.java.net
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: dev-help_at_jersey.dev.java.net