<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>6454</bug_id>
          
          <creation_ts>2009-01-19 22:43:20 +0000</creation_ts>
          <short_desc>Velocity unable to find templates when running from css-validator.jar</short_desc>
          <delta_ts>2009-01-21 18:25:48 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>CSSValidator</product>
          <component>Other</component>
          <version>CSS Validator</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Marshall Roch">mroch</reporter>
          <assigned_to name="Olivier Thereaux">ot</assigned_to>
          <cc>jean-gui</cc>
    
    <cc>mroch</cc>
          
          <qa_contact name="qa-dev tracking">www-validator-cvs</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>23169</commentid>
    <comment_count>0</comment_count>
    <who name="Marshall Roch">mroch</who>
    <bug_when>2009-01-19 22:43:20 +0000</bug_when>
    <thetext>After applying the patch I attached to bug 5578 to fix that problem, Velocity can&apos;t find the &lt;format&gt;.properties files (e.g. text.properties) when running from the command line:

Unable to find resource &apos;text.properties&apos;
org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource &apos;text.properties&apos;
	at org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(ResourceManagerImpl.java:452)
	at org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource(ResourceManagerImpl.java:335)
	at org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:1102)
	at org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:1077)
	at org.apache.velocity.runtime.RuntimeSingleton.getTemplate(RuntimeSingleton.java:303)
	at org.apache.velocity.app.Velocity.getTemplate(Velocity.java:503)
	at org.w3c.css.css.StyleSheetGenerator.&lt;init&gt;(StyleSheetGenerator.java:160)
	at org.w3c.css.css.StyleReportFactory.getStyleReport(StyleReportFactory.java:19)
	at org.w3c.css.css.CssValidator.handleRequest(CssValidator.java:178)
	at org.w3c.css.css.CssValidator.main(CssValidator.java:151)
java.lang.NullPointerException
	at org.w3c.css.css.StyleSheetGenerator.print(StyleSheetGenerator.java:418)
	at org.w3c.css.css.CssValidator.handleRequest(CssValidator.java:187)
	at org.w3c.css.css.CssValidator.main(CssValidator.java:151)

Relevant lines from the log:

[info] Velocity not initialized yet. Calling init()...
[debug] Starting Apache Velocity v1.5 (compiled: 2007-02-22 08:52:29)
[trace] RuntimeInstance initializing.
[debug] Default Properties File: org/apache/velocity/runtime/defaults/velocity.properties
[debug] Default ResourceManager initializing. (class org.apache.velocity.runtime.resource.ResourceManagerImpl)
[debug] ResourceLoader instantiated: org.apache.velocity.runtime.resource.loader.FileResourceLoader
[trace] FileResourceLoader : initialization starting.
[info] FileResourceLoader : adding path &apos;.&apos;
[trace] FileResourceLoader : initialization complete.
...
[error] ResourceManager : unable to find resource &apos;text.properties&apos; in any resource loader.

It is looking for text.properties in . (current directory) rather than inside css-validator.jar. If you copy text.proprties to the current dir, it works.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>23181</commentid>
    <comment_count>1</comment_count>
    <who name="Jean-Guilhem Rouel">jean-gui</who>
    <bug_when>2009-01-20 14:54:23 +0000</bug_when>
    <thetext>This problem should be fixed in the latest cvs revision.
Please give it a try and let me know if that works for you.

Jean-Gui</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>23204</commentid>
    <comment_count>2</comment_count>
    <who name="Marshall Roch">mroch</who>
    <bug_when>2009-01-21 07:05:21 +0000</bug_when>
    <thetext>Works, thanks!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>23205</commentid>
    <comment_count>3</comment_count>
    <who name="Marshall Roch">mroch</who>
    <bug_when>2009-01-21 08:39:00 +0000</bug_when>
    <thetext>Actually it doesn&apos;t... it works if you do &quot;ant jar; java -jar css-validator.jar ...&quot; because `org/w3c/css/css` is in the same directory. Try moving the jar elsewhere and it fails:

{output=text, medium=all, warning=2, profile=css21, lang=en}
Jan 21, 2009 12:33:44 AM org.apache.velocity.runtime.log.JdkLogChute log
INFO: Velocity not initialized yet. Calling init()...
Jan 21, 2009 12:33:44 AM org.apache.velocity.runtime.log.JdkLogChute log
INFO: FileResourceLoader : adding path &apos;.&apos;
Jan 21, 2009 12:33:44 AM org.apache.velocity.runtime.log.JdkLogChute log
SEVERE: ResourceManager : unable to find resource &apos;org/w3c/css/css/text.properties&apos; in any resource loader.
Unable to find resource &apos;org/w3c/css/css/text.properties&apos;
org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource &apos;org/w3c/css/css/text.properties&apos;
	at org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(ResourceManagerImpl.java:452)
	at org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource(ResourceManagerImpl.java:335)
	at org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:1102)
	at org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:1077)
	at org.apache.velocity.runtime.RuntimeSingleton.getTemplate(RuntimeSingleton.java:303)
	at org.apache.velocity.app.Velocity.getTemplate(Velocity.java:503)
	at org.w3c.css.css.StyleSheetGenerator.&lt;init&gt;(StyleSheetGenerator.java:160)
	at org.w3c.css.css.StyleReportFactory.getStyleReport(StyleReportFactory.java:19)
	at org.w3c.css.css.CssValidator.handleRequest(CssValidator.java:178)
	at org.w3c.css.css.CssValidator.main(CssValidator.java:151)
java.lang.NullPointerException
	at org.w3c.css.css.StyleSheetGenerator.print(StyleSheetGenerator.java:418)
	at org.w3c.css.css.CssValidator.handleRequest(CssValidator.java:187)
	at org.w3c.css.css.CssValidator.main(CssValidator.java:151)

Is it possible for IndexGenerator.java to tell whether it&apos;s inside a jar and use Velocity&apos;s JarResourceLoader instead? Or, if it was possible to specify the template path as an argument, then we could either store our own templates outside the jar, or pass &quot;jar:file:/path/to/css-validator.jar!/org/w3c/css/css/&quot; to use the templates inside the jar.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>23210</commentid>
    <comment_count>4</comment_count>
    <who name="Jean-Guilhem Rouel">jean-gui</who>
    <bug_when>2009-01-21 18:25:48 +0000</bug_when>
    <thetext>Jar files are driving me nuts... Anyway, I think this should be fixed for good this time, using JarResourceLoader.
So now, if the validator finds templates in the filesystem (in org/w3c/css/css, same basedir as css-validator.jar), it uses them. If not, it uses the ones bundled in css-validator.jar.

Note that lib/ dir needs to be at the same place as css-validator.jar (AFAIK there&apos;s no way to bundle jars into jars), but that&apos;s the only restriction. You can run css-validator.jar from anywhere, that should work too (I&apos;m not too proud of that part though).

Marshall, does that work for you too?</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>