- 浏览: 235998 次
- 性别:
- 来自: 上海
文章分类
最新评论
-
lwb314:
你的这个是创建的临时的hive表,数据也是通过文件录入进去的, ...
Spark SQL操作Hive数据库 -
yixiaoqi2010:
你好 我的提交上去 总是报错,找不到hive表,可能是哪里 ...
Spark SQL操作Hive数据库 -
bo_hai:
target jvm版本也要选择正确。不能选择太高。2.10对 ...
eclipse开发spark程序配置本地运行
org.dom4j.DocumentException:Invalid byte 2 of 2-byte UTF-8 sequence
- 博客分类:
- Java
今天做工作流项目(jbpm4),将流程文件导出成xml到客户端后,编码格式是utf-8的,在本地将导出的xml导入到mysql数据库中是正常的,但是将该项目打成war包后放到虚拟机中的tomcat中,运行虚拟机中的tomcat,并访问项目时候,导出的也是utf-8的xml文件,但是再将该文件导入到mysql数据库时候却出现下面的错误:
google了一下找到了下面的解决方法:
将原先导出的流程xml文件中的编码格式由“utf-8”改成“gbk”后保存,再导入就可以了。
仔细分析原因,我的本地电脑用的是win 7 ,而虚拟机中的系统使用的想xp系统。在中文版的window下java的默认的编码为GBK,虽然我们标识了要将xml保存为utf-8格式但实际上文件是以GBK格式来保存的,所以这也就是为什么能够我们使用GBK、GB2312编码来生成xml文件能正确的被解析,而以UTF-8格式生成的文件不能被xml解析器所解析的原因。
给我解决思路的来源如chenyanbo所说:
http://blog.csdn.net/chenyanbo/article/details/6866941
下面是我的一个导出的流程xml文件:
org.dom4j.DocumentException: Invalid byte 1 of 1-byte UTF-8 sequence. Nested exception: Invalid byte 1 of 1-byte UTF-8 sequence. at org.dom4j.io.SAXReader.read(SAXReader.java:484) at org.dom4j.io.SAXReader.read(SAXReader.java:321) at com.dataoperate.PaseXml.pXml(PaseXml.java:28) at com.dataoperate.JdbcOp.insertDb(JdbcOp.java:30) at com.dataoperate.JdbcOp.main(JdbcOp.java:89)
google了一下找到了下面的解决方法:
将原先导出的流程xml文件中的编码格式由“utf-8”改成“gbk”后保存,再导入就可以了。
仔细分析原因,我的本地电脑用的是win 7 ,而虚拟机中的系统使用的想xp系统。在中文版的window下java的默认的编码为GBK,虽然我们标识了要将xml保存为utf-8格式但实际上文件是以GBK格式来保存的,所以这也就是为什么能够我们使用GBK、GB2312编码来生成xml文件能正确的被解析,而以UTF-8格式生成的文件不能被xml解析器所解析的原因。
给我解决思路的来源如chenyanbo所说:
http://blog.csdn.net/chenyanbo/article/details/6866941
下面是我的一个导出的流程xml文件:
<?xml version="1.0" encoding="UTF-8"?> <root><TbBWebWorkflOwMain id="1000118"><node id="1000118"><wwmWorkflowId id="1000118">1000118</wwmWorkflowId><wwmWorkflowName id="1000118">test20</wwmWorkflowName><wwmWorkflowVersion id="1000118">1</wwmWorkflowVersion><wwmWorkflowIspress id="1000118"></wwmWorkflowIspress><wwmWorkflowIsemail id="1000118"></wwmWorkflowIsemail><wwmWorkflowIssms id="1000118"></wwmWorkflowIssms><wwmWorkflowXml id="1000118"> <process-definition xmlns="http://jbpm.org/4.4/jpdl" name="aaaa" key="aaaa"><task xmlns="" name="任务1" g="221,360,72,32"><assignment-handler class="com.sense.workflow.core.FirstAssigneeHandler"/><description>164D9B9892EA4C9C95D5972CBCF2AC14</description><transition name="任务2" to="任务2"/></task><start xmlns="" name="开始" g="241,290,32,32"><transition name="任务1" to="任务1"/></start><end xmlns="" name="结束" g="240,530,32,32"/><task xmlns="" name="任务3" g="220,480,72,32"><assignment-handler class="com.sense.workflow.core.CustomAssigneeHandler"/><description>FBBC22F3502C4C84B061A9E7034DD2F6</description><transition name="结束" to="结束"/></task><task xmlns="" name="任务2" g="220,420,72,32"><assignment-handler class="com.sense.workflow.core.CustomAssigneeHandler"/><description>24820DFF666A437A877054582FD1E246</description><transition name="任务3" to="任务3"/></task><migrate-instances/></process-definition></wwmWorkflowXml><wwmWorkflowMemo id="1000118"></wwmWorkflowMemo><wwnWorkflowIsrelease id="1000118">1</wwnWorkflowIsrelease><wwnWorkflowReleaseTime id="1000118">2013-09-09 13:17:41.0</wwnWorkflowReleaseTime><wwmCreateDatetime id="1000118">2012-11-20 10:19:41.0</wwmCreateDatetime><wwmLastUpdateDatetime id="1000118">2013-09-09 14:49:12.0</wwmLastUpdateDatetime><wwmLastUpdateOperatorId id="1000118"></wwmLastUpdateOperatorId><wwmWorkflowKey id="1000118">aaaa</wwmWorkflowKey></node></TbBWebWorkflOwMain><TbBWebWorkflOwNode id="1000420"><node id="1000420"><wwnNodeId id="1000420">1000420</wwnNodeId><wwnWwmWorkflowId id="1000420">1000118</wwnWwmWorkflowId><wwnWwmWorkflowName id="1000420">test20</wwnWwmWorkflowName><wwnNodeStepNumber id="1000420">1</wwnNodeStepNumber><wwnNodeName id="1000420">任务1</wwnNodeName><wwnNodeDescription id="1000420">164D9B9892EA4C9C95D5972CBCF2AC14</wwnNodeDescription><wwnNodeType id="1000420">1</wwnNodeType><wwnFormInfo id="1000420">noForm.jsp</wwnFormInfo><wwnTransreadToPeople id="1000420">{"chuanyueType":"1","display":"乐天","config":"82E6911F5DC0419680C65451C0A2CF71"}</wwnTransreadToPeople><wwnTransemailToPeople id="1000420"></wwnTransemailToPeople><wwnLuyouConfig id="1000420">{"lyType":0,"config":[2]}</wwnLuyouConfig><wwnRightConfig id="1000420">{"isRevoke":0,"isCircular":1,"isManualCirculate":1,"isAttachment":1,"isAssign":1,"returnConfig":{"returnType":"0","returnStep":[]}}</wwnRightConfig><wwnPressConfig id="1000420">{"isPress":"0","isEmail":"1","pressTimes":"1","pressInterval":"1"}</wwnPressConfig><wwnAssignConfig id="1000420">{"assignType":[2],"config":[["1"]]}</wwnAssignConfig><wwnHuqianConfig id="1000420"></wwnHuqianConfig><wwnXmlText id="1000420"> <root><start><transition to="任务1"/></start><task name="任务1" form="noForm.jsp"><assignment-handler class="com.sense.workflow.core.FirstAssigneeHandler"/><description>164D9B9892EA4C9C95D5972CBCF2AC14</description><transition name="2" to="2"/></task></root></wwnXmlText><wwnCreateDatetime id="1000420">2012-11-20 10:19:41.0</wwnCreateDatetime><wwnLastUpdateDatetime id="1000420">2013-09-09 14:49:12.0</wwnLastUpdateDatetime><wwnLastUpdateOperatorId id="1000420"></wwnLastUpdateOperatorId></node><node id="1000421"><wwnNodeId id="1000421">1000421</wwnNodeId><wwnWwmWorkflowId id="1000421">1000118</wwnWwmWorkflowId><wwnWwmWorkflowName id="1000421">test20</wwnWwmWorkflowName><wwnNodeStepNumber id="1000421">2</wwnNodeStepNumber><wwnNodeName id="1000421">任务2</wwnNodeName><wwnNodeDescription id="1000421">24820DFF666A437A877054582FD1E246</wwnNodeDescription><wwnNodeType id="1000421">1</wwnNodeType><wwnFormInfo id="1000421">noForm.jsp</wwnFormInfo><wwnTransreadToPeople id="1000421">{"chuanyueType":"0","display":"","config":""}</wwnTransreadToPeople><wwnTransemailToPeople id="1000421"></wwnTransemailToPeople><wwnLuyouConfig id="1000421">{"lyType":0,"config":[3]}</wwnLuyouConfig><wwnRightConfig id="1000421">{"isRevoke":0,"isCircular":0,"isManualCirculate":1,"isAttachment":1,"isAssign":1,"returnConfig":{"returnType":"0","returnStep":[]}}</wwnRightConfig><wwnPressConfig id="1000421">{"isPress":"0","isEmail":"1","pressTimes":"1","pressInterval":"1"}</wwnPressConfig><wwnAssignConfig id="1000421">{"assignType":[2],"config":[["1"]]}</wwnAssignConfig><wwnHuqianConfig id="1000421"></wwnHuqianConfig><wwnXmlText id="1000421"> <root><task name="任务2" form="noForm.jsp"><assignment-handler class="com.sense.workflow.core.CustomAssigneeHandler"/><description>24820DFF666A437A877054582FD1E246</description><transition name="3" to="3"/></task></root></wwnXmlText><wwnCreateDatetime id="1000421">2012-11-20 10:19:41.0</wwnCreateDatetime><wwnLastUpdateDatetime id="1000421">2013-09-09 14:49:12.0</wwnLastUpdateDatetime><wwnLastUpdateOperatorId id="1000421"></wwnLastUpdateOperatorId></node><node id="1000422"><wwnNodeId id="1000422">1000422</wwnNodeId><wwnWwmWorkflowId id="1000422">1000118</wwnWwmWorkflowId><wwnWwmWorkflowName id="1000422">test20</wwnWwmWorkflowName><wwnNodeStepNumber id="1000422">3</wwnNodeStepNumber><wwnNodeName id="1000422">任务3</wwnNodeName><wwnNodeDescription id="1000422">FBBC22F3502C4C84B061A9E7034DD2F6</wwnNodeDescription><wwnNodeType id="1000422">1</wwnNodeType><wwnFormInfo id="1000422">noForm.jsp</wwnFormInfo><wwnTransreadToPeople id="1000422">{"chuanyueType":"0","display":"","config":""}</wwnTransreadToPeople><wwnTransemailToPeople id="1000422"></wwnTransemailToPeople><wwnLuyouConfig id="1000422">{"lyType":0,"config":[4]}</wwnLuyouConfig><wwnRightConfig id="1000422">{"isRevoke":0,"isCircular":0,"isManualCirculate":0,"isAttachment":1,"isAssign":1,"returnConfig":{"returnType":"3","returnStep":[]}}</wwnRightConfig><wwnPressConfig id="1000422">{"isPress":"0","isEmail":"1","pressTimes":"1","pressInterval":"1"}</wwnPressConfig><wwnAssignConfig id="1000422">{"assignType":[2],"config":[["1"]]}</wwnAssignConfig><wwnHuqianConfig id="1000422"></wwnHuqianConfig><wwnXmlText id="1000422"> <root><task name="任务3" form="noForm.jsp"><assignment-handler class="com.sense.workflow.core.CustomAssigneeHandler"/><description>FBBC22F3502C4C84B061A9E7034DD2F6</description><transition name="4" to="4"/></task></root></wwnXmlText><wwnCreateDatetime id="1000422">2012-11-20 10:19:41.0</wwnCreateDatetime><wwnLastUpdateDatetime id="1000422">2013-09-09 14:49:12.0</wwnLastUpdateDatetime><wwnLastUpdateOperatorId id="1000422"></wwnLastUpdateOperatorId></node><node id="1000423"><wwnNodeId id="1000423">1000423</wwnNodeId><wwnWwmWorkflowId id="1000423">1000118</wwnWwmWorkflowId><wwnWwmWorkflowName id="1000423">test20</wwnWwmWorkflowName><wwnNodeStepNumber id="1000423">4</wwnNodeStepNumber><wwnNodeName id="1000423">结束</wwnNodeName><wwnNodeDescription id="1000423">15D72A74A5B5439593AA0558AA940E78</wwnNodeDescription><wwnNodeType id="1000423">6</wwnNodeType><wwnFormInfo id="1000423">noForm.jsp</wwnFormInfo><wwnTransreadToPeople id="1000423">{"display":"","config":"","chuanyueType":0}</wwnTransreadToPeople><wwnTransemailToPeople id="1000423"></wwnTransemailToPeople><wwnLuyouConfig id="1000423">{"config":[],"lyType":0}</wwnLuyouConfig><wwnRightConfig id="1000423">{"isCircular":0,"isAttachment":1,"isAssign":0,"returnConfig":{"returnType":0},"isRevoke":0}</wwnRightConfig><wwnPressConfig id="1000423">{"pressTimes":"0","isEmail":"1","isPress":0,"pressInterval":"0"}</wwnPressConfig><wwnAssignConfig id="1000423">{"assignType":[],"config":[]}</wwnAssignConfig><wwnHuqianConfig id="1000423"></wwnHuqianConfig><wwnXmlText id="1000423"><end name="结束"/></wwnXmlText><wwnCreateDatetime id="1000423">2012-11-20 10:19:41.0</wwnCreateDatetime><wwnLastUpdateDatetime id="1000423">2013-09-09 14:49:12.0</wwnLastUpdateDatetime><wwnLastUpdateOperatorId id="1000423"></wwnLastUpdateOperatorId></node></TbBWebWorkflOwNode></root>
发表评论
-
VMware中安装了ubuntu全屏设置
2016-01-18 00:09 2697在VMware虚拟机下的linux无法全屏的问题: 在VMwa ... -
Could not set the project description for 'hotelseqbid.ws' because the project d
2016-01-13 17:21 3593用eclipse 对项目进行Maven>Update P ... -
ASCII码值表
2014-03-30 14:23 972ASCII码值表 来源:http://blog.csdn.n ... -
Invalid character '\n' in value part of property(Oracle)
2013-10-12 17:11 4591链接地址:http://kevin12.i ... -
org.jbpm.api.JbpmException: no jBPM DB schema: no JBPM4_EXECUTION table
2013-09-30 14:37 3664链接地址:http://kevin12.iteye.com/b ... -
dom4j解析xml,dom4j 将对象解析到xml文件中以流的方式输出到服务器
2013-09-22 15:11 5392最近做流程项目用到了dom4j,于是就对dom4j进行了大概的 ... -
javascript 动态显示当前时间(系统时间)和指定时间差
2013-08-24 15:04 2156最近做流程项目计算流程总耗时用到了动态显示总耗时的时间,就是用 ... -
android的AutoCompleteTextView和MultiAutoCompleteTextView控件
2013-08-04 22:57 1220AutoCompleteTextView:自动完成输入内容的控 ... -
Description Resource Path Location Type Project has no default.properties file!
2013-03-04 22:39 2101在eclipse中创建android项目时候,通过File-- ... -
jQuery调用JSON时,net.sf.json.JSONException: There is a cycle in the hierarchy
2013-01-09 17:12 1028jQuery调用JSON时,net.sf.js ... -
spring配置异常
2013-01-06 12:08 849异常 org.springframework.orm.hibe ...
相关推荐
当我们遇到“java.lang.ClassNotFoundException: org.dom4j.DocumentException”的错误提示时,这通常意味着系统中缺少了DOM4j库,只需将“org.dom4j.jar”添加到项目类路径中即可解决此问题。 DOM4J是基于DOM和SAX...
解决 com.itextpdf.text.DocumentException: Font 'STSongStd-Light' with 'UniGB-UCS2-H' is not recognized. 亲测可用!
8. `org.dom4j.ElementHandler`: 提供了处理Element对象的方法,用于自定义元素处理逻辑。 9. `org.dom4j.ElementPath`: 用于ElementHandler,提供当前处理路径层次的信息。 10. `org.dom4j.Entity`: 定义XML实体,...
1. **下载`dom4j`库**:可以从官方网站http://dom4j.org/下载`dom4j`的最新版本,通常包括`dom4j-full.jar`或`dom4j.jar`等文件。 2. **配置ClassPath**:将下载的jar文件添加到项目的ClassPath中。如果是`dom4j-...
import org.dom4j.DocumentException; import org.dom4j.io.SAXReader; public class Dom4JExample { public static void main(String[] args) { try { SAXReader reader = new SAXReader(); Document document...
首先,我们import dom4j的相关类,包括Document、DocumentException、DocumentHelper和Element等。然后,我们使用DocumentHelper.parseText方法来解析XML字符串,并获取根元素。最后,我们可以使用Element对象的方法...
* @throws org.dom4j.DocumentException occurs whenever the build process fails. */ public void parseWithSAX(File aFile) throws DocumentException { SAXReader xmlReader = new SAXReader(); this.doc =...
import org.dom4j.DocumentException; import org.dom4j.DocumentFactory; import org.dom4j.Element; import org.dom4j.io.SAXReader; public class Dom4jDemo { public static void main(String[] args) { try ...
4. **异常处理**: dom4j在源码中广泛使用了异常处理机制,如`DocumentException`和`IOException`,确保在处理XML时能捕获并处理可能出现的问题。 **五、使用示例** 以下是一个简单的dom4j使用示例: ```java import...
import org.dom4j.DocumentException; import org.dom4j.Element; import org.dom4j.io.SAXReader; public class Dom4JExample { public static void main(String[] args) { try { SAXReader reader = new ...
### 使用dom4j读取XML的四种方法 在Java开发中,处理XML文件是一种常见的需求。Dom4j作为一款简洁高效的Java库,被广泛应用于解析、操作XML文档。本文将详细介绍使用dom4j读取XML文件的四种常见方法,并通过示例...
import org.dom4j.DocumentException; import org.dom4j.io.SAXReader; public class Dom4jExample { public static void main(String[] args) { try { SAXReader reader = new SAXReader(); Document document...
import org.dom4j.DocumentException; import org.dom4j.DocumentFactory; import org.dom4j.Element; import java.io.File; public class Dom4jExample { public static void main(String[] args) { try { // ...
import org.dom4j.DocumentException; import org.dom4j.Element; import org.dom4j.io.SAXReader; ``` 接下来,我们将创建一个`SAXReader`实例,它是DOM4J中的解析器,用于读取XML文件: ```java SAXReader ...
import org.dom4j.DocumentException; import org.dom4j.io.SAXReader; public class ParseXML { public static void main(String[] args) { SAXReader reader = new SAXReader(); try { Document document = ...
import org.dom4j.DocumentException; import org.dom4j.io.SAXReader; File file = new File("emailTemplateConfig.xml"); SAXReader reader = new SAXReader(); try { Document document = reader.read(file); }...
import org.dom4j.DocumentException; import org.dom4j.Element; import org.dom4j.io.SAXReader; public class Dom4jExample { public static void main(String[] args) { try { // 创建SAXReader对象 ...
import org.dom4j.DocumentException; import org.dom4j.io.SAXReader; // 创建DocumentBuilder SAXReader reader = new SAXReader(); try { // 读取XML文件 Document doc = reader.read(new File("path/to/...
import org.dom4j.DocumentException; import org.dom4j.io.SAXReader; import org.xml.sax.helpers.DefaultHandler; public class Dom4jSaxExample { public static void main(String[] args) { SAXReader ...