You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by prabhakar thopa <pr...@yahoo.com> on 2007/04/26 03:11:42 UTC

Re: Velocity and case insensitive template paths

Hi,

Can the velocity engine work with case-insensitive template names?

I have an spring based web application, where the template paths are read from a database and fed to the velocity engine. The problem I have is, that some of the database values of the template paths do not match the actual file names in the  in case.
So i run into 404 errors.

Is it possible to make the velocity engine ignore case, when processing templates.

Thanks

Prabhakar

----- Original Message ----
From: Nathan Bubna <nb...@gmail.com>
To: Velocity Users List <us...@velocity.apache.org>
Sent: Wednesday, April 25, 2007 8:19:11 PM
Subject: Re: Velocity, StringResourceLoader and Tomcat


It's all checked in.  Tino, if you want to use the new version, you
can find it at:

http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/StringResourceLoader.java?revision=532549&view=markup

And of course, this will be in the 1.6 release (no timetable on that though).

On 4/25/07, Nathan Bubna <nb...@gmail.com> wrote:
> Ok, i created an issue myself and took some time today to fix
> StringResourceLoader to use repository(s) sanely.   I'm still writing
> some new tests for it but will check it in soon.
>
> http://issues.apache.org/jira/browse/VELOCITY-541
>
> On 4/24/07, Nathan Bubna <nb...@gmail.com> wrote:
> > Would you be willing to open a JIRA issue and attach a patch with your
> > changes to StringResourceLoader?  It would speed up the process of
> > fixing it. ;)
> >
> > http://issues.apache.org/jira/browse/VELOCITY
> >
> > On 4/23/07, Tino Schöllhorn <t....@plattform-gmbh.de> wrote:
> > > Hi,
> > >
> > > I looked in the code and your description is exactly the problem. Now I
> > > wrote an StringResourceLoader on my own which works fine.
> > >
> > > But the StringResourceLoader would be great if it worked correctly. ;-)
> > >
> > > With regards
> > > Tino
> > >
> > > Nathan Bubna wrote:
> > > > It appears to mean that multiple StringResourceLoaders are being
> > > > initialized and the later ones are blowing up.   StringResourceLoader
> > > > uses a static RepositoryFactory.  Unfortunately i think this means
> > > > that you can really only have one StringResourceLoader per
> > > > classloader.  Sorry about this, it's a new feature and apparently
> > > > hasn't had all its usecases tested.
> > > >
> > > > i'll ping the dev list about this and/or try and look into it more
> > > > myself.  there should be a way to use multiple
> > > > StringResourceLoaders...
> > > >
> > > > in the meantime, you may want to make sure your app only instantiates
> > > > one VelocityEngine that uses a StringResourceLoader.
> > > >
> > > > On 4/23/07, Tino Schöllhorn <t....@plattform-gmbh.de> wrote:
> > > >> Hi,
> > > >>
> > > >> we are using Tomcat, Spring and Velocity 1.5. A first application
> > > >> (without Tomcat) is running fine - it just uses Velocity to parse an
> > > >> simple "Hello World" template which we provide in the
> > > >> StringResourceRepository.
> > > >>
> > > >> But as soon as we want to integrate this in our web-application we
> > > >> encounter the following error:
> > > >>
> > > >> Error creating bean with name 'velocityEngine' defined in class path
> > > >> resource [appCxt-kernelBase.xml]: Invocation of init method failed;
> > > >> nested exception is java.lang.IllegalStateException: The
> > > >> RepositoryFactory has already been initialized!
> > > >>         at
> > > >> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1148)
> > > >>
> > > >>         ....
> > > >>
> > > >>
> > > >> Does anyone know what the problem might be?
> > > >>
> > > >> With regards
> > > >> Tino
> > > >>
> > > >> ps:
> > > >>
> > > >> We are using the follwowing spring-bean configuration:
> > > >>
> > > >> <bean id="velocityEngine"
> > > >>
> > > >> class="org.springframework.ui.velocity.VelocityEngineFactoryBean">
> > > >>
> > > >>     <property name="velocityProperties">
> > > >>         <props>
> > > >>         <prop key="resource.loader">string</prop>
> > > >>          <prop key="string.resource.loader.class">
> > > >> org.apache.velocity.runtime.resource.loader.StringResourceLoader
> > > >>            </prop>
> > > >>          </props>
> > > >>     </property>
> > > >> </bean>
> > > >>
> > > >>
> > > >> ---------------------------------------------------------------------
> > > >> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> > > >> For additional commands, e-mail: user-help@velocity.apache.org
> > > >>
> > > >>
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> > > For additional commands, e-mail: user-help@velocity.apache.org
> > >
> > >
> >
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


