CssValidator/Installation

From W3C Wiki

This page is a draft aimed at providing a replacement documentation for http://jigsaw.w3.org/css-validator/RUN.html and http://jigsaw.w3.org/css-validator/DOWNLOAD.html

  • DOWNLOAD should just have indication of cvs source availability, and should propose at least a JAR
  • RUN should detail
    • dependencies
    • building from source
    • running from command-line (after building jar)
    • running as a servlet in tomcat
    • running as a servlet in Jigsaw

Dependencies

basic dependencies

You will need java installed on your system. That's the basic prerequisite.

building dependencies

@@ the following only necessary to build the validator ? Seems so. If so, should mention "the following is not needed if you are downloading the .jar @@

libraries dependencies should be satisfied by setting the proper CLASSPATH prior to building. Dependencies I am aware of include:

@@ we need pointers for each of these @@

Setting the CLASSPATH

When you have downloaded or installed the libraries above, you need to tell java where to look for them. This is done by setting the classpath, which a series of paths on your sytem, separated by colons. The syntax depends on which system you are using.

UNIX

WINDOWS

set CLASSPATH=C:\jigsaw\jigsaw\www\servlet\css-validator\css-validator.jar;c:\jigsaw\classes\velocity-1.5.jar;c:\jigsaw\\classes\xerces.jar;c:\jigsaw\classes\jigsaw.jar;c:\jigsaw\classes\xp.jar;c:\jigsaw\classes\sax.jar;c:\jigsaw\classes\servlet.jar;c:\jigsaw\classes\Tidy.jar;c:\jigsaw\classes\tagsoup-1.2.jar;C:\Jigsaw\classes\commons-lang-2.4.jar;C:\Jigsaw\classes\commons-collections-3.2.1.jar

Building from source

The following instructions should help you build the jar from the downloaded source. You may skip this if you have simply downloaded the jar file.

Media:CssValidator$$Installation$build.xml

  1. you need to have ant installed on your system. ant is a java building tool,
  2. Within a terminal (or a shell), go to the directory holding the validator's source, called css-validator. There should be a file called build.xml there.
  3. just run ant
  4. typical output should be as follows:
  build:
    [mkdir] Created dir: /home/ot/cssval/css-validator/build
    [javac] Compiling 869 source files to /home/ot/cssval/css-validator/build
    [javac] Note: Some input files use or override a deprecated API.
    [javac] Note: Recompile with -deprecation for details.
     [copy] Copying 1078 files to /home/ot/cssval/css-validator/build
     [copy] Copied 57 empty directories to 13 empty directories under /home/ot/cssval/css-validator/build

  jar:
      [jar] Building jar: /home/ot/cssval/css-validator/css-validator.jar


1.#5 Test the build by running from the command line (see next section)

Running the CSS Validator from the command line

Just run java -jar css-validator.jar to learn about the options.

Known issues

I systematically get an exception thrown at me, even though validation seems to be performed correctly. It is only mildly annoying, but I suspect this is also the problem causing tomcat installation to fail, so @@ help in stopping this exception, either through fix in our code or instructions for proper dependency fix, welcome @@


java -jar css-validator.jar http://www.w3.org/
html request http://www.w3.org/
file : http://www.w3.org/ 
No error or warning found

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/xerces/parsers/SAXParser
        at org.w3c.css.util.xml.XMLCatalog.parse(XMLCatalog.java:108)
        at org.w3c.css.util.xml.XMLCatalog.<init>(XMLCatalog.java:39)
        at org.w3c.css.css.XMLStyleSheetHandler.<clinit>(XMLStyleSheetHandler.java:73)
        at org.w3c.css.css.StyleSheetCom.xmlRequest(StyleSheetCom.java:77)
        at org.w3c.css.css.StyleSheetCom.htmlRequest(StyleSheetCom.java:68)
        at org.w3c.css.css.StyleSheetCom.main(StyleSheetCom.java:253)
[1]    7647 exit 1     java -jar css-validator.jar http://www.w3.org/


Running as a Web Application

with Jigsaw

from Sijtsche, in Jan 2003


Then you have to configure the validator home directory (usually this is
css-validator) so that it can work as a servlet container. For this purpose
you need to have Jigsaw installed (see the Jigsaw pages for a short
instruction (it is really easy)) and then start Jigsaw Admin. Change the
HTTPFrame to ServletDirectoryFrame.

The next step is to create a resource "validator", with as class
'ServletWrapper' and as frame 'ServletWrapperFrame'. The latter should add
itself automagically. The class of the servlet is
org.w3c.css.servlet.CssValidator. If there already exists a file named
'validator', please rename it. It is important that this 'alias' is always
named 'validator'.

Well, start jigsaw and run the validator. Check which HTML you want to
invoke. Usually your URL will look like this:

http://localhost:8001/css-validator/validator.html


known issues

error: indexed but not available. The server is misconfigured.

with Tomcat

Tomcat is apache's servlet container, and an alternative to jigsaw.

Here are the steps needed to get the CSS validator running under tomcat. They imply that your tomcat installation is already working and running (this generally means that http://myserver.example.com:8180/ is returning a tomcat welcome page)

(@@ it would perhaps be nice to provide a tarball of the files without the java source, with the WEB-INF etc already present, the web.xml and jar already packaged @@)

  1. first, download the files for the CSS validator
  2. under the css-validator directory, create a WEB-INF directory
  3. in the WEB-INF directory, create a web.xml file (souce below)
  4. in the WEB-INF create a lib directory, and put the css-validator.jar in there
  5. move the whole directory structure (the css-validator/ directory) into tomcat's webapps directory
  6. restart tomcat, (wait a bit - tomcat takes a while to start up), and point your browser to http://myserver.example.com:8180/css-validator/validator.html.en (replace the myserver.example.com by localhost or the address of your web server)
  7. you should get the usual CSS validator's Web interface (in english). If that works, then point your browser to http://myserver.example.com:8180/css-validator/validator?uri=http%3A%2F%2Fwww.w3.org&usermedium=all&warning=no
  8. if the above gives you CSS validator results, you're pretty much all set. The rest (e.g proxying your main web server, on port :80, to the tomcat instance, is rather cosmetic)

@@ should jigsaw.jar et.al be copied into WEB-INF/lib as well? @@

known issues

I never managed to get the servlet (the interface is ok, but not validation results), always get a tomcat exception page: @@ Help in fixing this is really welcome @@

(Note: Dave Ulm, MS, ran into same issue )


root cause

(first load)
java.lang.ExceptionInInitializerError
        org.w3c.css.servlet.CssValidator.init(CssValidator.java:107)
        
(upon reload)
java.lang.NoClassDefFoundError
        org.w3c.css.servlet.CssValidator.init(CssValidator.java:107)
        


Is this related to the NoClassDefFoundError exception thrown by java -jar in commandline mode? Is it a dependencies problem, or is it a bug in our code?

web.xml

(taken from jigsaw's install, appears to make tomcat happy as well)


<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
           "http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>
  <servlet>
    <servlet-name>validator</servlet-name>
    <servlet-class>org.w3c.css.servlet.CssValidator</servlet-class>
  </servlet>
  
  <servlet-mapping>
       <servlet-name>validator</servlet-name>
       <url-pattern>/validator</url-pattern>
   </servlet-mapping>
   
</web-app>