RE: Issues with Directory and Custom contexts
Hi Alex, I have fixed this potential NPE in SVN trunk. Can't you directly pass your Component's context to the Application constructor instead of having to recreate it manually via the internal 'createContext()' method? Best regards, Jerome -Message d'origine- De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] De la part de Alex Milowski Envoyé : mardi 13 mai 2008 02:52 À : discuss@restlet.tigris.org Objet : 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(App licationClientDispatcher.java:105) at com.noelios.restlet.application.ApplicationClientDispatcher.doHandle(Applica tionClientDispatcher.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:17 0) 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.j ava: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
Re: Issues with Directory and Custom contexts
On Wed, May 14, 2008 at 12:27 AM, Jerome Louvel [EMAIL PROTECTED] wrote: Hi Alex, I have fixed this potential NPE in SVN trunk. Can't you directly pass your Component's context to the Application constructor instead of having to recreate it manually via the internal 'createContext()' method? In this case, no. I need to have a different set of parameters and attributes. Maybe my use case is just non-trivial and so the strange constructor for the context is also non-trivial. --Alex Milowski
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