Re: Tomcat and Restlets
Hello Thomas, could you provide us your web.xml file also? Can you have a look at this documentation page? = http://www.restlet.org/documentation/1.1/firstSteps best regards, Thierry Boileau Hello, I've got some problems concerning the integration of a simple Application into the Tomcat container. I followed the instructions on the restlet.org FAQs, however it doesn't work with my code, I get HTTP 500 internal errors. The application works in the Noelios engine. package com.interaktivestadt; import java.io.File; import org.restlet.Component; import org.restlet.Context; import org.restlet.Restlet; import org.restlet.Route; import org.restlet.Router; import org.restlet.data.Protocol; import org.restlet.util.Variable; import org.restlet.Directory; import com.db4o.Db4o; import com.db4o.ObjectContainer; import com.db4o.config.Configuration; /** * The main Web application. * * @author Thomas Fuhrmann */ public class Application extends org.restlet.Application { private ObjectContainer container; 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, 3000); comp.getClients().add(Protocol.FILE); // Attach the application to the default host and start it comp.getDefaultHost().attach(/, new Application(comp.getContext())); comp.start(); } public Application(Context context) { super(context); // the db4o container is a simple database for storing objects // setting the update depth to two, because the user object we store contains a non primitive member // system property user.home means the local user directory Db4o.configure().updateDepth(2); this.container = Db4o.openFile(System.getProperty(user.home) + File.separator + userdb.dbo); } public Restlet createRoot() { // Router routes client requests to their according resources // taken from the Restlet docs: // The context property is typically provided by a parent Component as a way to encapsulate access to shared features such as logging and client connectors. Router router = new Router(getContext()); // Add a route for the homepage resource router.attach(,HomeResource.class); // Add a route for the user input validation router.attach(/users/participation, ParticipationResource.class); // Add a route for the users resource Route usersRoute = router.attach(/users/{username}, UserResource.class); usersRoute.getTemplate().getVariables().put(username, new Variable(Variable.TYPE_ALL)); return router; } /** * Returns the database container. * * @return the database container. */ public ObjectContainer getContainer() { return this.container; } } Thanks, for your help!
Re: javax.servlet should be optional for ext.fileupload -- was Re: Latest Restlet snapshot is amazing! (re: OSGi)
Hi Hendy, thanks for your contribution, that I think I've integrated too quickly... Normally, as a contributor you must sign the Joint Copyright Assignment. Do you mind to sign and send it? = http://www.restlet.org/community/contribute best regards, Thierry Boileau Confirmed. Hacking the ext.fileupload.jar to use the MANIFEST.MF below make it work. The changed line is the Import-Package one, where I specify dependency to javax.servlet.* as optional. I can still make FileUpload work using the built-in Restlet component HTTP Server. Should I make a JIRA request for this? This is very trivial... ;) Manifest-Version: 1.0 Ant-Version: Apache Ant 1.6.5 Created-By: 1.5.0_14-b03 (Sun Microsystems Inc.) Bundle-ManifestVersion: 2 Bundle-Name: Restlet Extension - FileUpload Bundle-SymbolicName: org.restlet.ext.fileupload Bundle-Version: 1.1 Bundle-Vendor: Noelios Consulting Export-Package: org.restlet.ext.fileupload;uses:=org.restlet.resource ,org.restlet.data,org.apache.commons.fileupload Import-Package: javax.servlet;resolution:=optional,javax.servlet.http;resolution:=optional,org.apache.commons.fi leupload,org.restlet,org.restlet.data,org.restlet.resource,org.restle t.service,org.restlet.util Name: org.restlet.ext.fileupload Implementation-Title: org.restlet.ext.fileupload_1.2 Implementation-Version: 1.1 Snapshot (build 215) Implementation-Vendor: Noelios Consulting Hendy Irawan wrote: After battling various strange things with latest Restlet milestone (without OSGi support incorporated), I tried Restlet snapshot and wow... I need no more Engine.setInstance() hack... and Component actually calls Application.createRoot(). (For some strange reason, it didn't, and left my Restlet server in a blank state. I have to update my restlet app bundle on every launch to make it work) Latest snapshot is working fine. (plus, thanks for mentioning me in the Changelog) ^)^ No workarounds needed now, except... Why ext.fileupload requires 'javax.servlet' and 'javax.servlet.http' (in OSGi manifest)? There has to be a good reason for this, because in my experience it works fine without (i.e. just using the built-in Restlet HTTP server component) If it's not always required then should be marked as resolution:=optional in MANIFEST.MF (or maybe other way). Thanks.
Re: Tomcat and Restlets
Hello Thomas, could you provide us your web.xml file also? Can you have a look at this documentation page? = http://www.restlet.org/documentation/1.1/firstSteps best regards, Thierry Boileau ?xml version=1.0 encoding=ISO-8859-1? !DOCTYPE web-app PUBLIC -//Sun Microsystems, Inc.//DTD Web Application 2.3//EN http://java.sun.com/dtd/web-app_2_3.dtd; web-app display-nameInteraktive Stadt Web Application/display-name description This is a Restful web map service, written in Java by Thomas Fuhrmann. For more information, please contact [EMAIL PROTECTED] /description context-param param-namemain.Application/param-name param-value com.interaktivestadt.Application /param-value /context-param !-- Restlet adapter -- servlet servlet-nameServerServlet/servlet-name servlet-class com.noelios.restlet.ext.servlet.ServerServlet /servlet-class /servlet !-- Catch all requests -- servlet-mapping servlet-nameServerServlet/servlet-name url-pattern/*/url-pattern /servlet-mapping Yes I've already looked at this page, that's where I started from. /web-app
Re: java.util.zip.ZipException: no current ZIP entry..Any ideas
Hi Surjendu, my first quick answer is that you don't need to wrap your FileRepresentation with an EncodeRepresentation. there is no gain to zip a zip file. File file = new File(c:\\temp.zip); rep = new FileRepresentation(file,MediaType.APPLICATION_ZIP); getResponse().setEntity(rep); However, this may be the sign of a bug, I have a look at this. best regards, Thierry Boileau I am receiving the following exception when the entity is being set in the response. java.util.zip.ZipException: no current ZIP entry My code: File file = new File(c:\\temp.zip); rep = new FileRepresentation(file,MediaType.APPLICATION_ZIP); Representation zippedRep = new EncodeRepresentation(Encoding.ZIP,rep); getResponse().setEntity(zippedRep);
Re: Tomcat and Restlets
Hello Thomas, that's great! best regards, Thierry Boileau OK, I've just fixed the problem, I had to change the param name value in the web.xml file. Thanks
Re: Tomcat and Restlets
OK, I've just fixed the problem, I had to change the param name value in the web.xml file. Thanks
Re: java.util.zip.ZipException: no current ZIP entry..Any ideas
Hi Surjendu, Thanks Surjendu for reporting this bug. I've entered a new issue. = http://restlet.tigris.org/issues/show_bug.cgi?id=493 You can encode using the GZIP encoding which seems to work well. Representation zippedRep = new EncodeRepresentation(Encoding.GZIP,rep); best regards, Thierry Boileau I am receiving the following exception when the entity is being set in the response. java.util.zip.ZipException: no current ZIP entry My code: File file = new File(c:\\temp.zip); rep = new FileRepresentation(file,MediaType.APPLICATION_ZIP); Representation zippedRep = new EncodeRepresentation(Encoding.ZIP,rep); getResponse().setEntity(zippedRep);
Re: Directory.java and CDDL no more
Please scroll down to the AlphanumericComparator implementation and observe that the source is credited to me and has nothing in common with Dave Koelle's implementation. Jerome, it might be good to alter the comment at the top of the file to clarify that we use an independent implementation, to avoid further confusion on this point. I think the change log has the correct language, crediting Dave for the advocacy but not the code. Dave's Web site has been a popular destination advocating the usability advantages of alphanumeric sorting. When this Web site was brought to the Restlet project's attention, I originally approached Dave Koelle in hopes of using his existing implementation. However, he was unwilling to release his work under a Restlet-compatible license (either public domain or CDDL), and so we could not use it. Although Dave independently arrived at the idea of an alphanumeric (natural) sort, he certainly isn't the first to have the idea; the concept and various implementations appear in computing literature back to at least the 1970s. Researching the prior discussion and work on the point led me to choose a simple character comparison approach with a 2-3x performance gain and memory footprint advantages over the block comparison approach Dave uses. Dave's blockwise approach theoretically allows more complex properties to be examined (for example, comparing hex strings or floats) but these advantages are not currently exposed in his reference implementation, and necessarily come with a performance tradeoff. - Rob On Mon, May 12, 2008 at 1:20 AM, Leshek [EMAIL PROTECTED] wrote: Am I looking at a wrong source? Around line 56 of Ditectory.java I see: * ... The default sorting uses the friendly a * href=http://www.davekoelle.com/alphanum.html;Alphanumhttp://www.davekoelle.com/alphanum.html%22%3EAlphanumAlgorithm from David * Koelle/a.
Re: Directory.java and CDDL no more
Thank you Rob! From my current experience with legal side, definitely would be good to make it crystal clear there is no LGPL related code in there. It almost shut down all my efforts.
Issues with Directory and Custom contexts
I'm loading applications directly from jar files and constructing their context. I ran into a problem where an application that uses the Directory restlet would generate a null pointer exception. That is, if I construct the context as: Context appContext = new Context(getLogger()); then I get this stack trace: java.lang.NullPointerException at com.noelios.restlet.application.ApplicationClientDispatcher.parentHandle(ApplicationClientDispatcher.java:105) at com.noelios.restlet.application.ApplicationClientDispatcher.doHandle(ApplicationClientDispatcher.java:90) at com.noelios.restlet.TemplateDispatcher.handle(TemplateDispatcher.java:101) at org.restlet.Uniform.handle(Uniform.java:95) at org.restlet.Uniform.get(Uniform.java:83) at com.noelios.restlet.local.DirectoryResource.init(DirectoryResource.java:170) at com.noelios.restlet.Engine.createDirectoryResource(Engine.java:292) at org.restlet.Directory.findTarget(Directory.java:159) at org.restlet.Finder.handle(Finder.java:316) at org.restlet.Filter.doHandle(Filter.java:137) at org.restlet.Filter.handle(Filter.java:180) at org.restlet.Filter.doHandle(Filter.java:137) at com.noelios.restlet.StatusFilter.doHandle(StatusFilter.java:117) at org.restlet.Filter.handle(Filter.java:180) at org.restlet.Filter.doHandle(Filter.java:137) at org.restlet.Filter.handle(Filter.java:180) at com.noelios.restlet.ChainHelper.handle(ChainHelper.java:140) at com.noelios.restlet.application.ApplicationHelper.handle(ApplicationHelper.java:103) at org.restlet.Application.handle(Application.java:305) I can solve this by constructing the application context from the component as: Context appContext = Engine.getInstance().createHelper(MyComponent.this).createContext(getLogger().getName()); This seems rather non-obvious :( --Alex Milowski