java - 访问 WMTS 服务的 Geotools 抛出 stackoverflow 解析 XML
问题描述
我正在访问
http://geodata.nationaalgeoregister.nl/luchtfoto/infrarood/wmts?request=GetCapabilities&service=WMTS
(这是荷兰 PDOK 网站上的众多免费服务之一)
我正在使用 JMapFrame(Java 1.8u131x86,Geotools 18.3 模块不支持摇摆)。它抛出:
May 07, 2018 4:37:29 PM org.geotools.xml.resolver.SchemaCache resolveLocation
INFO: Cached XML schema: http://schemas.opengis.net/wmts/1.0/wmtsGetCapabilities_response.xsd
May 07, 2018 4:37:30 PM org.geotools.xml.resolver.SchemaCache resolveLocation
INFO: Cached XML schema: http://schemas.opengis.net/wmts/1.0/wmts.xsd
May 07, 2018 4:37:30 PM org.geotools.xml.resolver.SchemaCache resolveLocation
INFO: Cached XML schema: http://schemas.opengis.net/wmts/1.0/wmtsKVP.xsd
May 07, 2018 4:37:31 PM org.geotools.data.ows.AbstractOpenWebService internalIssueRequest
SEVERE: Failed to execute request http://geodata.nationaalgeoregister.nl/luchtfoto/infrarood/wmts?REQUEST=GetCapabilities&VERSION=1.3.0&SERVICE=WMS
Exception in thread "main" java.lang.StackOverflowError
at java.io.InputStream.<init>(InputStream.java:45)
at java.io.FileInputStream.<init>(FileInputStream.java:123)
at java.io.FileInputStream.<init>(FileInputStream.java:93)
at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:90)
at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:188)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:623)
at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:148)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:805)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:770)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:643)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:327)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:274)
at org.geotools.xml.SchemaFactory.getRealInstance(SchemaFactory.java:323)
at org.geotools.xml.SchemaFactory.getInstance(SchemaFactory.java:309)
at org.geotools.xml.handlers.xsi.SchemaHandler.compress(SchemaHandler.java:386)
at org.geotools.xml.handlers.xsi.RootHandler.getSchema(RootHandler.java:118)
at org.geotools.xml.XSISAXHandler.getSchema(XSISAXHandler.java:258)
at org.geotools.xml.SchemaFactory.getRealInstance(SchemaFactory.java:334)
at org.geotools.xml.SchemaFactory.getInstance(SchemaFactory.java:309)
at org.geotools.xml.handlers.xsi.SchemaHandler.compress(SchemaHandler.java:386)
at org.geotools.xml.handlers.xsi.RootHandler.getSchema(RootHandler.java:118)
at org.geotools.xml.XSISAXHandler.getSchema(XSISAXHandler.java:258)
at org.geotools.xml.SchemaFactory.getRealInstance(SchemaFactory.java:334)
at org.geotools.xml.SchemaFactory.getInstance(SchemaFactory.java:309)
at org.geotools.xml.handlers.xsi.SchemaHandler.compress(SchemaHandler.java:386)
at org.geotools.xml.handlers.xsi.RootHandler.getSchema(RootHandler.java:118)
at org.geotools.xml.XSISAXHandler.getSchema(XSISAXHandler.java:258)
at org.geotools.xml.SchemaFactory.getRealInstance(SchemaFactory.java:334)
at org.geotools.xml.SchemaFactory.getInstance(SchemaFactory.java:309)
at org.geotools.xml.handlers.xsi.SchemaHandler.compress(SchemaHandler.java:386)
Web 服务返回的 XML 似乎未按预期格式化。我能做些什么吗?
解决方案
如果您使用带有 WMTS url 的 WMSServer,则查找模式似乎存在问题 - 我打开了一个错误。
但简单的答案是像这样构造它:
URL url = new URL("http://geodata.nationaalgeoregister.nl/luchtfoto/infrarood/wmts?request=GetCapabilities&service=WMTS");
try {
wmts = new WebMapTileServer(url);
} catch (ServiceException | IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.exit(2);
}
WMTSCapabilities capabilities = wmts.getCapabilities();
List<WMTSLayer> wmtsLayers = capabilities.getLayerList();
推荐阅读
- javascript - 我怎样才能从 javascript 中调用用 dart 编写的函数?
- python - 美丽的汤,get_text 但不是文本.. 我怎样才能得到它?
- azure - 将 azure blob 挂载到 VM
- javascript - 获取文件类型 Node.js
- swiftui - SwiftUI iOS 14 选择器绑定
- r - 如何从数据框中删除特定字符
- javascript - 使用 JavaScript 检查用户输入
- python - 编辑要求用户名的程序。它应该检查前四个字符是字母,第五个和第六个是数字。在 Python 中
- r - 使用整洁的评估过滤我自己的功能
- javascript - 从经过消毒的 html 中设置 innerHtml 仍然很危险吗?