I noticed that if the system property
com.bluecast.xml.ValidatingSAXParserFactory is not set,
Piccolo will try to search the class path for all
implementors of SAXParserFactory using the services
mechanism as used by SAXParserFactory itself.
Despite having Xerces on the classpath, it wasn't being
picked up. Having investigated, it appears there's a
bug in the JAXPSAXParserFactory and
FactoryServiceFinder classes.
The method FactoryServiceFinder.findService(String)
correctly added the "META-INF/services" prefix to the
name of the interface before searching for it, but the
method FactoryServiceFinder.findServices(String) (which
looks for *all* implementing classes) did not. This
means it was always returning an empty enumeration.
Changing line 53 from:
ClassLoader.getSystemClassLoader().getResources(name));
to:
ClassLoader.getSystemClassLoader().getResources(SERVICE
+ name));
Solves the first bit of the problem.
I also added the character set used to read the file to
UTF-8 to match up with findService().
The second problem was that the
JAXPSAXParserFactory.findValidatingFactory() method was
comparing the name of the class with
"com.bluecast.xml.Piccolo" rather than the name of its
own SAXParserFactory implementation.
diffs from 1.04, and modifed versions of classes
Logged In: YES
user_id=537678
Oh, and you might to consider using the thread context
classloader to search for services (like JAXP does) -
otherwise classes in EAR or WAR classloaders won't be
considered when looking for the services files.