views:

543

answers:

2

In this ParserFactory.java

String className = System.getProperty("org.w3c.css.sac.parser");
if (className == null) {
    throw new NullPointerException("No value for sac.parser property");  //line 35
} else {
    return (Parser)(Class.forName(className).newInstance());
}

When I run this DemoSAC.java file as Java Application in Eclipse, I got

Exception in thread "main" java.lang.NullPointerException: No value for sac.parser property
at org.w3c.css.sac.helpers.ParserFactory.makeParser(ParserFactory.java:35)

What exactly is the "org.w3c.css.sac.parser" property? How do I set it under Windows? What should I set it to?

Thanks!

A: 

It looks like you need to provide an interface implementation. Per this link here, this is one way to do it:

  • get the flute parser here
  • add it to your build path
  • add this to the DemoSAC class (before the getProperty call):

    System.setProperty("org.w3c.css.sac.parser", "org.w3c.flute.parser.Parser");

I don't know why it is doing this reflection based instantiation to begin with, perhaps bypassing ParserFactory and returning a new instance of the flute parser would be cleaner altogether?

javamonkey79
+1  A: 

If you don't want to modify code, you can also set a Java property in Eclipse's Java launch configuration dialog. You specify a "VM option" in the "Arguments" tab . To set the property to "org.w3c.flute.parser.Parser" as suggested by javamonkey79, you would specify:

-Dorg.w3c.css.sac.parser=org.w3c.flute.parser.Parser

Roy Paterson