Re: Velocity and case insensitive template paths

Posted by Will Glass-Husain <wg...@gmail.com>.
Would it be possible to just make everything lower case?

WILL

On 4/25/07, Nathan Bubna <nb...@gmail.com> wrote:
>
> There's no provision for doing this built into Velocity.  You may be
> able to subclass whatever resource loader you are using in order to
> adjust the requested paths to match the actual file names.
>
> On 4/25/07, prabhakar thopa <pr...@yahoo.com> wrote:
> > Hi,
> >
> > Can the velocity engine work with case-insensitive template names?
> >
> > I have an spring based web application, where the template paths are
> read from a database and fed to the velocity engine. The problem I have is,
> that some of the database values of the template paths do not match the
> actual file names in the  in case.
> > So i run into 404 errors.
> >
> > Is it possible to make the velocity engine ignore case, when processing
> templates.
> >
> > Thanks
> >
> > Prabhakar
> >
> > ----- Original Message ----
> > From: Nathan Bubna <nb...@gmail.com>
> > To: Velocity Users List <us...@velocity.apache.org>
> > Sent: Wednesday, April 25, 2007 8:19:11 PM
> > Subject: Re: Velocity, StringResourceLoader and Tomcat
> >
> >
> > It's all checked in.  Tino, if you want to use the new version, you
> > can find it at:
> >
> >
> http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/StringResourceLoader.java?revision=532549&view=markup
> >
> > And of course, this will be in the 1.6 release (no timetable on that
> though).
> >
> > On 4/25/07, Nathan Bubna <nb...@gmail.com> wrote:
> > > Ok, i created an issue myself and took some time today to fix
> > > StringResourceLoader to use repository(s) sanely.   I'm still writing
> > > some new tests for it but will check it in soon.
> > >
> > > http://issues.apache.org/jira/browse/VELOCITY-541
> > >
> > > On 4/24/07, Nathan Bubna <nb...@gmail.com> wrote:
> > > > Would you be willing to open a JIRA issue and attach a patch with
> your
> > > > changes to StringResourceLoader?  It would speed up the process of
> > > > fixing it. ;)
> > > >
> > > > http://issues.apache.org/jira/browse/VELOCITY
> > > >
> > > > On 4/23/07, Tino Schöllhorn <t....@plattform-gmbh.de> wrote:
> > > > > Hi,
> > > > >
> > > > > I looked in the code and your description is exactly the problem.
> Now I
> > > > > wrote an StringResourceLoader on my own which works fine.
> > > > >
> > > > > But the StringResourceLoader would be great if it worked
> correctly. ;-)
> > > > >
> > > > > With regards
> > > > > Tino
> > > > >
> > > > > Nathan Bubna wrote:
> > > > > > It appears to mean that multiple StringResourceLoaders are being
> > > > > > initialized and the later ones are blowing up.
> StringResourceLoader
> > > > > > uses a static RepositoryFactory.  Unfortunately i think this
> means
> > > > > > that you can really only have one StringResourceLoader per
> > > > > > classloader.  Sorry about this, it's a new feature and
> apparently
> > > > > > hasn't had all its usecases tested.
> > > > > >
> > > > > > i'll ping the dev list about this and/or try and look into it
> more
> > > > > > myself.  there should be a way to use multiple
> > > > > > StringResourceLoaders...
> > > > > >
> > > > > > in the meantime, you may want to make sure your app only
> instantiates
> > > > > > one VelocityEngine that uses a StringResourceLoader.
> > > > > >
> > > > > > On 4/23/07, Tino Schöllhorn <t....@plattform-gmbh.de>
> wrote:
> > > > > >> Hi,
> > > > > >>
> > > > > >> we are using Tomcat, Spring and Velocity 1.5. A first
> application
> > > > > >> (without Tomcat) is running fine - it just uses Velocity to
> parse an
> > > > > >> simple "Hello World" template which we provide in the
> > > > > >> StringResourceRepository.
> > > > > >>
> > > > > >> But as soon as we want to integrate this in our web-application
> we
> > > > > >> encounter the following error:
> > > > > >>
> > > > > >> Error creating bean with name 'velocityEngine' defined in class
> path
> > > > > >> resource [appCxt-kernelBase.xml]: Invocation of init method
> failed;
> > > > > >> nested exception is java.lang.IllegalStateException: The
> > > > > >> RepositoryFactory has already been initialized!
> > > > > >>         at
> > > > > >>
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean
> (AbstractAutowireCapableBeanFactory.java:1148)
> > > > > >>
> > > > > >>         ....
> > > > > >>
> > > > > >>
> > > > > >> Does anyone know what the problem might be?
> > > > > >>
> > > > > >> With regards
> > > > > >> Tino
> > > > > >>
> > > > > >> ps:
> > > > > >>
> > > > > >> We are using the follwowing spring-bean configuration:
> > > > > >>
> > > > > >> <bean id="velocityEngine"
> > > > > >>
> > > > > >> class="
> org.springframework.ui.velocity.VelocityEngineFactoryBean">
> > > > > >>
> > > > > >>     <property name="velocityProperties">
> > > > > >>         <props>
> > > > > >>         <prop key="resource.loader">string</prop>
> > > > > >>          <prop key="string.resource.loader.class">
> > > > > >>
> org.apache.velocity.runtime.resource.loader.StringResourceLoader
> > > > > >>            </prop>
> > > > > >>          </props>
> > > > > >>     </property>
> > > > > >> </bean>
> > > > > >>
> > > > > >>
> > > > > >>
> ---------------------------------------------------------------------
> > > > > >> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> > > > > >> For additional commands, e-mail: user-help@velocity.apache.org
> > > > > >>
> > > > > >>
> > > > >
> > > > >
> > > > >
> ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> > > > > For additional commands, e-mail: user-help@velocity.apache.org
> > > > >
> > > > >
> > > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> > For additional commands, e-mail: user-help@velocity.apache.org
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam?  Yahoo! Mail has the best spam protection around
> > http://mail.yahoo.com
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> > For additional commands, e-mail: user-help@velocity.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>


