Could not load imported ontology HTTP response code: 403 - java

I have the following ontology (https://raw.githubusercontent.com/wiki/ontop/ontop/attachments/Example_MovieOntology/movieontology.owl) stored in OWL File.
I tried to load it:
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
File file = new File("movieontology.owl");
OWLOntology ontology = manager.loadOntologyFromOntologyDocument(file);
But I got this Exception:
Exception in thread "main" org.semanticweb.owlapi.model.UnloadableImportException: Could not load imported ontology: <http://dbpedia.org/ontology/> Cause: Server returned HTTP response code: 403 for URL: http://dbpedia.org/ontology/at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.makeLoadImportRequest(OWLOntologyManagerImpl.java:1766)
at org.semanticweb.owlapi.rdf.rdfxml.parser.TripleHandlers$TPImportsHandler.handleTriple(TripleHandlers.java:1537)
at org.semanticweb.owlapi.rdf.rdfxml.parser.TripleHandlers$HandlerAccessor.handleStreaming(TripleHandlers.java:194)
at org.semanticweb.owlapi.rdf.rdfxml.parser.OWLRDFConsumer.statementWithResourceValue(OWLRDFConsumer.java:1545)
at org.semanticweb.owlapi.rdf.rdfxml.parser.RDFParser.statementWithResourceValue(RDFParser.java:370)
at org.semanticweb.owlapi.rdf.rdfxml.parser.EmptyPropertyElement.startElement(StartRDF.java:236)
at org.semanticweb.owlapi.rdf.rdfxml.parser.PropertyElementList.startElement(StartRDF.java:658)
at org.semanticweb.owlapi.rdf.rdfxml.parser.RDFParser.startElement(RDFParser.java:201)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.emptyElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(Unknown Source)
at org.semanticweb.owlapi.rdf.rdfxml.parser.RDFParser.parse(RDFParser.java:145)
at org.semanticweb.owlapi.rdf.rdfxml.parser.RDFXMLParser.parse(RDFXMLParser.java:73)
at uk.ac.manchester.cs.owl.owlapi.OWLOntologyFactoryImpl.loadOWLOntology(OWLOntologyFactoryImpl.java:197)
at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.actualParse(OWLOntologyManagerImpl.java:1156)
at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntology(OWLOntologyManagerImpl.java:1112)
at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntologyFromOntologyDocument(OWLOntologyManagerImpl.java:1062)
at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntologyFromOntologyDocument(OWLOntologyManagerImpl.java:1073)
at uk.ac.manchester.owl.owlapi.tutorial.examples.SimpleHierarchyExample.main(SimpleHierarchyExample.java:409)
Caused by: org.semanticweb.owlapi.io.OWLOntologyCreationIOException: Server returned HTTP response code: 403 for URL: http://dbpedia.org/ontology/
at uk.ac.manchester.cs.owl.owlapi.OWLOntologyFactoryImpl.loadOWLOntology(OWLOntologyFactoryImpl.java:207)
at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.actualParse(OWLOntologyManagerImpl.java:1156)
at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntology(OWLOntologyManagerImpl.java:1112)
at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntology(OWLOntologyManagerImpl.java:1014)
at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadImports(OWLOntologyManagerImpl.java:1723)
at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.makeLoadImportRequest(OWLOntologyManagerImpl.java:1759)
... 29 more
If I try to load the ontology through a Web-based Visualization of Ontologies (WebVOWL), it loaded without any problems.
How can I solve?

Move to OWLAPI 4.2.3. Content negotiation has been upgraded and should handle any format the caller knows how to parse.
If this dies not work, please raise an issue in the OWLAPI tracker on github.

Related

I am getting following error while deploying application on google cloud appengine

I am getting following error while deploying application on google cloud appengine
I have downloaded appengine-java-sdk-1.9.42 and installed appengine plugins in netbeans.
com.google.apphosting.utils.config.AppEngineConfigException: XML error validating
1
<application>driven-copilot-143702</application>
<system-properties>
<property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
</system-properties>
<threadsafe>false</threadsafe>
</appengine-web-app>
against C:\Users\graycell\Downloads\appengine-java-sdk-1.9.42\docs\appengine-web.xsd
at com.google.apphosting.utils.config.XmlUtils.validateXmlContent(XmlUtils.java:120)
at com.google.apphosting.utils.config.XmlUtils.validateXml(XmlUtils.java:91)
at com.google.appengine.tools.admin.Application.<init>(Application.java:227)
at com.google.appengine.tools.admin.Application.readApplication(Application.java:421)
at com.google.appengine.tools.admin.AppCfg.readWar(AppCfg.java:297)
at com.google.appengine.tools.admin.AppCfg.readApplication(AppCfg.java:288)
at com.google.appengine.tools.admin.AppCfg.<init>(AppCfg.java:217)
at com.google.appengine.tools.admin.AppCfg.<init>(AppCfg.java:119)
at com.google.appengine.tools.admin.AppCfg.main(AppCfg.java:115)
Caused by: org.xml.sax.SAXParseException; lineNumber: 6; columnNumber: 17; cvc-complex-type.2.4.a: Invalid content was found starting with element 'application'. One of '{"http://appengine.google.com/ns/1.0":runtime, "http://appengine.google.com/ns/1.0":module, "http://appengine.google.com/ns/1.0":service, "http://appengine.google.com/ns/1.0":instance-class, "http://appengine.google.com/ns/1.0":automatic-scaling, "http://appengine.google.com/ns/1.0":manual-scaling, "http://appengine.google.com/ns/1.0":basic-scaling, "http://appengine.google.com/ns/1.0":static-files, "http://appengine.google.com/ns/1.0":resource-files, "http://appengine.google.com/ns/1.0":system-properties, "http://appengine.google.com/ns/1.0":vm-settings, "http://appengine.google.com/ns/1.0":beta-settings, "http://appengine.google.com/ns/1.0":vm-health-check, "http://appengine.google.com/ns/1.0":health-check, "http://appengine.google.com/ns/1.0":resources, "http://appengine.google.com/ns/1.0":network, "http://appengine.google.com/ns/1.0":env-variables, "http://appengine.google.com/ns/1.0":ssl-enabled, "http://appengine.google.com/ns/1.0":sessions-enabled, "http://appengine.google.com/ns/1.0":async-session-persistence, "http://appengine.google.com/ns/1.0":user-permissions, "http://appengine.google.com/ns/1.0":public-root, "http://appengine.google.com/ns/1.0":inbound-services, "http://appengine.google.com/ns/1.0":precompilation-enabled, "http://appengine.google.com/ns/1.0":admin-console, "http://appengine.google.com/ns/1.0":static-error-handlers, "http://appengine.google.com/ns/1.0":warmup-requests-enabled, "http://appengine.google.com/ns/1.0":threadsafe, "http://appengine.google.com/ns/1.0":auto-id-policy, "http://appengine.google.com/ns/1.0":code-lock, "http://appengine.google.com/ns/1.0":vm, "http://appengine.google.com/ns/1.0":env, "http://appengine.google.com/ns/1.0":class-loader-config, "http://appengine.google.com/ns/1.0":url-stream-handler, "http://appengine.google.com/ns/1.0":use-google-connector-j, "http://appengine.google.com/ns/1.0":api-config}' is expected.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.validation.StreamValidatorHelper.validate(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.validation.ValidatorImpl.validate(Unknown Source)
at javax.xml.validation.Validator.validate(Unknown Source)
at com.google.apphosting.utils.config.XmlUtils.validateXmlContent(XmlUtils.java:116)
... 8 more
Do you have a <version> tag in your appengine-web.xml? Could you show your complete xml file?
Here's the reference doc for your xml: https://cloud.google.com/appengine/docs/java/config/appref
By the way: People are downvoting you because it's much better to try to explain what you've tried instead of just showing a stacktrace. It makes it much harder to help you this way.

Uncaught Throwable java.lang.NoClassDefFoundError:com/sun/xml/internal/bind/v2/runtime/reflect/opt/Const

when i submit a form i get the below error in cq....There is some problem with this line
dataFileType = (DataFileType) jaxbUnmarshaller.unmarshal(url);
I get logs until before this line.
30.10.2014 15:48:12.912 *INFO* [jackrabbit-pool-8] org.apache.jackrabbit.core.query.lucene.IndexMerger merged 15 documents in 43 ms into _1sew.
30.10.2014 15:48:14.541 *ERROR* [0:0:0:0:0:0:0:1 [1414664289775] POST HTTP/1.1] org.apache.sling.engine.impl.SlingRequestProcessorImpl service: Uncaught Throwable java.lang.NoClassDefFoundError: com/sun/xml/internal/bind/v2/runtime/reflect/opt/Const
at com.sun.xml.internal.bind.v2.runtime.reflect.Accessor.receive(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext.endElement(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.SAXConnector.endElement(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
Looks like the jaxb-impl.jar is missing in your classpath. Download and add it to your classpath.

Connection timed out while generating pdf from html string

I am using <dependency>
<groupId>org.xhtmlrenderer</groupId>
<artifactId>flying-saucer-pdf-itext5</artifactId>
<version>9.0.4</version>
</dependency>
to convert my HTML string to PDF.
try {
String table = getHtmlAsString();//returns html string which contains reference to external CSS
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document doc = builder.parse(new ByteArrayInputStream(table.getBytes("UTF-8")));
ITextRenderer renderer = new ITextRenderer();
renderer.setDocument(doc, null);
ByteArrayOutputStream byteArray = new ByteArrayOutputStream();
renderer.layout();
renderer.createPDF(byteArray);
byte[] pdf = byteArray.toByteArray();
byteArray.close();
writeByteArrayToFile(pdf);
} catch (Exception e) {
e.printStackTrace();
}
The code is working fine locally. But on production server Its throwing connection time out exception.
Here is complete stacks trace
java.net.ConnectException: Connection timed out: connect at
java.net.DualStackPlainSocketImpl.connect0(Native Method) at
java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source) at
java.net.AbstractPlainSocketImpl.doConnect(Unknown Source) at
java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source) at
java.net.AbstractPlainSocketImpl.connect(Unknown Source) at
java.net.PlainSocketImpl.connect(Unknown Source) at
java.net.SocksSocketImpl.connect(Unknown Source) at
java.net.Socket.connect(Unknown Source) at
java.net.Socket.connect(Unknown Source) at
sun.net.NetworkClient.doConnect(Unknown Source) at
sun.net.www.http.HttpClient.openServer(Unknown Source) at
sun.net.www.http.HttpClient.openServer(Unknown Source) at
sun.net.www.http.HttpClient.<init>(Unknown Source) at
sun.net.www.http.HttpClient.New(Unknown Source) at
sun.net.www.http.HttpClient.New(Unknown Source) at
sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source) at
sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source) at
sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source) at
sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source) at
org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source) at
org.apache.xerces.impl.XMLEntityManager.startEntity(Unknown Source) at
org.apache.xerces.impl.XMLEntityManager.startDTDEntity(Unknown Source) at
org.apache.xerces.impl.XMLDTDScannerImpl.setInputSource(Unknown Source) at
org.apache.xerces.impl.XMLDocumentScannerImpl$DTDDispatcher.dispatch(Unknown Source) at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at
org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at
org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at
org.apache.xerces.parsers.XMLParser.parse(Unknown Source) at
org.apache.xerces.parsers.DOMParser.parse(Unknown Source) at
org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source) at
javax.xml.parsers.DocumentBuilder.parse(Unknown Source) at
com.mypackage.PDFProcessor.getPdf(PDFProcessor.java:84)
Line No.84 in code is Document doc = builder.parse(new ByteArrayInputStream(table.getBytes("UTF-8")));
At first I thought may be server is not able to fetch External CSS. So I saved html string as html file and I am able to see the page on browser. That means server is able to access the CSS.
You may still be right about your CSS, since the fact that the main html has been saved does not mean that the CSS is well saved (actually, we don't even know if it tries to save it, have you tried to do your work through a proxy like Paros in order to know every communication you attempt?)
http://sourceforge.net/projects/paros/
By the way, your problem may be different. Are you behind a corporate proxy in your production environment? Does your "flying saucer pdf library" need any external resource (any .xsd or something like that) that could be stuck in the firewall and cause that time-out? Make sure that you have under controll all the communication your application generates and you will find your problem.

How to use an HTTPS wsdl file without downloading to local computer in java

I just implemented my first webservice (client). The URL is HTTPS. I tried to use the URL directly but i could not. So i downloaded the WSDL file and everything worked fine. Now the problem is that when service definition changes i will not know because the code that i wrote is based on the local WSDL i saved. So back to square one. Is it possible to use HTTPS URL directly without downloading it.
The exceptions i got while trying to implement the webservice using the URL are:
Exception in thread "main" javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service.
at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:151)
at org.apache.cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:101)
at javax.xml.ws.Service.<init>(Unknown Source)
at org.tempuri.Service.<init>(Service.java:43)
at org.tempuri.ServiceSoap_ServiceSoap_Client.main(ServiceSoap_ServiceSoap_Client.java:65)
Caused by: org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service.
at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:100)
at org.apache.cxf.jaxws.ServiceImpl.initializePorts(ServiceImpl.java:204)
at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:149)
... 4 more
Caused by: javax.wsdl.WSDLException: WSDLException: faultCode=PARSER_ERROR: Problem parsing 'https myipaddress service.asmx?WSDL'.: javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject alternative names present
at com.ibm.wsdl.xml.WSDLReaderImpl.getDocument(WSDLReaderImpl.java:2198)
at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(WSDLReaderImpl.java:2390)
at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(WSDLReaderImpl.java:2422)
at org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:263)
at org.apache.cxf.wsdl11.WSDLManagerImpl.getDefinition(WSDLManagerImpl.java:206)
at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:98)
... 6 more
Caused by: javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject alternative names present
at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(Unknown Source)
at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Unknown Source)
at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Unknown Source)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(Unknown Source)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(Unknown Source)
at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Unknown Source)
at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.afterConnect(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at com.ibm.wsdl.xml.WSDLReaderImpl.getDocument(WSDLReaderImpl.java:2188)
... 11 more
Caused by: java.security.cert.CertificateException: No subject alternative names present
at sun.security.util.HostnameChecker.matchIP(Unknown Source)
at sun.security.util.HostnameChecker.match(Unknown Source)
at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkIdentity(Unknown Source)
at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(Unknown Source)
Please help. Thanks in advance.
The simple answer is yes it is possible to use HTTPS to retrieve the WSDL.
The "No subject alternative names present" is Java's obscure way of telling you that there is a mismatch between the hostname of the URL you are using, and the Common Name (CN) in the hosts Certificate.
The right solution is to either use the hostname that matches the certificate, or get a new certificate issued with the proper hostnames in it.
There is a work around described in this similar question.

Parsing XML files with Java and spaces in file path

I have files on my file system, on Windows XP. I want to parse them using Java (JRE 1.6).
Problem is, I don't understand how Java and Xerces work together when the file path has spaces in it.
If the file has no spaces in its path, all works fine.
If there are spaces, I may have this kind of trouble, even if I call the parser with a FileInputStream instance :
java.net.UnknownHostException: .
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.NetworkClient.openServer(Unknown Source)
at sun.net.ftp.FtpClient.openServer(Unknown Source)
at sun.net.ftp.FtpClient.openServer(Unknown Source)
at sun.net.www.protocol.ftp.FtpURLConnection.connect(Unknown Source)
at sun.net.www.protocol.ftp.FtpURLConnection.getInputStream(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startEntity(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startDTDEntity(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.setInputSource(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.dispatch(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at javax.xml.parsers.DocumentBuilder.parse(Unknown Source)
(sun.net.ftp.FtpClient.openServer ??? Wtf ?)
or else this kind of trouble :
java.net.MalformedURLException: unknown protocol: d
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startEntity(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startDTDEntity(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.setInputSource(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.dispatch(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
(It says unknown protocol: d because, I guess, the file is on the D drive.)
Has anyone any clue of why that happens, and how to circumvent the problem ? I tried to supply my own EntityResolver but my log tells me it is not even called before the crash.
EDIT:
Here is the code calling the parser.
public Document fileToDom(File file) throws ProcessException {
Document doc = null;
try {
DocumentBuilderFactory db = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = db.newDocumentBuilder();
if (this.errorHandler!=null){
builder.setErrorHandler(this.errorHandler);}
else {
builder.setErrorHandler(new DefaultHandler());
}
FileInputStream test= new FileInputStream(file);
doc = builder.parse(test);
...
} catch (Exception e) {...}
...
}
For the moment I find myself forced to remove the DOCTYPE before the parse, which removes all the problems, and the DTD validation... Not so great a solution.
Are you just using DocumentBuilder.parse(filename)?
If so, that's failing because it expects a URI. Open a FileInputStream to the file, and then pass that to DocumentBuilder.parse(InputStream).
Try this URI style:
file:///d:/folder/folder%20with%20space/file.xml
It looks like it's trying to connect to a URL in the doctype header so it can download it in order to validate the document against the downloaded DTD.
Try this.
InputSource is = new InputSource();
is.setCharacterStream(new StringReader(test));
doc = builder.parse(is);
instead of just parsing the 'test'

Categories