|
From: awaterma <awa...@me...> - 2011-02-11 19:02:04
|
Thanks for your help Michael. This looks to be a maven dependency configuration issue. I narrowed it down to what looks like a classpath conflict between TJWS and Jetty (another test in the project I've been working on uses Jetty). Once that is removed, TJWS tests can run. Also TJWS looks to need a declared version of the Servlet API to work properly. I'm still seeing the following issue, when I scope a versioned Servlet API to "provided", although the tests now run and pass: > java.lang.IllegalStateException: Can not send an error, headers have been already written > at Acme.Serve.Serve$ServeConnection.realSendError(Serve.java:4205) > at Acme.Serve.Serve$ServeConnection.sendError(Serve.java:4183) > at org.jboss.resteasy.plugins.server.servlet.HttpServletResponseWrapper.sendError(HttpServletResponseWrapper.java:71) > at org.jboss.resteasy.core.SynchronousDispatcher.handleFailure(SynchronousDispatcher.java:246) > at org.jboss.resteasy.core.SynchronousDispatcher.handleWriterException(SynchronousDispatcher.java:363) > at org.jboss.resteasy.core.SynchronousDispatcher.handleException(SynchronousDispatcher.java:202) > at org.jboss.resteasy.core.SynchronousDispatcher.handleWriteResponseException(SynchronousDispatcher.java:187) > at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:488) > at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:119) > at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:207) > at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55) > at org.jboss.resteasy.plugins.server.tjws.TJWSServletDispatcher.service(TJWSServletDispatcher.java:40) > at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) > at Acme.Serve.Serve$ServeConnection.runServlet(Serve.java:2324) > at Acme.Serve.Serve$ServeConnection.parseRequest(Serve.java:2278) > at Acme.Serve.Serve$ServeConnection.run(Serve.java:2052) > at Acme.Utils$ThreadPool$PooledThread.run(Utils.java:1402) > at java.lang.Thread.run(Thread.java:680) Are these known issues, I wonder? best wishes, Andrew On Feb 10, 2011, at 11:28 AM, awaterma wrote: > Hello Everybody, > > I'm sorry to trouble the list with this question, but I haven't been able to find an answer via google or the archives, so I thought I'd email you guys. Basically, I'm trying to use the Embedded server for jUnit tests on my RESTEasy implementation. I was having trouble just getting a simple example to work, so I searched Google and came across the following post from Rob Williams: "http://www.jroller.com/robwilliams/entry/resteasy_oobe_a_10". In the comments section, Solomon Duskis makes a suggestion: > >> RESTEasy ClientRequest and EmbeddedServer make this kind of testing even easier. Unfortunately, they're not documented yet... the docs are in progress. >> >> An example can be found at: http://resteasy.svn.sourceforge.net/viewvc/resteasy/trunk/jaxrs/resteasy-jaxrs/src/test/java/org/jboss/resteasy/test/finegrain/client/ClientResponseTest.java?view=markup >> Posted by Solomon Duskis on April 27, 2009 at 07:21 AM PDT # >> > > So I followed his suggested approach. My unit tests run perfectly in my IDE (IntelliJ 10) with no apparent issues. However, when I evoke my test as part of a general maven 3 build, I run into the following problem: > >> Caused by: java.lang.NullPointerException >> at javax.servlet.GenericServlet.log(GenericServlet.java:300) >> at javax.servlet.GenericServlet.init(GenericServlet.java:257) >> at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.init(HttpServletDispatcher.java:33) >> at Acme.Serve.Serve.addServlet(Serve.java:509) >> at Acme.Serve.Serve.addServlet(Serve.java:493) >> at org.jboss.resteasy.plugins.server.tjws.TJWSServletServer.addServlet(TJWSServletServer.java:57) >> at org.jboss.resteasy.plugins.server.tjws.TJWSEmbeddedJaxrsServer.start(TJWSEmbeddedJaxrsServer.java:42) >> at org.jboss.resteasy.test.TJWSServletContainer.start(TJWSServletContainer.java:50) >> at org.jboss.resteasy.test.TJWSServletContainer.start(TJWSServletContainer.java:40) >> at org.jboss.resteasy.test.TJWSServletContainer.start(TJWSServletContainer.java:22) > > > As I mentioned, it's not possible to debug this, as when I step through the downloaded source (man, I love maven), I see no NPE from the IDE perspective. Any ideas as to what could be going on? Am I missing some logging configuration data that IntelliJ somehow magically passes on? > > I should also mention, that I although my Unit Tests in IntelliJ all run, and come up green, I do see the following logged errors in the output stream: > >> [Thu Feb 10 11:19:40 CST 2011] MIME map can't be loaded:java.lang.NullPointerException >> [Thu Feb 10 11:19:40 CST 2011] Servlet for path '/' already defined and no default will be used. >> [Thu Feb 10 11:19:40 CST 2011] TJWS httpd 0.0.0.0 - SimpleAcceptor ServerSocket[addr=0.0.0.0/0.0.0.0,port=0,localport=8081] is listening. >> [Thu Feb 10 11:19:47 CST 2011] IO error: java.net.SocketException: Broken pipe in processing a request from /127.0.0.1:8081 / java.net.Socket >> [Thu Feb 10 11:19:47 CST 2011] Unexpected problem running servlet >> java.lang.IllegalStateException: Can not send an error, headers have been already written >> at Acme.Serve.Serve$ServeConnection.realSendError(Serve.java:4205) >> at Acme.Serve.Serve$ServeConnection.sendError(Serve.java:4183) >> at org.jboss.resteasy.plugins.server.servlet.HttpServletResponseWrapper.sendError(HttpServletResponseWrapper.java:71) >> at org.jboss.resteasy.core.SynchronousDispatcher.handleFailure(SynchronousDispatcher.java:246) >> at org.jboss.resteasy.core.SynchronousDispatcher.handleWriterException(SynchronousDispatcher.java:363) >> at org.jboss.resteasy.core.SynchronousDispatcher.handleException(SynchronousDispatcher.java:202) >> at org.jboss.resteasy.core.SynchronousDispatcher.handleWriteResponseException(SynchronousDispatcher.java:187) >> at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:488) >> at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:119) >> at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:207) >> at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55) >> at org.jboss.resteasy.plugins.server.tjws.TJWSServletDispatcher.service(TJWSServletDispatcher.java:40) >> at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50) >> at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) >> at Acme.Serve.Serve$ServeConnection.runServlet(Serve.java:2324) >> at Acme.Serve.Serve$ServeConnection.parseRequest(Serve.java:2278) >> at Acme.Serve.Serve$ServeConnection.run(Serve.java:2052) >> at Acme.Utils$ThreadPool$PooledThread.run(Utils.java:1402) >> at java.lang.Thread.run(Thread.java:680) > > > I wonder if the null mime map is the issue I'm seeing in Maven? Should I do more to initialize TJWS then: > >> ResteasyDeployment deployment = EmbeddedContainer.start(); >> dispatcher = deployment.getDispatcher(); >> dispatcher.getRegistry().addPerRequestResource(PackageService.class); > > > Here's my client connection code: > >> URL url = new URL(generateBaseUrl() + "/packages"); >> connection = (HttpURLConnection)url.openConnection(); > > > Really looking forward to your ideas and suggestions. > > best wishes, > > Andrew Waterman > ------------------------------------------------------------------------------ > The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE: > Pinpoint memory and threading errors before they happen. > Find and fix more than 250 security defects in the development cycle. > Locate bottlenecks in serial and parallel code that limit performance. > http://p.sf.net/sfu/intel-dev2devfeb_______________________________________________ > Resteasy-users mailing list > Res...@li... > https://lists.sourceforge.net/lists/listinfo/resteasy-users |