-- 
Forio Business Simulations

Will Glass-Husain
wglass@forio.com
www.forio.com

Re: Velocity and case insensitive template paths

Posted by Nathan Bubna <nb...@gmail.com>.
There's no provision for doing this built into Velocity.  You may be
able to subclass whatever resource loader you are using in order to
adjust the requested paths to match the actual file names.

On 4/25/07, prabhakar thopa <pr...@yahoo.com> wrote:
> Hi,
>
> Can the velocity engine work with case-insensitive template names?
>
> I have an spring based web application, where the template paths are read from a database and fed to the velocity engine. The problem I have is, that some of the database values of the template paths do not match the actual file names in the  in case.
> So i run into 404 errors.
>
> Is it possible to make the velocity engine ignore case, when processing templates.
>
> Thanks
>
> Prabhakar
>
> ----- Original Message ----
> From: Nathan Bubna <nb...@gmail.com>
> To: Velocity Users List <us...@velocity.apache.org>
> Sent: Wednesday, April 25, 2007 8:19:11 PM
> Subject: Re: Velocity, StringResourceLoader and Tomcat
>
>
> It's all checked in.  Tino, if you want to use the new version, you
> can find it at:
>
> http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/StringResourceLoader.java?revision=532549&view=markup
>
> And of course, this will be in the 1.6 release (no timetable on that though).
>
> On 4/25/07, Nathan Bubna <nb...@gmail.com> wrote:
> > Ok, i created an issue myself and took some time today to fix
> > StringResourceLoader to use repository(s) sanely.   I'm still writing
> > some new tests for it but will check it in soon.
> >
> > http://issues.apache.org/jira/browse/VELOCITY-541
> >
> > On 4/24/07, Nathan Bubna <nb...@gmail.com> wrote:
> > > Would you be willing to open a JIRA issue and attach a patch with your
> > > changes to StringResourceLoader?  It would speed up the process of
> > > fixing it. ;)
> > >
> > > http://issues.apache.org/jira/browse/VELOCITY
> > >
> > > On 4/23/07, Tino Schöllhorn <t....@plattform-gmbh.de> wrote:
> > > > Hi,
> > > >
> > > > I looked in the code and your description is exactly the problem. Now I
> > > > wrote an StringResourceLoader on my own which works fine.
> > > >
> > > > But the StringResourceLoader would be great if it worked correctly. ;-)
> > > >
> > > > With regards
> > > > Tino
> > > >
> > > > Nathan Bubna wrote:
> > > > > It appears to mean that multiple StringResourceLoaders are being
> > > > > initialized and the later ones are blowing up.   StringResourceLoader
> > > > > uses a static RepositoryFactory.  Unfortunately i think this means
> > > > > that you can really only have one StringResourceLoader per
> > > > > classloader.  Sorry about this, it's a new feature and apparently
> > > > > hasn't had all its usecases tested.
> > > > >
> > > > > i'll ping the dev list about this and/or try and look into it more
> > > > > myself.  there should be a way to use multiple
> > > > > StringResourceLoaders...
> > > > >
> > > > > in the meantime, you may want to make sure your app only instantiates
> > > > > one VelocityEngine that uses a StringResourceLoader.
> > > > >
> > > > > On 4/23/07, Tino Schöllhorn <t....@plattform-gmbh.de> wrote:
> > > > >> Hi,
> > > > >>
> > > > >> we are using Tomcat, Spring and Velocity 1.5. A first application
> > > > >> (without Tomcat) is running fine - it just uses Velocity to parse an
> > > > >> simple "Hello World" template which we provide in the
> > > > >> StringResourceRepository.
> > > > >>
> > > > >> But as soon as we want to integrate this in our web-application we
> > > > >> encounter the following error:
> > > > >>
> > > > >> Error creating bean with name 'velocityEngine' defined in class path
> > > > >> resource [appCxt-kernelBase.xml]: Invocation of init method failed;
> > > > >> nested exception is java.lang.IllegalStateException: The
> > > > >> RepositoryFactory has already been initialized!
> > > > >>         at
> > > > >> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1148)
> > > > >>
> > > > >>         ....
> > > > >>
> > > > >>
> > > > >> Does anyone know what the problem might be?
> > > > >>
> > > > >> With regards
> > > > >> Tino
> > > > >>
> > > > >> ps:
> > > > >>
> > > > >> We are using the follwowing spring-bean configuration:
> > > > >>
> > > > >> <bean id="velocityEngine"
> > > > >>
> > > > >> class="org.springframework.ui.velocity.VelocityEngineFactoryBean">
> > > > >>
> > > > >>     <property name="velocityProperties">
> > > > >>         <props>
> > > > >>         <prop key="resource.loader">string</prop>
> > > > >>          <prop key="string.resource.loader.class">
> > > > >> org.apache.velocity.runtime.resource.loader.StringResourceLoader
> > > > >>            </prop>
> > > > >>          </props>
> > > > >>     </property>
> > > > >> </bean>
> > > > >>
> > > > >>
> > > > >> ---------------------------------------------------------------------
> > > > >> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> > > > >> For additional commands, e-mail: user-help@velocity.apache.org
> > > > >>
> > > > >>
> > > >
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> > > > For additional commands, e-mail: user-help@velocity.apache.org
> > > >
> > > >
> > >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org