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文件:
1000118 test20 1 <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> 1 2013-09-09 13:17:41.0 2012-11-20 10:19:41.0 2013-09-09 14:49:12.0 aaaa 1000420 1000118 test20 1 任务1 164D9B9892EA4C9C95D5972CBCF2AC14 1 noForm.jsp {"chuanyueType":"1","display":"乐天","config":"82E6911F5DC0419680C65451C0A2CF71"} {"lyType":0,"config":[2]} {"isRevoke":0,"isCircular":1,"isManualCirculate":1,"isAttachment":1,"isAssign":1,"returnConfig":{"returnType":"0","returnStep":[]}} {"isPress":"0","isEmail":"1","pressTimes":"1","pressInterval":"1"} {"assignType":[2],"config":[["1"]]} <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> 2012-11-20 10:19:41.0 2013-09-09 14:49:12.0 1000421 1000118 test20 2 任务2 24820DFF666A437A877054582FD1E246 1 noForm.jsp {"chuanyueType":"0","display":"","config":""} {"lyType":0,"config":[3]} {"isRevoke":0,"isCircular":0,"isManualCirculate":1,"isAttachment":1,"isAssign":1,"returnConfig":{"returnType":"0","returnStep":[]}} {"isPress":"0","isEmail":"1","pressTimes":"1","pressInterval":"1"} {"assignType":[2],"config":[["1"]]} <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> 2012-11-20 10:19:41.0 2013-09-09 14:49:12.0 1000422 1000118 test20 3 任务3 FBBC22F3502C4C84B061A9E7034DD2F6 1 noForm.jsp {"chuanyueType":"0","display":"","config":""} {"lyType":0,"config":[4]} {"isRevoke":0,"isCircular":0,"isManualCirculate":0,"isAttachment":1,"isAssign":1,"returnConfig":{"returnType":"3","returnStep":[]}} {"isPress":"0","isEmail":"1","pressTimes":"1","pressInterval":"1"} {"assignType":[2],"config":[["1"]]} <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> 2012-11-20 10:19:41.0 2013-09-09 14:49:12.0 1000423 1000118 test20 4 结束 15D72A74A5B5439593AA0558AA940E78 6 noForm.jsp {"display":"","config":"","chuanyueType":0} {"config":[],"lyType":0} {"isCircular":0,"isAttachment":1,"isAssign":0,"returnConfig":{"returnType":0},"isRevoke":0} {"pressTimes":"0","isEmail":"1","isPress":0,"pressInterval":"0"} {"assignType":[],"config":[]} <end name="结束"/> 2012-11-20 10:19:41.0 2013-09-09 14:49:12.0