|
|
|
Dustin N. Jenkins
|
Hello!
I'm using Java 1.6, Tomcat 6, RESTlet 2.0M5, Spring 2.5, the supported version of FreeMarker, all on Linux. The relevant part of my spring configuration looks like this: <bean id="freeMarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer"> ... </bean> <bean id="application" name="application" class="org.restlet.Application"> <property name="root" ref="router" /> ... </bean> <bean name="router" class="org.restlet.ext.spring.SpringBeanRouter" /> <bean abstract="true" name="baseResource" scope="prototype" class="ca.nrc.cadc.dp.web.restlet.resources.AbstractResource"> <!-- Method to configure FreeMarker using the FreeMarker Configurer. --> <property name="freeMarkerConfigViaConfigurer" ref="freeMarkerConfigurer" /> </bean> Which is very straightforward and worked fine with the 1.1.x versions of RESTlet. Here are the relevant parts of my web.xml also: <context-param> <param-name>org.restlet.application</param-name> <param-value>application</param-value> </context-param> <servlet> <servlet-name>RestletServer</servlet-name> <servlet-class>org.restlet.ext.spring.SpringServerServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>RestletServer</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping> My problem is that in my baseResource bean, I create a new ContextTemplateLoader for FreeMarker to use, and I pass it getContext() like so: /** * Set the FreeMarker Configuration. * * @param freeMarkerConfig The FreeMarker Configuration instance. */ public void setFreeMarkerConfig(final Configuration freeMarkerConfig) { if (freeMarkerConfig == null) { throw new FreeMarkerConfigurationException( "FreeMarker Configuration cannot be NULL"); } this.freeMarkerConfig = freeMarkerConfig; freeMarkerConfig.setTemplateLoader( new ContextTemplateLoader(getContext(), "war:///freemarker-templates/")); } public void setFreeMarkerConfigViaConfigurer( final FreeMarkerConfigurer springFreeMarkerConfigurer) { setFreeMarkerConfig(springFreeMarkerConfigurer.getConfiguration()); } but getContext() returns null because the ServerResource's context member is null. Is there a step I need to set the Context? The SpringBeanFinder from the Router is passing in a null Context when the init(Context, Request, Response) method is called on the ServerResource. Has anyone else experienced this? I have not tried the SVN trunk of RESTlet yet. Many thanks! Dustin -- Dustin N. Jenkins | Tel/Tél: 250.363.3101 | [hidden email] facsimile/télécopieur: (250) 363-0045 National Research Council Canada | 5071 West Saanich Rd, Victoria BC. V9E 2E7 Conseil national de recherches Canada | 5071, ch. West Saanich, Victoria (C.-B) V9E 2E7 Government of Canada | Gouvernement du Canada ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2411701 |
||||||||||||||||
|
Dustin N. Jenkins
|
I should mention too that I have my component defined:
<!-- The Restlet Component --> <bean name="component" class="org.restlet.ext.spring.SpringComponent"> <property name="defaultTarget" ref="application" /> <property name="context" ref="component.context" /> <property name="clientsList"> <list> <value>http</value> <value>file</value> </list> </property> </bean> <bean name="component.context" class="org.springframework.beans.factory.config.PropertyPathFactoryBean" /> And also in my web.xml: <context-param> <param-name>org.restlet.component</param-name> <param-value>component</param-value> </context-param> Thanks! Dustin Dustin N. Jenkins wrote: > Hello! > > I'm using Java 1.6, Tomcat 6, RESTlet 2.0M5, Spring 2.5, the supported > version of FreeMarker, all on Linux. > > The relevant part of my spring configuration looks like this: > > <bean id="freeMarkerConfig" > class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer"> > ... > </bean> > > <bean id="application" name="application" class="org.restlet.Application"> > <property name="root" ref="router" /> > ... > </bean> > > <bean name="router" class="org.restlet.ext.spring.SpringBeanRouter" /> > > <bean abstract="true" name="baseResource" scope="prototype" > class="ca.nrc.cadc.dp.web.restlet.resources.AbstractResource"> > <!-- Method to configure FreeMarker using the FreeMarker Configurer. --> > <property name="freeMarkerConfigViaConfigurer" > ref="freeMarkerConfigurer" /> > </bean> > > Which is very straightforward and worked fine with the 1.1.x versions of > RESTlet. Here are the relevant parts of my web.xml also: > > <context-param> > <param-name>org.restlet.application</param-name> > <param-value>application</param-value> > </context-param> > > <servlet> > <servlet-name>RestletServer</servlet-name> > > <servlet-class>org.restlet.ext.spring.SpringServerServlet</servlet-class> > <load-on-startup>1</load-on-startup> > </servlet> > > <servlet-mapping> > <servlet-name>RestletServer</servlet-name> > <url-pattern>/*</url-pattern> > </servlet-mapping> > > My problem is that in my baseResource bean, I create a new > ContextTemplateLoader for FreeMarker to use, and I pass it getContext() > like so: > > /** > * Set the FreeMarker Configuration. > * > * @param freeMarkerConfig The FreeMarker Configuration instance. > */ > public void setFreeMarkerConfig(final Configuration freeMarkerConfig) > { > if (freeMarkerConfig == null) > { > throw new FreeMarkerConfigurationException( > "FreeMarker Configuration cannot be NULL"); > } > > this.freeMarkerConfig = freeMarkerConfig; > > freeMarkerConfig.setTemplateLoader( > new ContextTemplateLoader(getContext(), > "war:///freemarker-templates/")); > } > > public void setFreeMarkerConfigViaConfigurer( > final FreeMarkerConfigurer springFreeMarkerConfigurer) > { > setFreeMarkerConfig(springFreeMarkerConfigurer.getConfiguration()); > } > > but getContext() returns null because the ServerResource's context > member is null. Is there a step I need to set the Context? The > SpringBeanFinder from the Router is passing in a null Context when the > init(Context, Request, Response) method is called on the > ServerResource. Has anyone else experienced this? I have not tried the > SVN trunk of RESTlet yet. > > Many thanks! > Dustin > -- Dustin N. Jenkins | Tel/Tél: 250.363.3101 | [hidden email] facsimile/télécopieur: (250) 363-0045 National Research Council Canada | 5071 West Saanich Rd, Victoria BC. V9E 2E7 Conseil national de recherches Canada | 5071, ch. West Saanich, Victoria (C.-B) V9E 2E7 Government of Canada | Gouvernement du Canada ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2411720 |
||||||||||||||||
|
jlouvel
|
Hi Dustin,
Thanks for all the details. Would it be possible for you to send a mini project (Eclipse or other) that would reproduce the issue? That would really help us resolving any issue quickly. Best regards, Jerome Louvel -- Restlet ~ Founder and Lead developer ~ http://www.restlet.org Noelios Technologies ~ Co-founder ~ http://www.noelios.com Dustin N. Jenkins a écrit : > I should mention too that I have my component defined: > > <!-- The Restlet Component --> > <bean name="component" class="org.restlet.ext.spring.SpringComponent"> > <property name="defaultTarget" ref="application" /> > <property name="context" ref="component.context" /> > <property name="clientsList"> > <list> > <value>http</value> > <value>file</value> > </list> > </property> > </bean> > > <bean name="component.context" > > class="org.springframework.beans.factory.config.PropertyPathFactoryBean" /> > > And also in my web.xml: > > <context-param> > <param-name>org.restlet.component</param-name> > <param-value>component</param-value> > </context-param> > > Thanks! > Dustin > > > Dustin N. Jenkins wrote: > >> Hello! >> >> I'm using Java 1.6, Tomcat 6, RESTlet 2.0M5, Spring 2.5, the supported >> version of FreeMarker, all on Linux. >> >> The relevant part of my spring configuration looks like this: >> >> <bean id="freeMarkerConfig" >> class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer"> >> ... >> </bean> >> >> <bean id="application" name="application" class="org.restlet.Application"> >> <property name="root" ref="router" /> >> ... >> </bean> >> >> <bean name="router" class="org.restlet.ext.spring.SpringBeanRouter" /> >> >> <bean abstract="true" name="baseResource" scope="prototype" >> class="ca.nrc.cadc.dp.web.restlet.resources.AbstractResource"> >> <!-- Method to configure FreeMarker using the FreeMarker Configurer. --> >> <property name="freeMarkerConfigViaConfigurer" >> ref="freeMarkerConfigurer" /> >> </bean> >> >> Which is very straightforward and worked fine with the 1.1.x versions of >> RESTlet. Here are the relevant parts of my web.xml also: >> >> <context-param> >> <param-name>org.restlet.application</param-name> >> <param-value>application</param-value> >> </context-param> >> >> <servlet> >> <servlet-name>RestletServer</servlet-name> >> >> <servlet-class>org.restlet.ext.spring.SpringServerServlet</servlet-class> >> <load-on-startup>1</load-on-startup> >> </servlet> >> >> <servlet-mapping> >> <servlet-name>RestletServer</servlet-name> >> <url-pattern>/*</url-pattern> >> </servlet-mapping> >> >> My problem is that in my baseResource bean, I create a new >> ContextTemplateLoader for FreeMarker to use, and I pass it getContext() >> like so: >> >> /** >> * Set the FreeMarker Configuration. >> * >> * @param freeMarkerConfig The FreeMarker Configuration instance. >> */ >> public void setFreeMarkerConfig(final Configuration freeMarkerConfig) >> { >> if (freeMarkerConfig == null) >> { >> throw new FreeMarkerConfigurationException( >> "FreeMarker Configuration cannot be NULL"); >> } >> >> this.freeMarkerConfig = freeMarkerConfig; >> >> freeMarkerConfig.setTemplateLoader( >> new ContextTemplateLoader(getContext(), >> "war:///freemarker-templates/")); >> } >> >> public void setFreeMarkerConfigViaConfigurer( >> final FreeMarkerConfigurer springFreeMarkerConfigurer) >> { >> setFreeMarkerConfig(springFreeMarkerConfigurer.getConfiguration()); >> } >> >> but getContext() returns null because the ServerResource's context >> member is null. Is there a step I need to set the Context? The >> SpringBeanFinder from the Router is passing in a null Context when the >> init(Context, Request, Response) method is called on the >> ServerResource. Has anyone else experienced this? I have not tried the >> SVN trunk of RESTlet yet. >> >> Many thanks! >> Dustin >> >> > > ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2411727 |
||||||||||||||||
|
Dustin N. Jenkins
|
Hi Jerome,
I sent a tar file containing the source and WAR file, but the attachment was 4.4M in the end. It sent fine, but I haven't seen it pop up on here. Is there a better way to get it to you? Or will it come through eventually? Thanks, Dustin Jerome Louvel wrote: > Hi Dustin, > > Thanks for all the details. Would it be possible for you to send a mini > project (Eclipse or other) that would reproduce the issue? That would > really help us resolving any issue quickly. > > Best regards, > Jerome Louvel > -- > Restlet ~ Founder and Lead developer ~ http://www.restlet.org > Noelios Technologies ~ Co-founder ~ http://www.noelios.com > > > > Dustin N. Jenkins a écrit : > >> I should mention too that I have my component defined: >> >> <!-- The Restlet Component --> >> <bean name="component" class="org.restlet.ext.spring.SpringComponent"> >> <property name="defaultTarget" ref="application" /> >> <property name="context" ref="component.context" /> >> <property name="clientsList"> >> <list> >> <value>http</value> >> <value>file</value> >> </list> >> </property> >> </bean> >> >> <bean name="component.context" >> >> class="org.springframework.beans.factory.config.PropertyPathFactoryBean" /> >> >> And also in my web.xml: >> >> <context-param> >> <param-name>org.restlet.component</param-name> >> <param-value>component</param-value> >> </context-param> >> >> Thanks! >> Dustin >> >> >> Dustin N. Jenkins wrote: >> >> >>> Hello! >>> >>> I'm using Java 1.6, Tomcat 6, RESTlet 2.0M5, Spring 2.5, the supported >>> version of FreeMarker, all on Linux. >>> >>> The relevant part of my spring configuration looks like this: >>> >>> <bean id="freeMarkerConfig" >>> class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer"> >>> ... >>> </bean> >>> >>> <bean id="application" name="application" class="org.restlet.Application"> >>> <property name="root" ref="router" /> >>> ... >>> </bean> >>> >>> <bean name="router" class="org.restlet.ext.spring.SpringBeanRouter" /> >>> >>> <bean abstract="true" name="baseResource" scope="prototype" >>> class="ca.nrc.cadc.dp.web.restlet.resources.AbstractResource"> >>> <!-- Method to configure FreeMarker using the FreeMarker Configurer. --> >>> <property name="freeMarkerConfigViaConfigurer" >>> ref="freeMarkerConfigurer" /> >>> </bean> >>> >>> Which is very straightforward and worked fine with the 1.1.x versions of >>> RESTlet. Here are the relevant parts of my web.xml also: >>> >>> <context-param> >>> <param-name>org.restlet.application</param-name> >>> <param-value>application</param-value> >>> </context-param> >>> >>> <servlet> >>> <servlet-name>RestletServer</servlet-name> >>> >>> <servlet-class>org.restlet.ext.spring.SpringServerServlet</servlet-class> >>> <load-on-startup>1</load-on-startup> >>> </servlet> >>> >>> <servlet-mapping> >>> <servlet-name>RestletServer</servlet-name> >>> <url-pattern>/*</url-pattern> >>> </servlet-mapping> >>> >>> My problem is that in my baseResource bean, I create a new >>> ContextTemplateLoader for FreeMarker to use, and I pass it getContext() >>> like so: >>> >>> /** >>> * Set the FreeMarker Configuration. >>> * >>> * @param freeMarkerConfig The FreeMarker Configuration instance. >>> */ >>> public void setFreeMarkerConfig(final Configuration freeMarkerConfig) >>> { >>> if (freeMarkerConfig == null) >>> { >>> throw new FreeMarkerConfigurationException( >>> "FreeMarker Configuration cannot be NULL"); >>> } >>> >>> this.freeMarkerConfig = freeMarkerConfig; >>> >>> freeMarkerConfig.setTemplateLoader( >>> new ContextTemplateLoader(getContext(), >>> "war:///freemarker-templates/")); >>> } >>> >>> public void setFreeMarkerConfigViaConfigurer( >>> final FreeMarkerConfigurer springFreeMarkerConfigurer) >>> { >>> setFreeMarkerConfig(springFreeMarkerConfigurer.getConfiguration()); >>> } >>> >>> but getContext() returns null because the ServerResource's context >>> member is null. Is there a step I need to set the Context? The >>> SpringBeanFinder from the Router is passing in a null Context when the >>> init(Context, Request, Response) method is called on the >>> ServerResource. Has anyone else experienced this? I have not tried the >>> SVN trunk of RESTlet yet. >>> >>> Many thanks! >>> Dustin >>> >>> >>> >> > > ------------------------------------------------------ > http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2411727 > -- Dustin N. Jenkins | Tel/Tél: 250.363.3101 | [hidden email] facsimile/télécopieur: (250) 363-0045 National Research Council Canada | 5071 West Saanich Rd, Victoria BC. V9E 2E7 Conseil national de recherches Canada | 5071, ch. West Saanich, Victoria (C.-B) V9E 2E7 Government of Canada | Gouvernement du Canada ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2412718 |
||||||||||||||||
|
Dustin N. Jenkins
|
From some further investigation, it looks like the problem stems from
the Finder class still using the deprecated methods, which require the Resource class instead of the ServerResource class. Fixing this may be as simple as overriding the findTarget() method to return the result of the find() method. Dustin Dustin N. Jenkins wrote: > Hi Jerome, > > I sent a tar file containing the source and WAR file, but the attachment > was 4.4M in the end. It sent fine, but I haven't seen it pop up on > here. Is there a better way to get it to you? Or will it come through > eventually? > > Thanks, > Dustin > > > Jerome Louvel wrote: > >> Hi Dustin, >> >> Thanks for all the details. Would it be possible for you to send a mini >> project (Eclipse or other) that would reproduce the issue? That would >> really help us resolving any issue quickly. >> >> Best regards, >> Jerome Louvel >> -- >> Restlet ~ Founder and Lead developer ~ http://www.restlet.org >> Noelios Technologies ~ Co-founder ~ http://www.noelios.com >> >> >> >> Dustin N. Jenkins a écrit : >> >> >>> I should mention too that I have my component defined: >>> >>> <!-- The Restlet Component --> >>> <bean name="component" class="org.restlet.ext.spring.SpringComponent"> >>> <property name="defaultTarget" ref="application" /> >>> <property name="context" ref="component.context" /> >>> <property name="clientsList"> >>> <list> >>> <value>http</value> >>> <value>file</value> >>> </list> >>> </property> >>> </bean> >>> >>> <bean name="component.context" >>> >>> class="org.springframework.beans.factory.config.PropertyPathFactoryBean" /> >>> >>> And also in my web.xml: >>> >>> <context-param> >>> <param-name>org.restlet.component</param-name> >>> <param-value>component</param-value> >>> </context-param> >>> >>> Thanks! >>> Dustin >>> >>> >>> Dustin N. Jenkins wrote: >>> >>> >>> >>>> Hello! >>>> >>>> I'm using Java 1.6, Tomcat 6, RESTlet 2.0M5, Spring 2.5, the supported >>>> version of FreeMarker, all on Linux. >>>> >>>> The relevant part of my spring configuration looks like this: >>>> >>>> <bean id="freeMarkerConfig" >>>> class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer"> >>>> ... >>>> </bean> >>>> >>>> <bean id="application" name="application" class="org.restlet.Application"> >>>> <property name="root" ref="router" /> >>>> ... >>>> </bean> >>>> >>>> <bean name="router" class="org.restlet.ext.spring.SpringBeanRouter" /> >>>> >>>> <bean abstract="true" name="baseResource" scope="prototype" >>>> class="ca.nrc.cadc.dp.web.restlet.resources.AbstractResource"> >>>> <!-- Method to configure FreeMarker using the FreeMarker Configurer. --> >>>> <property name="freeMarkerConfigViaConfigurer" >>>> ref="freeMarkerConfigurer" /> >>>> </bean> >>>> >>>> Which is very straightforward and worked fine with the 1.1.x versions of >>>> RESTlet. Here are the relevant parts of my web.xml also: >>>> >>>> <context-param> >>>> <param-name>org.restlet.application</param-name> >>>> <param-value>application</param-value> >>>> </context-param> >>>> >>>> <servlet> >>>> <servlet-name>RestletServer</servlet-name> >>>> >>>> <servlet-class>org.restlet.ext.spring.SpringServerServlet</servlet-class> >>>> <load-on-startup>1</load-on-startup> >>>> </servlet> >>>> >>>> <servlet-mapping> >>>> <servlet-name>RestletServer</servlet-name> >>>> <url-pattern>/*</url-pattern> >>>> </servlet-mapping> >>>> >>>> My problem is that in my baseResource bean, I create a new >>>> ContextTemplateLoader for FreeMarker to use, and I pass it getContext() >>>> like so: >>>> >>>> /** >>>> * Set the FreeMarker Configuration. >>>> * >>>> * @param freeMarkerConfig The FreeMarker Configuration instance. >>>> */ >>>> public void setFreeMarkerConfig(final Configuration freeMarkerConfig) >>>> { >>>> if (freeMarkerConfig == null) >>>> { >>>> throw new FreeMarkerConfigurationException( >>>> "FreeMarker Configuration cannot be NULL"); >>>> } >>>> >>>> this.freeMarkerConfig = freeMarkerConfig; >>>> >>>> freeMarkerConfig.setTemplateLoader( >>>> new ContextTemplateLoader(getContext(), >>>> "war:///freemarker-templates/")); >>>> } >>>> >>>> public void setFreeMarkerConfigViaConfigurer( >>>> final FreeMarkerConfigurer springFreeMarkerConfigurer) >>>> { >>>> setFreeMarkerConfig(springFreeMarkerConfigurer.getConfiguration()); >>>> } >>>> >>>> but getContext() returns null because the ServerResource's context >>>> member is null. Is there a step I need to set the Context? The >>>> SpringBeanFinder from the Router is passing in a null Context when the >>>> init(Context, Request, Response) method is called on the >>>> ServerResource. Has anyone else experienced this? I have not tried the >>>> SVN trunk of RESTlet yet. >>>> >>>> Many thanks! >>>> Dustin >>>> >>>> >>>> >>>> >>> >>> >> ------------------------------------------------------ >> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2411727 >> >> > > -- Dustin N. Jenkins | Tel/Tél: 250.363.3101 | [hidden email] facsimile/télécopieur: (250) 363-0045 National Research Council Canada | 5071 West Saanich Rd, Victoria BC. V9E 2E7 Conseil national de recherches Canada | 5071, ch. West Saanich, Victoria (C.-B) V9E 2E7 Government of Canada | Gouvernement du Canada ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2412813 |
||||||||||||||||
|
jlouvel
|
Hi Dustin,
The Finder class still uses deprecated methods for backward compatibility purpose. But, the code should be capable of dealing with both Handler/Resource and ServerResource subclasses. Could you create a bug report and attach your test project to it (ideally just a subset allowing us to quickly reproduce). You shouldn't have any attachment size issue this way: http://www.restlet.org/community/issues 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 : Dustin N. Jenkins [mailto:[hidden email]] Envoyé : jeudi 29 octobre 2009 21:26 À : [hidden email] Objet : Re: Null Context in ServerResource through SpringBeanFinder From some further investigation, it looks like the problem stems from the Finder class still using the deprecated methods, which require the Resource class instead of the ServerResource class. Fixing this may be as simple as overriding the findTarget() method to return the result of the find() method. Dustin Dustin N. Jenkins wrote: > Hi Jerome, > > I sent a tar file containing the source and WAR file, but the attachment > was 4.4M in the end. It sent fine, but I haven't seen it pop up on > here. Is there a better way to get it to you? Or will it come through > eventually? > > Thanks, > Dustin > > > Jerome Louvel wrote: > >> Hi Dustin, >> >> Thanks for all the details. Would it be possible for you to send a mini >> project (Eclipse or other) that would reproduce the issue? That would >> really help us resolving any issue quickly. >> >> Best regards, >> Jerome Louvel >> -- >> Restlet ~ Founder and Lead developer ~ http://www.restlet.org >> Noelios Technologies ~ Co-founder ~ http://www.noelios.com >> >> >> >> Dustin N. Jenkins a écrit : >> >> >>> I should mention too that I have my component defined: >>> >>> <!-- The Restlet Component --> >>> <bean name="component" class="org.restlet.ext.spring.SpringComponent"> >>> <property name="defaultTarget" ref="application" /> >>> <property name="context" ref="component.context" /> >>> <property name="clientsList"> >>> <list> >>> <value>http</value> >>> <value>file</value> >>> </list> >>> </property> >>> </bean> >>> >>> <bean name="component.context" >>> >>> class="org.springframework.beans.factory.config.PropertyPathFactoryBean" /> >>> >>> And also in my web.xml: >>> >>> <context-param> >>> <param-name>org.restlet.component</param-name> >>> <param-value>component</param-value> >>> </context-param> >>> >>> Thanks! >>> Dustin >>> >>> >>> Dustin N. Jenkins wrote: >>> >>> >>> >>>> Hello! >>>> >>>> I'm using Java 1.6, Tomcat 6, RESTlet 2.0M5, Spring 2.5, the supported >>>> version of FreeMarker, all on Linux. >>>> >>>> The relevant part of my spring configuration looks like this: >>>> >>>> <bean id="freeMarkerConfig" >>>> class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer"> >>>> ... >>>> </bean> >>>> >>>> <bean id="application" name="application" class="org.restlet.Application"> >>>> <property name="root" ref="router" /> >>>> ... >>>> </bean> >>>> >>>> <bean name="router" class="org.restlet.ext.spring.SpringBeanRouter" /> >>>> >>>> <bean abstract="true" name="baseResource" scope="prototype" >>>> class="ca.nrc.cadc.dp.web.restlet.resources.AbstractResource"> >>>> <!-- Method to configure FreeMarker using the FreeMarker Configurer. --> >>>> <property name="freeMarkerConfigViaConfigurer" >>>> ref="freeMarkerConfigurer" /> >>>> </bean> >>>> >>>> Which is very straightforward and worked fine with the 1.1.x versions of >>>> RESTlet. Here are the relevant parts of my web.xml also: >>>> >>>> <context-param> >>>> <param-name>org.restlet.application</param-name> >>>> <param-value>application</param-value> >>>> </context-param> >>>> >>>> <servlet> >>>> <servlet-name>RestletServer</servlet-name> >>>> >>>> <servlet-class>org.restlet.ext.spring.SpringServerServlet</servlet-class> >>>> <load-on-startup>1</load-on-startup> >>>> </servlet> >>>> >>>> <servlet-mapping> >>>> <servlet-name>RestletServer</servlet-name> >>>> <url-pattern>/*</url-pattern> >>>> </servlet-mapping> >>>> >>>> My problem is that in my baseResource bean, I create a new >>>> ContextTemplateLoader for FreeMarker to use, and I pass it getContext() >>>> like so: >>>> >>>> /** >>>> * Set the FreeMarker Configuration. >>>> * >>>> * @param freeMarkerConfig The FreeMarker Configuration instance. >>>> */ >>>> public void setFreeMarkerConfig(final Configuration freeMarkerConfig) >>>> { >>>> if (freeMarkerConfig == null) >>>> { >>>> throw new FreeMarkerConfigurationException( >>>> "FreeMarker Configuration cannot be NULL"); >>>> } >>>> >>>> this.freeMarkerConfig = freeMarkerConfig; >>>> >>>> freeMarkerConfig.setTemplateLoader( >>>> new ContextTemplateLoader(getContext(), >>>> "war:///freemarker-templates/")); >>>> } >>>> >>>> public void setFreeMarkerConfigViaConfigurer( >>>> final FreeMarkerConfigurer springFreeMarkerConfigurer) >>>> { >>>> setFreeMarkerConfig(springFreeMarkerConfigurer.getConfiguration()); >>>> } >>>> >>>> but getContext() returns null because the ServerResource's context >>>> member is null. Is there a step I need to set the Context? The >>>> SpringBeanFinder from the Router is passing in a null Context when the >>>> init(Context, Request, Response) method is called on the >>>> ServerResource. Has anyone else experienced this? I have not tried the >>>> SVN trunk of RESTlet yet. >>>> >>>> Many thanks! >>>> Dustin >>>> >>>> >>>> >>>> >>> >>> >> ------------------------------------------------------ >> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2411727 >> >> > > -- Dustin N. Jenkins | Tel/Tél: 250.363.3101 | [hidden email] facsimile/télécopieur: (250) 363-0045 National Research Council Canada | 5071 West Saanich Rd, Victoria BC. V9E 2E7 Conseil national de recherches Canada | 5071, ch. West Saanich, Victoria (C.-B) V9E 2E7 Government of Canada | Gouvernement du Canada ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2412813 ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2413741 |
||||||||||||||||
| Free Embeddable Forum Powered by Nabble | Help |