The code is:
package org.tingting.bn.mn.phylotree.test;
import java.io.File;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Unmarshaller;
import javax.xml.transform.stream.StreamSource;
import org.tingting.bn.mn.graph.impl.jaxp.Pathway;
/**
* TestPathwayReader.java is to test PathwayReader
* @author Tingting
*
*/
public class TestPathwayReader {
public static void main(String[] args) {
String xmlFile = "D:\\Data\\KEGG\\KGML\\aae\\aae00010.xml";
try {
JAXBContext jc = JAXBContext.newInstance( "org.tingting.bn.mn.graph.impl.jaxp" );
Unmarshaller u = jc.createUnmarshaller();
Pathway pathway =
u.unmarshal( new StreamSource(new File(xmlFile)), Pathway.class ).getValue();
System.out.println( pathway.getName() );
} catch(Exception e) {
System.out.println(e);
}
}
}
First of all, I debug and run it on my own notebook which is connected to the internet. It debugs successfully and works well.
Secondly, I debug it on the remote server which is an offline virtual machine in three ways. One is using Eclipse(Together). In this case he debug process stops PlainSocketImpl.class on the debug view, whose java source file is not found. And when I run it with Eclipse, the program throws an unexpeted console error:
javax.xml.bind.UnmarshalException
- with linked exception:
[java.net.ConnectException: Connection timed out: connect]
In addition, no matter what kind of approach I use to run it, Eclipse, JBuilder, or just the pain command line, they throw the same error message. In that the code can run well on my notebook and Java is not sensitive to the different of platform, I guess the problem is caused by two possible reasons: One is because the virtual machines is not connected to the internet while the JAXB library need some internet support; the other is the JDK installed in the virtual machine may have some possible problems.
For the first possibilty, Samuel said he was sure that JAXB could work well. For the second one, if it were caused by the JDK's problems, how could it happened to three different JVMs of three different approaches to run the code?(as far as I know, JBuilder, Eclipse and the Command line run Java codes based on their own JVM)
Samuel are prone to the latter. The google seems to relate it to the firewall. But the virtual machine has no firewall. Is the problem caused by that the platform is a virtual machine? I wondered.
For me I thought it must be something related to the difference between the socket working of the virtual machine(offline Windows 2003) and the notebook(online Windows Vista). By now I couldn't find much more useful information online. So, tomorrow I plan to give three other attempts:
- let the virtual machine connected to internet to see if it's work;
- uninstall all the JDKs on the virtual machine and reinstall them with the latest version as possible;
- ask for helps via posting the problem on some Java Forum or throuhg maillist.
Here is the introduction of UnmarshalException on JavaSE 6.
Here is the introduction of java.net.ConnectException on JavaSE6.
3 comments:
Sometimes I am really a stonehead! I should have been tested how the code would preform under the condition that the vista's network connection is broken. Since when my notebook is disconnected, the code throws the same error information. That is to say, JAXB needs the network service support. But now the question turns to a new one: which port does the JAXB occupy?
JAXB runs well after I delete the declaration sentence in the head of XML: < DOCTYPE ....>. That means, even having parsed the xml file into a series of domain object java files, JAXB still need to verify the xml files online.
Now I have two choices:
1. delete the line < !DOCTYPE pathway SYSTEM "http://www.genome.jp/kegg/xml/KGML_v0.6.1_.dtd"> for every involved xml file;
2. download the *.dtd file() and set it locally and revise this line for each XML file. The link in this line < !DOCTYPE pathway SYSTEM "http://www.genome.jp/kegg/xml/KGML_v0.6.1_.dtd"> should be modified as the local location.
Post a Comment