Re: How to run JAX-RS application in a Servlet container
Hi sbyonge, Until now I've used JAX-RS only as standlone application outside a Servlet container. I propose to create a subclass of the JaxRsApplication, and override it's createRoot methode to set the Guard and so on: public class MyJaxRsApplication extends JaxRsApplication { @Override public Restlet createRoot() { this.attach(new MyAppConfig()); this.setGuard(...); // if needed this.setRoleChecker(...); // if needed return super.createRoot(); } } sbyonge, I do not tested this. Does it work? Let me know; and I will put the example into the Restlet wiki. Perhaps other ones have better ideas, let us know. best regards Stephan sbyonge schrieb: I would like to know how to deploy a JAX-RS application in a Servlet container. I built a resource and MyAppConfig for testing and I don't know how to deploy it a servlet container (similar to a servlet example in quick start). public class MyAppConfig extends ApplicationConfig { @Override public SetClass? getResourceClasses() { SetClass? rcs = new HashSetClass?(); rcs.add(HelloResource.class); return rcs; } } Thanks
Re: cURL PUT with data?
Hi, Marcus. I'm not sure to fully understand you question. If you want to create PUT request with a Restlet Client you can do as follow: Client client = new Client(Protocol.HTTP); Representation rep = new StringRepresentation(my data., MediaType.TEXT_PLAIN); client.put(rep, http://www.example.com/my/resource;); Or you can create PUT request: Client client = new Client(Protocol.HTTP); Request request = new Request(Method.PUT, http://www.example.com/my/resource;); Representation rep = new StringRepresentation(my data., MediaType.TEXT_PLAIN); request.setEntity(rep); Client.handle(request); best regards, Thierry Boileau Hey all, I did research into Restlet at the beginning of this year and really liked it. It tought me a lot about REST in general, but my boss decided that for the mean time we would implement our REST services in PHP, and slowly migrate modules across to Java at a later date. Regardless, I figured that this forum would be a good place to ask the following question: I have encountered an issue with using cURL and issuing PUT HTTP requests to perform update REST calls. It seems as if you can only upload whole files using this method. When using POST, data can be passed in. Unfortunately I seem to be left with no option other than to use a POST HTTP verb with a queryString flag saying something like 'reallyAPut=true' so that i can then retrieve the data and act on it in an 'update' way rather than a 'create' way. Has anyone else noticed this 'problem' with cURL? How does Restlet handle this again (memory is fading now)? Thanks guys, Marcus.
Re: cURL PUT with data?
Marcus, I've just tested the following curl command line: curl -T testPut.txt localhost:8182 where testPut.txt is a file. On port 8182, a simple Restlet based server is listening and receives correctly a PUT method and the content of the file. best regards, Thierry Boileau I did a quick test, and formatted up my own HTTP request manually. I put in the PUT verb and the resource URI, the headers, and the data. Apache doesn't provide the data in the post data. It does pass these in when i change the verb to POST. Could this be an Apache thing? This is making the implementation of true REST calls very difficult for me. Marcus [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hey all, I did research into Restlet at the beginning of this year and really liked it. It tought me a lot about REST in general, but my boss decided that for the mean time we would implement our REST services in PHP, and slowly migrate modules across to Java at a later date. Regardless, I figured that this forum would be a good place to ask the following question: I have encountered an issue with using cURL and issuing PUT HTTP requests to perform update REST calls. It seems as if you can only upload whole files using this method. When using POST, data can be passed in. Unfortunately I seem to be left with no option other than to use a POST HTTP verb with a queryString flag saying something like 'reallyAPut=true' so that i can then retrieve the data and act on it in an 'update' way rather than a 'create' way. Has anyone else noticed this 'problem' with cURL? How does Restlet handle this again (memory is fading now)? Thanks guys, Marcus.
Re: How to run JAX-RS application in a Servlet container
Hi Stephan, Yes, the warning message is gone after adding a constructor. Everything seems working great. Thanks very much for your help, Sangbok
Re: How to run JAX-RS application in a Servlet container
Hi, I've added the example class to the tutorial in the wiki http://wiki.restlet.org/docs_1.1/g1/13-restlet/28-restlet/57-restlet.html best regards Stephan Stephan Koops schrieb: Hi Sangbok, add a constructor with one Parameter of type Context: public class MyJaxRsApplication extends JaxRsApplication { public MyJaxRsApplication(Context context) { super(context); } @Override public Restlet createRoot() { this.attach(new MyAppConfig()); this.setGuard(...); // if needed this.setRoleChecker(...); // if needed return super.createRoot(); } } Does this work? If you have comments, question or something like that to the JAX-RS extension, let me now. best regards Stephan sbyonge schrieb: Hi Stephan, Yes, it works but I am getting the following warning message. I am using Apache Geronimo 2.1.1 (with Jetty) and application seems to work. Thanks, Sangbok // My Application public class RestletApplication extends JaxRsApplication { @Override public Restlet createRoot() { this.attach(new RestletConfig()); return super.createRoot(); } } // jars included in WEB-INF/lib com.noelios.restlet.ext.servlet_2.5.jar com.noelios.restlet.jar javax.ws.rs.jar org.json.jar org.restlet.ext.jaxrs_0.9.jar org.restlet.jar WARNING: The connector has been instantiated without any protocol. [Noelios Restlet Engine] - The ServerServlet couldn't invoke the constructor of the target class. Please check this class has a constructor with a single parameter of type Context. The empty constructor and the context setter will be used instead. java.lang.NoSuchMethodException: gmo.resource.RestletApplication.init (org.restlet.Context) at java.lang.Class.getConstructor0(Class.java:2706) at java.lang.Class.getConstructor(Class.java:1657) at com.noelios.restlet.ext.servlet.ServerServlet.createApplication (ServerServlet.java:182) at com.noelios.restlet.ext.servlet.ServerServlet.getApplication (ServerServlet.java:428) at com.noelios.restlet.ext.servlet.ServerServlet.init (ServerServlet.java:545) at javax.servlet.GenericServlet.init(GenericServlet.java:215) at org.mortbay.jetty.servlet.ServletHolder.initServlet (ServletHolder.java:433) at org.mortbay.jetty.servlet.ServletHolder.getServlet (ServletHolder.java:342) at org.mortbay.jetty.servlet.ServletHolder.handle (ServletHolder.java:463) at org.apache.geronimo.jetty6.InternalJettyServletHolder.handle (InternalJettyServletHolder.java:65) at org.mortbay.jetty.servlet.ServletHandler.handle (ServletHandler.java:362) at org.mortbay.jetty.security.SecurityHandler.handle (SecurityHandler.java:216) at org.mortbay.jetty.servlet.SessionHandler.handle (SessionHandler.java:181) at org.mortbay.jetty.handler.ContextHandler.handle (ContextHandler.java:726) at org.mortbay.jetty.webapp.WebAppContext.handle (WebAppContext.java:405) at org.apache.geronimo.jetty6.handler.TwistyWebAppContext.access$101 (TwistyWebAppContext.java:40) at org.apache.geronimo.jetty6.handler.TwistyWebAppContext$ TwistyHandler.handle(TwistyWebAppContext.java:65) at org.apache.geronimo.jetty6.handler.ThreadClassloaderHandler.handle (ThreadClassloaderHandler.java:46) at org.apache.geronimo.jetty6.handler.InstanceContextHandler.handle (InstanceContextHandler.java:58) at org.apache.geronimo.jetty6.handler.UserTransactionHandler.handle (UserTransactionHandler.java:48) at org.apache.geronimo.jetty6.handler.ComponentContextHandler.handle (ComponentContextHandler.java:47) at org.apache.geronimo.jetty6.handler.TwistyWebAppContext.handle (TwistyWebAppContext.java:59) at org.mortbay.jetty.handler.ContextHandlerCollection.handle (ContextHandlerCollection.java:206) at org.mortbay.jetty.handler.HandlerWrapper.handle (HandlerWrapper.java:139) at org.mortbay.jetty.Server.handle(Server.java:324) at org.mortbay.jetty.HttpConnection.handleRequest (HttpConnection.java:505) at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete (HttpConnection.java:828) at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:514) at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211) at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380) at org.mortbay.io.nio.SelectChannelEndPoint.run (SelectChannelEndPoint.java:395) at org.apache.geronimo.pool.ThreadPool$1.run(ThreadPool.java:214) at org.apache.geronimo.pool.ThreadPool$ContextClassLoaderRunnable.run (ThreadPool.java:344) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask (ThreadPoolExecutor.java:885) at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:907) at java.lang.Thread.run(Thread.java:619) Jun 12, 2008 11:34:41 AM org.restlet.Connector init WARNING: The connector has been instantiated
router, attach, 404
Hi, I can't figure out this problem even though I've read past postings on this. On the server side when I do a router.attach, I am getting a 404 error on the client side. My client uri is /restful/vi/users /restful/vi/folders On the server side, the Application code public static void main(String... args) throws Exception { // Create a component with an HTTP server connector Component comp = new Component(); comp.getServers().add(Protocol.HTTP); // Attach the application to the default host and start it comp.getDefaultHost().attach(/restful/v1, new Application()); comp.start(); } public Restlet createRoot() { Router router = new Router(getContext()); log.info( in createRoot ); // Add a route for user resources //router.attachDefault(FolderResource.class); // Add a route for users resources router.attach(/users, UserResource.class); // Add a route for folders resources router.attach(/folders, FolderResource.class); return router; } The router.attachDefault(***) works. Are there configuration issues? Thanks a bunch, Jennifer J. Chen
Re: router, attach, 404
Sorry about the misspelling, my client's URIs are /restful/v1/users /restful/v1/folders Thanks again, Jennifer J. Chen On Thu, Jun 12, 2008 at 5:29 PM, Jennifer J. Chen [EMAIL PROTECTED] wrote: Hi, I can't figure out this problem even though I've read past postings on this. On the server side when I do a router.attach, I am getting a 404 error on the client side. My client uri is /restful/vi/users /restful/vi/folders On the server side, the Application code public static void main(String... args) throws Exception { // Create a component with an HTTP server connector Component comp = new Component(); comp.getServers().add(Protocol.HTTP); // Attach the application to the default host and start it comp.getDefaultHost().attach(/restful/v1, new Application()); comp.start(); } public Restlet createRoot() { Router router = new Router(getContext()); log.info( in createRoot ); // Add a route for user resources //router.attachDefault(FolderResource.class); // Add a route for users resources router.attach(/users, UserResource.class); // Add a route for folders resources router.attach(/folders, FolderResource.class); return router; } The router.attachDefault(***) works. Are there configuration issues? Thanks a bunch, Jennifer J. Chen
Use a proxy server with a Client?
Hi all, does anyone know of a way to have a Client use a proxy server when making a request? Thanks! -- Avi Flax » Lead Technologist » Partner » Arc90 » http://arc90.com
Re: Use a proxy server with a Client?
Thara S had an open question about this in another thread. I think the answer is here: http://restlet.tigris.org/issues/show_bug.cgi?id=317 For the Net connector you ought to be able to use the common idiom of setting the system properties http.proxyHost and http.proxyPort. This idiom does not work with the Apache HttpClient connector anyway. Steve Loughran went to big lengths to fix this here: http://jira.smartfrog.org/jira/browse/SFOS-629 and he also contributed some ideas to the bug report. I'd rather set properties on the client context, like configuring server properties, though ... If enough people think this is a big deal, I'm happy to propose a patch and see if Jerome's willing to bump it earlier. - R On Thu, Jun 12, 2008 at 6:55 PM, Avi Flax [EMAIL PROTECTED] wrote: Hi all, does anyone know of a way to have a Client use a proxy server when making a request?