最近用dom4j写了一个修改XML文件的小例子,抛出了如下异常:

org.dom4j.DocumentException: unknown protocol: d Nested exception: unknown protocol: d

在网上查了资料,问题的原因是Tomcat的安装路径有空格.d是Tomcat安装的盘符.
解决的办法有两种:
1.重新安装Tomcat.去掉空格.

2.将解析的XML文档转换为File类型.

原始代码:

String path = "D:\\config.xml";
SAXReader reader = new SAXReader();
Document document = reader.read(path);

目的代码:

String path = "D:\\config.xml";
File file = new File(path);
SAXReader reader = new SAXReader();
Document document = reader.read(file);

org.dom4j.DocumentException: unknown protocol: d Nested exception: unknown的更多相关文章

  1. java解析XML saxReader.read(xml) 错误:org.dom4j.DocumentException: no protocol

    java解析XML saxReader.read(xml) 错误:org.dom4j.DocumentException: no protocol 完整错误信息: org.dom4j.Document ...

  2. dom4j解析xml报错:Nested exception: org.xml.sax.SAXParseException: White space is required between the processing instruction target and data.

    采用dom4j方式解析string类型的xml xml:        String string="<?xmlversion=\"1.0\" encoding=\ ...

  3. ssh启动报错:org.dom4j.DocumentException: Connection timed out: connect Nested exception: Connection timed out: connect

    ssh项目启动报错: org.dom4j.DocumentException: Connection timed out: connect Nested exception: Connection t ...

  4. org.dom4j.DocumentException : 1 字节的 UTF-8 序列的字节 1 无效。 Nested exception: 1 字节的 UTF-8 序列的字节 1 无效。

    org.dom4j.DocumentException : 1 字节的 UTF-8 序列的字节 1 无效. Nested exception: 1 字节的 UTF-8 序列的字节 1 无效. 网上查了 ...

  5. hibernate3.0 org.dom4j.DocumentException: Connection timed out: connect Nested exception:

    hibernate3.0 org.dom4j.DocumentException: Connection timed out: connect Nested exception:   所报异常: 严重 ...

  6. Java使用dom4j读取xml时报错:org.dom4j.DocumentException: Error on line 2 of document : Invalid byte 2 of 2-byte UTF-8 sequence. Nested exception: Invalid byte 2 of 2-byte UTF-8 sequence

    1.Java使用dom4j读取xml时报错: org.dom4j.DocumentException: Error on line 2 of document  : Invalid byte 2 of ...

  7. spring 整合hibernate注解时候,出现“Unknown entity: com.ssh.entry.Admin; nested exception is org.hibernate.MappingException: Unknown entity: com.ssh.entry.Admin”异常的问题

    今天学习使用ssh框架的时候,出现一个异常,弄了好久才找到,在这记录一下,我的sb错误1.spring整合hibernate,取代*.hbm.xml配置文件   在applicationContext ...

  8. org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.jdbc.BadSqlGrammarException: Unknown column 'viewpoint' in 'field list'

    问题描述:当我在model中添加了一下代码以后数据库报错: 添加的代码为: private Viewpoint viewpoint; public Viewpoint getViewpoint() { ...

  9. Handler dispatch failed; nested exception is java.lang.NoClassDefFoundError: org/dom4j/io/SAXReader

    Handler dispatch failed; nested exception is java.lang.NoClassDefFoundError: org/dom4j/io/SAXReader ...

随机推荐

  1. poj2676(数独)

    也是一个简单剪枝的dfs.记录所有为0的位置,依次填写,当发现某个空格可选的填写数字已经没有时,说明该支路无效,剪掉. 不算是一个难题吧,但是还是花了不少时间,问题主要出在细节上,行列坐标反了.3乘3 ...

  2. 你了解border-radius吗?

    1.圆角正方形 .rounded-square{ width: 200px; height: 200px; background-color: pink; border-radius: 50px; } ...

  3. python opencv3 grabcut前景检测

    git:https://github.com/linyi0604/Computer-Vision import numpy as np import cv2 import matplotlib.pyp ...

  4. 在Kali Linux上编译Windows EXP

    使用vc6.0去编译的时候,难免会出现点问题 这里找到MS11-046的exp来编译 poc地址:https://www.exploit-db.com/exploits/40564/ 首先需要安装mi ...

  5. NOIP 算法模板

    Hash: #include <iostream> #include <cstdio> #include <cstdlib> #include <algori ...

  6. ASP.NET MVC HttpVerbs.Delete/Put Routes not firing

    原文地址: https://weblog.west-wind.com/posts/2015/Apr/09/ASPNET-MVC-HttpVerbsDeletePut-Routes-not-firing ...

  7. CDOJ 1402 三角形棋盘上的博弈游戏 状压DP

    三角形棋盘上的博弈游戏 题目连接: http://mozhu.today/#/problem/show/1402 Description 柱爷有天上课无聊,于是和同桌卿学姐一起下一种奇特的棋: 棋盘如 ...

  8. JVM监控启动参数

    服务端: JVM监控启动参数 -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=52001 -Dcom.sun.ma ...

  9. Maven的POM文件parent节点不可以使用properties里面的变量

    Maven的POM文件parent节点不可以使用properties里面的变量 但是如果在子项目上的parent节点是可以使用父项目里定义的properties变量 如果一开始为单项目,或者最顶层项目 ...

  10. vim segment fault when i upgrade to macOS Mojave 103_PollServerReady

    系统升级到 macOS Mojave, vim插件YouCompleteMe出错. Vim: Caught deadly signal SEGV Error detected while proces ...