Actually, I had a compatibility bug with Turbine when they upgraded
ExtendedProperties and it started using backslash to escape characters.  A
real pain.  UNC paths (and any Windows path with a '\') would generate
errors due to invalid escape codes.

We should fix the Velocity docs to note this.

WILL

On 9/10/07, Nathan Bubna <[EMAIL PROTECTED]> wrote:
>
> You only need to have one of those in your classpath.  the
> velocity-dep jar contains classes from Commons Collections 3.1,
> especially the ExtendedProperties class, which i suspect is the guilty
> party here.   given the code you've shown me, all Velocity does with
> your path is put it into an ExtendedProperties instance, pull it out
> later, and use String.trim() to remove whitespace from the outside of
> it.
>
> Looking at
>
> http://commons.apache.org/collections/api/org/apache/commons/collections/ExtendedProperties.html
>
> it appears that ExtendedProperties does use backslashes for escaping
> commas and new lines; i would not be at all surprised to find that it
> uses them to escape backslashes too.
>
> you can ask the Apache Commons' user list for confirmation or more
> info on the whys and hows of that, or complain if you feel that's
> inappropriate.
>
> as far as Velocity goes, feel free to open a JIRA issue reporting this
> and requesting a change in behavior.  that would be a good place to
> marshall arguments for or against preempting or undoing any String
> manipulations performed on Velocity properties by the
> ExtendedProperties class.  it will also keep this from being
> forgotten.  feel free to include content from this thread in the issue
> description.
>
> On 9/10/07, Peter Steele <[EMAIL PROTECTED]> wrote:
> > My libraries list for this project includes both velocity-1.5.jar and
> velocity-dep-1.5.jar.
> >
> > -----Original Message-----
> > From: Nathan Bubna [mailto:[EMAIL PROTECTED]
> > Sent: Saturday, September 08, 2007 8:22 AM
> > To: Velocity Users List
> > Subject: Re: UNC paths in Velocity
> >
> > Commons Collections is one of Velocity's dependencies.  In the case of
> > this particular bug, we are concerned about how their
> > ExtendedProperties class might be treating your backslashes.
> >
> > Are you using the velocity-dep jar? (which includes all needed
> dependencies)
> > or the plain velocity jar? (in which case you would need to include a
> > commons-collections jar in your app as well)
> >
> > On 9/7/07, Peter Steele <[EMAIL PROTECTED]> wrote:
> > > I am using Velocity 1.5 and JDK 1.6 under Eclipse 3.3. Not sure what
> you mean by the Commons Collection; I'm a relative Java newbie...
> > >
> > > -----Original Message-----
> > > From: Nathan Bubna [mailto:[EMAIL PROTECTED]
> > > Sent: Thursday, September 06, 2007 12:22 PM
> > > To: Velocity Users List
> > > Subject: Re: UNC paths in Velocity
> > >
> > > Oh, and it would be good to know the versions of Velocity, Commons
> > > Collections, and the JDK that you are using.
> > >
> > > On 9/6/07, Nathan Bubna <[EMAIL PROTECTED]> wrote:
> > > > I've looked through the relevant code, and i don't see Velocity
> > > > stripping out backslashes explicitly anywhere.  It could be
> happening
> > > > within Commons Collections' ExtendedProperties class (which is where
> > > > the property is stored by the runtime instance and from which it is
> > > > retrieved by the FileResourceLoader), though that would be
> surprising.
> > > >  i haven't the time to look into it that right now.  anyway, if it's
> > > > not happening there, then the only other possible culprit is java
> > > > (either String.trim() or some other string method used within
> > > > ExtendedProperties).  There's really not much in the path between
> > > > Velocity.setProperty() and the log message printed by
> > > > FileResourceLoader (where the backslash is missing).
> > > >
> > > > On 9/6/07, Peter Steele <[EMAIL PROTECTED]> wrote:
> > > > > I'd be happy not to use backslashes, except that in my case the
> path that created problems was given to me by Java's getAbsolutePath()
> method. Because I'm running under Windows, it returns a Windows path, using
> backslashes, as it should. Velocity should in turn be able to handle such a
> path because it is in fact a valid Windows path.
> > > > >
> > > > > -----Original Message-----
> > > > > From: Gonzalo Diethelm [mailto:[EMAIL PROTECTED]
> > > > > Sent: Monday, September 03, 2007 5:49 AM
> > > > > To: Velocity Users List
> > > > > Subject: Re: UNC paths in Velocity
> > > > >
> > > > > Allow me to paste my very last reply to this list. Regardless of
> the '/'
> > > > > vs '\' issue, Velocity does have a very quirky way of handling
> > > > > backslashes... Best regards.
> > > > >
> > > > >
> > > > >         I suggest you NEVER use the backslash character for path
> > > > >         delimiters. As far as I know, C, C++, C# and Java all
> understand
> > > > >         the forward slash as a path separator, with the benefits
> of
> > > > >         portable code and not having to quote and re-quote the
> > > > >         backslash. Therefore, try something like
> > > > >         "//myserver/home/peter/myproj/template".
> > > > >
> > > > >
> > > > > On Fri, 2007-08-31 at 07:50 -0700, Peter Steele wrote:
> > > > >
> > > > > > Velocity does not seem to properly support UNC paths under
> Windows. I am running from a network drive on a Vista box and want to point
> Velocity to a location relative to my current dir to find my template files.
> I have code similar to the following:
> > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >         String templateDir = new File("templates");
> > > > > >
> > > > > >         String absTemplateDir = templateDir.getAbsolutePath();
> > > > > >
> > > > > >         Velocity.setProperty(
> RuntimeConstants.FILE_RESOURCE_LOADER_PATH, absTemplateDir);
> > > > > >
> > > > > >         Velocity.init();
> > > > > >
> > > > > >         Template myTemplate = Velocity.getTemplate
> ("my_template.vm");
> > > > > >
> > > > > >
> > > > > >
> > > > > > The getTemplate call fails saying that it cannot find the file.
> The init call explains why: it generates a log message similar to this:
> > > > > >
> > > > > >
> > > > > >
> > > > > > INFO: FileResourceLoader : adding path
> '\myserver\home\peter\myproj\template'
> > > > > >
> > > > > >
> > > > > >
> > > > > > The file path *should* be
> '\\myserver\home\peter\myproj\template', but Velocity strips one of the
> leading backslashes. The original string is correct that's returned by
> getAbsolutePath, with four backslashes representing two real backslashes:
> > > > > >
> > > > > >
> > > > > >
> > > > > >       \\\\myserver\\home\\peter\\myproj\\template
> > > > > >
> > > > > >
> > > > > >
> > > > > > This is what I'd expect. This doesn't seem to satisfy Velocity
> though. If I manually set the string to
> > > > > >
> > > > > >
> > > > > >
> > > > > >       \\\\\\\\\\myserver\\home\\peter\\myproj\\template
> > > > > >
> > > > > >
> > > > > >
> > > > > > this solves the problem. What I ended up doing though was this:
> > > > > >
> > > > > >
> > > > > >
> > > > > >         String absTemplateDir = 
> > > > > > templateDir.getAbsolutePath().replace('\\',
> '/');
> > > > > >
> > > > > >
> > > > > >
> > > > > > This also works, so obviously the problem has something to do
> with interpreting the leading backslash characters that represent the
> Windows UNC path. This seems like a bug to me…
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > No virus found in this outgoing message.
> > > > > > Checked by AVG Free Edition.
> > > > > > Version: 7.5.484 / Virus Database: 269.13.1/981 - Release Date:
> 8/31/2007 6:13 AM
> > > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Gonzalo Diethelm
> > > > > [EMAIL PROTECTED]
> > > > >
> > > > > No virus found in this incoming message.
> > > > > Checked by AVG Free Edition.
> > > > > Version: 7.5.484 / Virus Database: 269.13.3/986 - Release Date:
> 9/3/2007 9:31 AM
> > > > >
> > > > >
> > > > > No virus found in this outgoing message.
> > > > > Checked by AVG Free Edition.
> > > > > Version: 7.5.485 / Virus Database: 269.13.7/992 - Release Date:
> 9/6/2007 8:36 AM
> > > > >
> > > > >
> > > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > >
> > >
> > > No virus found in this incoming message.
> > > Checked by AVG Free Edition.
> > > Version: 7.5.485 / Virus Database: 269.13.7/992 - Release Date:
> 9/6/2007 8:36 AM
> > >
> > >
> > > No virus found in this outgoing message.
> > > Checked by AVG Free Edition.
> > > Version: 7.5.485 / Virus Database: 269.13.8/993 - Release Date:
> 9/6/2007 3:18 PM
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> > No virus found in this incoming message.
> > Checked by AVG Free Edition.
> > Version: 7.5.485 / Virus Database: 269.13.9/994 - Release Date: 9/7/2007
> 4:40 PM
> >
> >
> > No virus found in this outgoing message.
> > Checked by AVG Free Edition.
> > Version: 7.5.485 / Virus Database: 269.13.13/998 - Release Date:
> 9/10/2007 8:48 AM
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


-- 
Forio Business Simulations

Will Glass-Husain
[EMAIL PROTECTED]
www.forio.com

Reply via email to