RE: Problem with Reloading
Kalimera Sopasakis, This is due to a bug in ServerResource in the conditional processing. Good news: it was fixed in recent snapshots: http://www.restlet.org/downloads/unstable Could you try again and let us know? Best regards, Jerome Louvel -- Restlet ~ Founder and Lead developer ~ http://www.restlet.org Noelios Technologies ~ Co-founder ~ http://www.noelios.com -Message d'origine- De : Sopasakis Pantelis [mailto:ch...@mail.ntua.gr] Envoyé : vendredi 23 octobre 2009 12:23 À : discuss@restlet.tigris.org Objet : Re: Problem with Reloading Hi Rob, Thank you for your prompt reply. I tried both Jetty and the Internal connector but there was no difference. The problem appeared as soon as I decided to migrate to restlet 2 m3 from restlet 1.1.5 and 1.1.6 where the same code did not produce any errors. However, it might be just a matter of including the appropriate jars in the classpath. Which are the necessary ones? I tried to include all the jars in the lib/ directory of restlet 2.0 m3 but I received some error messages... Best Regards, Sopasakis Pantelis On Thu, 2009-10-22 at 09:27 -0400, Rob Heittman wrote: Did you try it to see if you get the same behavior using a connector other than Grizzly? (e.g. Jetty or the included HTTP connector) On refresh, most Mozilla based browsers will try a conditional GET first to see if the resource has changed, then if the server indicates that it has changed, will repeat with the full GET. The weird behavior you describe is also found when running under Tomcat 5 if you don't send a large enough entity from Restlet ... where that first conditional GET will fail and cause the same symptoms in the browser. So I'm wondering if it's connector-specific here, too. On Thu, Oct 22, 2009 at 8:38 AM, Sopasakis Pantelis ch...@mail.ntua.gr wrote: Dear List, Hi for the first time, cause I'm a new member. I've developed a web service based on Restlet 1.1.5 which runs as a standalone application using Grizzly. I deciided to migrate to Restlet version 2.0. m3 and after some refactoring and changes in my code, I managed to make the whole thing work just fine! In the server class, I attach both an application and some static html files including a javadoc directory. This is the server class: *** package org.opentox.server; import java.util.logging.Level; import java.util.logging.Logger; import org.opentox.Applications.OpenToxApplication; import org.opentox.Resources.AbstractResource; import org.restlet.Application; import org.restlet.Component; import org.restlet.data.LocalReference; import org.restlet.data.Protocol; import org.restlet.resource.Directory; import org.restlet.routing.VirtualHost; /** * * @author chung */ public class Server { public static void main(String[] args){ // Create a component Component component = new Component(); component.getServers().add(Protocol.HTTP, 3000); component.getClients().add(Protocol.FILE); LocalReference javadoc = LocalReference.createFileReference( AbstractResource.javadocDir); LocalReference home = LocalReference.createFileReference( AbstractResource.HTMLDir); Directory javadocDirectory = new Directory(component.getContext().createChildContext(), javadoc); Directory homeDirectory = new Directory(component.getContext().createChildContext(), home); Application application = new OpenToxApplication(); VirtualHost host = new VirtualHost(); host.attach(/OpenToxServices,application); host.attach(,homeDirectory); host.attach(/OpenToxServices/javadoc, javadocDirectory); component.setDefaultHost(host); try { component.start(); } catch (Exception ex) { Logger.getLogger(Server.class.getName()).log(Level.SEVERE, null, ex); } } } The problem is that when I reload any of the resources that corresponds to a static HTML file (e.g. the javadoc), I get
Re: Problem with Reloading
Hi Rob, Thank you for your prompt reply. I tried both Jetty and the Internal connector but there was no difference. The problem appeared as soon as I decided to migrate to restlet 2 m3 from restlet 1.1.5 and 1.1.6 where the same code did not produce any errors. However, it might be just a matter of including the appropriate jars in the classpath. Which are the necessary ones? I tried to include all the jars in the lib/ directory of restlet 2.0 m3 but I received some error messages... Best Regards, Sopasakis Pantelis On Thu, 2009-10-22 at 09:27 -0400, Rob Heittman wrote: Did you try it to see if you get the same behavior using a connector other than Grizzly? (e.g. Jetty or the included HTTP connector) On refresh, most Mozilla based browsers will try a conditional GET first to see if the resource has changed, then if the server indicates that it has changed, will repeat with the full GET. The weird behavior you describe is also found when running under Tomcat 5 if you don't send a large enough entity from Restlet ... where that first conditional GET will fail and cause the same symptoms in the browser. So I'm wondering if it's connector-specific here, too. On Thu, Oct 22, 2009 at 8:38 AM, Sopasakis Pantelis ch...@mail.ntua.gr wrote: Dear List, Hi for the first time, cause I'm a new member. I've developed a web service based on Restlet 1.1.5 which runs as a standalone application using Grizzly. I deciided to migrate to Restlet version 2.0. m3 and after some refactoring and changes in my code, I managed to make the whole thing work just fine! In the server class, I attach both an application and some static html files including a javadoc directory. This is the server class: *** package org.opentox.server; import java.util.logging.Level; import java.util.logging.Logger; import org.opentox.Applications.OpenToxApplication; import org.opentox.Resources.AbstractResource; import org.restlet.Application; import org.restlet.Component; import org.restlet.data.LocalReference; import org.restlet.data.Protocol; import org.restlet.resource.Directory; import org.restlet.routing.VirtualHost; /** * * @author chung */ public class Server { public static void main(String[] args){ // Create a component Component component = new Component(); component.getServers().add(Protocol.HTTP, 3000); component.getClients().add(Protocol.FILE); LocalReference javadoc = LocalReference.createFileReference( AbstractResource.javadocDir); LocalReference home = LocalReference.createFileReference( AbstractResource.HTMLDir); Directory javadocDirectory = new Directory(component.getContext().createChildContext(), javadoc); Directory homeDirectory = new Directory(component.getContext().createChildContext(), home); Application application = new OpenToxApplication(); VirtualHost host = new VirtualHost(); host.attach(/OpenToxServices,application); host.attach(,homeDirectory); host.attach(/OpenToxServices/javadoc, javadocDirectory); component.setDefaultHost(host); try { component.start(); } catch (Exception ex) { Logger.getLogger(Server.class.getName()).log(Level.SEVERE, null, ex); } } } The problem is that when I reload any of the resources that corresponds to a static HTML file (e.g. the javadoc), I get a status code 405 (Method Not allowed). If I reload the page again, I get the HTML but without the CSS. I reload it again to get the correct HTML representation but without the Images contained in it. Another reload gives once again a status 405, then HTML without css and finally the correct HTML. This happens each time I press F5 on mozilla BUT NOT if I request the resource again, i.e. if I retype the URL. Note that this
Re: Problem with Reloading
Did you try it to see if you get the same behavior using a connector other than Grizzly? (e.g. Jetty or the included HTTP connector) On refresh, most Mozilla based browsers will try a conditional GET first to see if the resource has changed, then if the server indicates that it has changed, will repeat with the full GET. The weird behavior you describe is also found when running under Tomcat 5 if you don't send a large enough entity from Restlet ... where that first conditional GET will fail and cause the same symptoms in the browser. So I'm wondering if it's connector-specific here, too. On Thu, Oct 22, 2009 at 8:38 AM, Sopasakis Pantelis ch...@mail.ntua.grwrote: Dear List, Hi for the first time, cause I'm a new member. I've developed a web service based on Restlet 1.1.5 which runs as a standalone application using Grizzly. I deciided to migrate to Restlet version 2.0. m3 and after some refactoring and changes in my code, I managed to make the whole thing work just fine! In the server class, I attach both an application and some static html files including a javadoc directory. This is the server class: *** package org.opentox.server; import java.util.logging.Level; import java.util.logging.Logger; import org.opentox.Applications.OpenToxApplication; import org.opentox.Resources.AbstractResource; import org.restlet.Application; import org.restlet.Component; import org.restlet.data.LocalReference; import org.restlet.data.Protocol; import org.restlet.resource.Directory; import org.restlet.routing.VirtualHost; /** * * @author chung */ public class Server { public static void main(String[] args){ // Create a component Component component = new Component(); component.getServers().add(Protocol.HTTP, 3000); component.getClients().add(Protocol.FILE); LocalReference javadoc = LocalReference.createFileReference( AbstractResource.javadocDir); LocalReference home = LocalReference.createFileReference( AbstractResource.HTMLDir); Directory javadocDirectory = new Directory(component.getContext().createChildContext(), javadoc); Directory homeDirectory = new Directory(component.getContext().createChildContext(), home); Application application = new OpenToxApplication(); VirtualHost host = new VirtualHost(); host.attach(/OpenToxServices,application); host.attach(,homeDirectory); host.attach(/OpenToxServices/javadoc, javadocDirectory); component.setDefaultHost(host); try { component.start(); } catch (Exception ex) { Logger.getLogger(Server.class.getName()).log(Level.SEVERE, null, ex); } } } The problem is that when I reload any of the resources that corresponds to a static HTML file (e.g. the javadoc), I get a status code 405 (Method Not allowed). If I reload the page again, I get the HTML but without the CSS. I reload it again to get the correct HTML representation but without the Images contained in it. Another reload gives once again a status 405, then HTML without css and finally the correct HTML. This happens each time I press F5 on mozilla BUT NOT if I request the resource again, i.e. if I retype the URL. Note that this happens only with the static html files. Other resources that are based on java classes (MyResource extends ServerResource) don't have such problems! Having no idea how to solve that, I just separated the static files from the service. I set up an apache server on another port (80) to deploy the static html files and the services run on 3000. However I think other people are experiencing the same problem, because I had the same problem on 2 different machines. I would appreciate any suggestions or ideas on that. You can find the source code of the application at http://github.com/sopasakis/yaqp Thank you in advance, Sopasakis Pantelis -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2410202 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2410217