Problem: javax.xml.transform.FactoryFinder cannot load class
This problem is actually related to a problem I ran into while installing Websphere Community Edition. I wrote a test class to confirm my suspicions to simulate the problem. My test class creates the same error message as wasce startup. By the way, I downloaded the big bundle for wasce and the problem went away ???
I have been using Netbeans 7.0 for 6 weeks on Linux FC14 using jdk1.6.0_29 and it all works great.
The following code will not work even though saxon.jar is in my class path and I have verified it contains the class net.cf.saxon.TransformerFactoryImpl.
public class DebugWasce {public DebugWasce() {
Classloader loader = DebugWasce.class.getClassLoader();
try {
TransformerFactory tf = TransformerFactoroy.newInstance("net.cf.saxon.Tran sformerFactoryImpl", loader);
} catch (TransformerFactoryConfigurationError tce) {
System.out.println(tce.getMessage());
}
}
}
The message I get is: Provider net.cf.saxon.TransformerFactoryImpl not found
If I use the following line instead, it works OK. I turned on jaxp.debug and I can see it do fallback lookup and I am using the java.endorsed.dirs to make it load from saxon.jar. When I use it as above, I don't see any debug output.
TransformerFactory tf = TransformerFactory.newInstance();
I looked at source code and newInstance(string,ClassLoader) is designed to not do any fallback lookup. I would really like to understand this so I don't have to tear my hair out next time because I anticipate using XML a lot or packages that use it. The possible explanations are:
- I am not using the class loader correctly although I have used it this way before.
- Java is trying to use some facility built-in to Linux I don't have
- My jdk is not configured properly
- The parameters to newInstance() are wrong.
- It is an ignored bug because most people use other methods to specify an XML parser instead of hard coding it.
Please advise or refer. Thanks in advance
Re: Problem: javax.xml.transform.FactoryFinder cannot load class
Are you sure that the jar fiel for that class is on the runtime classpath for your app?
How are you defining that?
Anyway, normally you would define this as a property of some sort, as per the API. That would allow for use of the fallback.
Re: Problem: javax.xml.transform.FactoryFinder cannot load class
It sounds like it needs a properties file in the jar manifest.
I will try that out.
So many APIs, so little time.
Re: Problem: javax.xml.transform.FactoryFinder cannot load class
The solution to this problem was to put saxon9he.jar into $JAVA_HOME/jre/lib/ext plus it would help if I spelled the class name right.
Actually, a cleaner solution is:
import net.sf.saxon.*;
TransformerFactory tf = new TransformerFactoryImpl();
The problem is that putting saxon9he.jar in the CLASSPATH does not work (at least for me).
Re: Problem: javax.xml.transform.FactoryFinder cannot load class
No.
That is not the solution.
You should not be putting anything in the jre directories.
You should also not use the CLASSPATH environment.
You should define the classpath for your particular app, either with -cp (for non-executable jar applications) or in the Manifest of the executable jar.
Anything else is pretty much a hack.