deployment problem
Added by Anonymous over 19 years ago
Legacy ID: #3032869 Legacy Poster: Jozef (xml4pharma)
I seem to have a deployment problem with classes from Saxon (saxonb8-2). My program just runs fine in the IDE (Eclipse), but when I run using: set JAVA_HOME=C:\jdk1.5.0_01 set classpath=.;.\xercesImpl.jar;.\xml-apis.jar;.\xercesSamples.jar;.\saxon8.jar;.\saxon8-jdom.jar set path=.;%JAVA_HOME%\bin;. java -classpath %CLASSPATH% -Djavax.xml.transform.TransformerFactory=net.sf.saxon.TransformerFactoryImpl -jar ODMViewer.jar I get the error: Exception in thread "main" javax.xml.transform.TransformerFactoryConfigurationError: Provider net.sf.saxon.TransformerFactoryImpl could not be instantiated: java.lang.nullPointerException The source code snipped is: private File ODM2ODMViewTree(Document xmldoc) { File file = new File("C:\ODMViewer\temp.xml"); StreamSource stylesheet = new StreamSource(new File(transformFile)); //StreamSource src = new StreamSource(xmlfile); DOMSource src = new DOMSource(xmldoc); StreamResult result = new StreamResult(file); System.setProperty("javax.xml.transform.TransformerFactory", "net.sf.saxon.TransformerFactoryImpl"); // next line causes the error TransformerFactory factory = TransformerFactory.newInstance(); System.out.println("factory = " + factory); try { Transformer t = factory.newTransformer(stylesheet); t.transform(src, result); } catch (TransformerConfigurationException tce) { tce.printStackTrace(); } catch (TransformerException te) { te.printStackTrace(); } return file; } Any idea what I am doing wrong ??? Many thanks in advance Jozef
Replies (3)
Please register to reply
RE: deployment problem - Added by Anonymous over 19 years ago
Legacy ID: #3033148 Legacy Poster: Michael Kay (mhkay)
My understanding is that when you use the "-jar" option in the java command, the classpath is ignored. (I haven't actually seen anyone use both the -jar and the -classpath options at the same time, so this may be a simplification.) In any case, the message means that the Java VM isn't finding the Saxon jar file and therefore can't load Saxon's TransformerFactoryImpl. Michael Kay http://www.saxonica.com/
RE: deployment problem - Added by Anonymous almost 19 years ago
Legacy ID: #3558402 Legacy Poster: joz (joz777)
If -classpath and -jar are mutually exlusive, then how am I supposed to use saxon8.jar from anywhere but the directory I placed the saxon8-6-1 files in? I am also having problem getting Java (1.5.0_06) to find the saxon8.jar On your website it clear states: "The class path is normally represented by an environment variable named CLASSPATH: see your Java documentation for details. Note that the JAR file itself (not the directory that contains it) should be named on the class path." I have done this and still Java will not locate the saxon8.jar until I am sat in it's installation directory. What is going on?!
RE: deployment problem - Added by Anonymous almost 19 years ago
Legacy ID: #3558610 Legacy Poster: Michael Kay (mhkay)
You haven't given much detail about what you are doing, so it's hard to tell what you are doing wrong. In particular, it's not clear whether you are trying to run using the -jar option or using the classpath. There's no requirement to run from the same directory as the one holding the Saxon JAR file (whichever option you use). For example if your current directory is c:/app, and Saxon is installed in c:/saxon, you can run using cd c:/app java -cp c:/saxon/saxon8.jar source.xml style.xsl Hope this helps. Michael Kay
Please register to reply