将RCP程序放在模拟机上运行,提示"Could not parse configuration"错误,定位是由SAXReader找不到dtd文件引起的(模拟机没有联网),解决:
下载"hibernate-configuration-3.0.dtd"和"hibernate-mapping-3.0.dtd"两个文件到本地目录(/cfg/目录下),增加代码:
cfg.setEntityResolver(new EntityResolver(){
private static final String HIBERNATE_NAMESPACE = "http://hibernate.sourceforge.net/";
@Override
public InputSource resolveEntity(String publicId, String systemId)
throws SAXException, IOException {
String path = "/cfg/" + systemId.substring( HIBERNATE_NAMESPACE.length() );
InputStream dtdStream = bundle.getEntry(path).openStream();
InputSource source = new InputSource( dtdStream );
return source;
}
});