users@jersey.java.net

SV: [Jersey] Getting nuts with hangs in Client API

From: Morten <mortench2004_at_yahoo.dk>
Date: Mon, 7 Sep 2009 16:34:15 +0000 (GMT)

You have to call close otherwise you get hangs as you reported. I have reported a bug about this to get an exception instead but it is a difficult fix. /Morten --- Den man 7/9/09 skrev Markus KARG <markus.karg@gmx.net>: > Fra: Markus KARG <markus.karg@gmx.net> > Emne: [Jersey] Getting nuts with hangs in Client API > Til: users@jersey.dev.java.net > Dato: mandag 7. september 2009 18.15 > > > > > > > > > > > > > > > > Please help me, I have to do a > presentation on Jersey Client > API but the demo program just hangs all the time! ;-( > >   > > Server looks like this: > >   > > @Path("/RsChatroom") > > public class JaxRsChat { > >       > private static volatile > String content = ""; > >       > @POST > >       > public void publish(String > text) { > >             > content = content + '\n' + text; > >       > } > >       > @GET > >       > public String > getContent() { > >             > return content; > >       > } > > } > >   > > public class > JaxRsChatContainer { > >       > public static void main(String[] > arguments) throws IOException { > >             > HttpServer > server = HttpServerFactory.create("http://localhost:80/ADV/"); > >             > server.start(); > >       > } > > } > >   > > Client looks like this: > >   > > public static void main(String[] arguments) > throws > InterruptedException { > >       Client > client = Client.create(); > >       > WebResource > resource = client.resource("http://localhost:80/ADV/RsChatroom"); > >       > while (true) { > >             > System.out.println(resource.get(String.class)); > >             > resource.post(new > Date().toString()); // Later will use user input > instead. > >       > } > > } > >   > > Looks rather simple, but actually > hangs at > resource.get IN THE SECOND TURN! If I comment out either > resource.get() or > resource.post(), then it correctly runs endless. > >   > > But as soon as there was a single > resource.post(), the > subsequent resource.get() HANGS. I was trying for hours, > and do not see a > solution. Sometimes, it also runs a few times, and then > says this: > >   > > Exception in thread "main" > com.sun.jersey.api.client.ClientHandlerException: java.net.BindException: Address already > in use: connect > >   > > Can anybody tell me how to fix that? > My OS is Windows XP > Home and Java is JDK 1.6.0_16. Jersey is 1.0.3.1. I am > rather desparate since I > have to do a presentation about the Client API next week > and currently JUST > NOTHING WORKS. ;-( With cURL everything works pretty fine. > Strange! > >   > > I don't believe that it is a bug > in the client API since I > tried using HttpURLConnection instead of Client API and > experienced the same > problem (waiting endless in Socket reading internally in > the JRE). > >   > > Please help me! :-) > >   > > Thanks > > Markus > >   > > > > > > > Trænger du til at se det store billede? Kelkoo giver dig gode tilbud på LCD TV! Se her http://dk.yahoo.com/r/pat/lcd