日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 人文社科 > 生活经验 >内容正文

生活经验

JBPM4常见错误汇总

發(fā)布時(shí)間:2023/11/27 生活经验 41 豆豆
生活随笔 收集整理的這篇文章主要介紹了 JBPM4常见错误汇总 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

1.在tomcat6.0下布署錯(cuò)誤
?? 基于JBPM4的web項(xiàng)目jsp頁(yè)面發(fā)布出錯(cuò)
現(xiàn)象:

 javax.servlet.ServletException: java.lang.LinkageError: loader constraint violation: when resolving interface method "javax.servlet.jsp.JspApplicationContext.getExpressionFactory()Ljavax/el/ExpressionFactory;" the class loader (instance of org/apache/jasper/servlet/JasperLoader) of the current class, org/apache/jsp/OnDuty/wfmanage_jsp, and the class loader (instance of org/apache/catalina/loader/StandardClassLoader) for resolved class, javax/servlet/jsp/JspApplicationContext, have different Class objects for the type javax/el/ExpressionFactory used in the signature
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:
275)
javax.servlet.http.HttpServlet.service(HttpServlet.java:
717)
。。。

?


原因:
?? 項(xiàng)目中WEB-INF\lib中的三個(gè)jar包(juel.jar, juel-engine.jar, juel-impl.jar)和tomcat6下lib中jar包(el-api.jar)沖突

解決方法:
?? 方法一:換成tomcat5.5 一點(diǎn)問(wèn)題也沒(méi)有了
?? 方法二:將juel.jar, juel-engine.jar, juel-impl.jar這三個(gè)包復(fù)制到tomcat6下lib中,并刪除原來(lái)的el-api.jar,切記要把WEB-INF\lib中的juel.jar, juel-engine.jar, juel-impl.jar刪除。不然還是要沖突。?

2.無(wú)法保存(布署)含有中文的流程定義文件
現(xiàn)象:
保存流程定義文件

???

?

<?xml version="1.0" encoding="GBK"?>
<process name="leave" xmlns="http://jbpm.org/4.0/jpdl">
<start g="201,14,48,48" name="開(kāi)始">
<transition g="-42,-10" name="請(qǐng)假" to="填寫(xiě)請(qǐng)假單"/>
</start>
...

?


提示錯(cuò)誤:
?? MalformedByteSequenceException:Invalid byte 1 of 1-byte UTF-8 sequence

原因:
?? XML字符串大概經(jīng)過(guò)了下面一些方法才被解析為DOM:

org.jbpm.pvm.internal.repository.DeploymentImpl:
public NewDeployment addResourceFromString(String resourceName, String text) {
addResourceFromStreamInput(resourceName,
new StringStreamInput(text));
return this;
}
public NewDeployment addResourceFromString(String resourceName, String text) {
addResourceFromStreamInput(resourceName,
new StringStreamInput(text));
return this;
}

org.jbpm.pvm.internal.stream.StringStreamInput:
public class StringStreamInput extends StreamInput {
String string;
public StringStreamInput(String string) {
this.name = "string";
this.string = string;
}
public InputStream openStream() {
byte[] bytes = string.getBytes();
return new ByteArrayInputStream(bytes);
}
}
public class StringStreamInput extends StreamInput {
String string;
public StringStreamInput(String string) {
this.name = "string";
this.string = string;
}
public InputStream openStream() {
byte[] bytes = string.getBytes();
return new ByteArrayInputStream(bytes);
}
}

org.jbpm.pvm.internal.xml.Parse:
protected InputSource getInputSource() {
if (inputSource!=null) {
return inputSource;
}
if (streamInput!=null) {
inputStream
= streamInput.openStream();
return new InputSource(inputStream);
}
addProblem(
"no source specified to parse");
return null;
}
protected InputSource getInputSource() {
if (inputSource!=null) {
return inputSource;
}
if (streamInput!=null) {
inputStream
= streamInput.openStream();
return new InputSource(inputStream);
}
addProblem(
"no source specified to parse");
return null;
}

org.jbpm.pvm.internal.xml.Parser:
protected Document buildDom(Parse parse) {
Document document
= null;
try {
SAXParser saxParser
= saxParserFactory.newSAXParser();
XMLReader xmlReader
= saxParser.getXMLReader();
// ...

InputSource inputSource
= parse.getInputSource();
xmlReader.parse(inputSource);

}
catch (Exception e) {
parse.addProblem(
"couldn't parse xml document", e);
}

return document;
}

?


?? 經(jīng)過(guò)層層包裝、拆包、再包裝再拆包,可憐的字符串終于來(lái)到SAX解析器的手上。問(wèn)題是jBPM在中間調(diào)用了String.getBytes():這個(gè)方法 會(huì)把Java字符串(Unicode)轉(zhuǎn)換為系統(tǒng)默認(rèn)編碼并返回對(duì)應(yīng)的byte[],但當(dāng)InputSource中沒(méi)有設(shè)置編碼信息 時(shí),SAXParser默認(rèn)是以UTF-8編碼來(lái)讀取輸入流的。我的開(kāi)發(fā)機(jī)的系統(tǒng)默認(rèn)編碼是GBK,于是就出問(wèn)題了。

解決方法:
?? String?xmlStr?=?"<?xml?version=\"1.0\"?encoding=\""?+?System.getProperty("file.encoding")?+?"\"?><test?name=\"名稱(chēng)\"></test>";?
?? 這里就用System.getProperty("file.encoding")去獲取系統(tǒng)默認(rèn)編碼,以便于String.getBytes()匹配。
?? 如果你能確保你的WEB服務(wù)器上運(yùn)行的字符集是GBK,也可以寫(xiě)成

?

<?xml version="1.0" encoding="GBK"?>
<process name="leave" xmlns="http://jbpm.org/4.0/jpdl">
<start g="201,14,48,48" name="開(kāi)始">
<transition g="-42,-10" name="請(qǐng)假" to="填寫(xiě)請(qǐng)假單"/>
</start>
...

?



3.無(wú)法保存(布署)含有中文的流程定義文件
現(xiàn)象:
?? 流程定義已經(jīng)成功保存到數(shù)據(jù)庫(kù)中,但無(wú)法執(zhí)行,
?? 數(shù)據(jù)庫(kù)表jbpm4_execution中的任務(wù)名稱(chēng)為亂碼

原因:
?? 數(shù)據(jù)庫(kù)中任務(wù)名稱(chēng)為亂碼的根本原因不是hiberate保存到j(luò)bpm4_lob中的字段BLOB_VALUE造成的。而是JSP頁(yè)面?zhèn)鬟f給servlet流程定義文本時(shí),中文轉(zhuǎn)碼錯(cuò)誤造成的。即servlet接收的即亂碼。

解決方法
? 1)JSP頁(yè)面中顯示中文亂碼
???? 在JSP文件中使用page命令指定響應(yīng)結(jié)果的MIME類(lèi)型,如<%@ page language="java" contentType="text/html;charset=gbk" %>
? 2)表單提交亂碼???
??? 表單提交時(shí)(post和Get方法),使用request.getParameter方法得到亂碼,這是因?yàn)閠omcat處理提交的參數(shù)時(shí)默認(rèn)的是iso-8859-1,表單提交get和post處理亂碼問(wèn)題不同,下面分別說(shuō)明。
??? (1)POST處理
??? 對(duì)post提交的表單通過(guò)編寫(xiě)一個(gè)過(guò)濾器的方法來(lái)解決,過(guò)濾器在用戶(hù)提交的數(shù)據(jù)被處理之前被調(diào)用,可以在這里改變參數(shù)的編碼方式,過(guò)濾器的代碼如下:
Java代碼

?

package example.util;

import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

public class SetCharacterEncodingFilter implements Filter {
protected String encoding = null;
protected FilterConfig filterConfig = null;
protected boolean ignore = true;

public void destroy() {
this.encoding = null;
this.filterConfig = null;
}

public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain)
throws IOException, ServletException {
if (ignore || (request.getCharacterEncoding() == null)) {
String encoding
= selectEncoding(request);
if (encoding != null) {
request.setCharacterEncoding(encoding);
}
}

// Pass control on to the next filter
chain.doFilter(request, response);

}
public void init(FilterConfig filterConfig) throws ServletException {

this.filterConfig = filterConfig;
this.encoding = filterConfig.getInitParameter("encoding");
String value
= filterConfig.getInitParameter("ignore");
if (value == null) {
this.ignore = true;
}
else if (value.equalsIgnoreCase("true")) {
this.ignore = true;
}
else if (value.equalsIgnoreCase("yes")) {
this.ignore = true;
}
else {
this.ignore = false;
}

}

protected String selectEncoding(ServletRequest request) {

return (this.encoding);

}

}

?



web.xml文件加入過(guò)濾器

?

<filter>
<filter-name>Encoding</filter-name>
<filter-class>
example.util.SetCharacterEncodingFilter
</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>gbk</param-value>
<!--gbk或者gb2312或者utf-8-->
</init-param>
<init-param>
<param-name>ignore</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>Encoding</filter-name>
<servlet-name>/*</servlet-name>
</filter-mapping>

?



(2) Get方法的處理
?tomcat對(duì)post和get的處理方法不一樣,所以過(guò)濾器不能解決get的亂碼問(wèn)題,它需要在其他地方設(shè)置。
?打開(kāi)<tomcat_home>\conf目錄下server.xml文件,找到對(duì)8080端口進(jìn)行服務(wù)的Connector組件的設(shè)置部分,給這個(gè)組件添加一個(gè)屬性:URIEncoding="GBK"。修改后的Connector設(shè)置為:
??

<Connector port="8080" maxHttpHeaderSize="8192"
maxThreads
="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups
="false" redirectPort="8443" acceptCount="100"
connectionTimeout
="20000" disableUploadTimeout="true" URIEncoding="GBK" />

?


? * 注意修改后重新啟動(dòng)tomcat才能起作用。

4.運(yùn)行出錯(cuò)時(shí),數(shù)據(jù)庫(kù)中的所有數(shù)據(jù)丟失
現(xiàn)象:
?? 運(yùn)行出錯(cuò)后,數(shù)據(jù)庫(kù)中的所有數(shù)據(jù)丟失,包括流程定義文件

原因:
?? jbpm.hibernate.cfg.xml文件中有一個(gè)配置

???
 <property name="hibernate.hbm2ddl.auto" value="create-drop"/> 

幾個(gè)參數(shù)的意思,我解釋一下:
validate 加載hibernate時(shí),驗(yàn)證創(chuàng)建數(shù)據(jù)庫(kù)表結(jié)構(gòu)
create 每次加載hibernate,重新創(chuàng)建數(shù)據(jù)庫(kù)表結(jié)構(gòu),這就是導(dǎo)致數(shù)據(jù)庫(kù)表數(shù)據(jù)丟失的原因。
create-drop 加載hibernate時(shí)創(chuàng)建,退出是刪除表結(jié)構(gòu)
update 加載hibernate自動(dòng)更新數(shù)據(jù)庫(kù)結(jié)構(gòu)
none 不進(jìn)行任何操作

?



?? 由于jbpm4的默認(rèn)配置為create-drop,所以出現(xiàn)以上問(wèn)題

解決方法:
?? 將jbpm.hibernate.cfg.xml文件中修改如下

 <property name="hibernate.hbm2ddl.auto" value="none"/>   

?



5.在eclipse3.5流程設(shè)計(jì)器上設(shè)計(jì)流程時(shí),中文出現(xiàn)亂碼
現(xiàn)象:
?? 將流程設(shè)計(jì)好之后,點(diǎn)擊保存,再查看代碼,發(fā)現(xiàn)中文是亂碼

原因:
?? 不清楚,應(yīng)該是插件的bug

解決方法:
?? 將流程設(shè)計(jì)好之后,不要點(diǎn)保存,先將界面切換到代碼窗口,這時(shí)可以看到中文,再點(diǎn)擊保存

6.無(wú)法布署zip流程定義文件
現(xiàn)象:
?? 提示以下錯(cuò)誤

 streams type cannot be used in batching
2009-11-26 15:58:07 org.hibernate.event.def.AbstractFlushingEventListener performExecutions
嚴(yán)重: Could not synchronize database state with session
org.hibernate.exception.GenericJDBCException: could not insert: [org.jbpm.pvm.internal.lob.Lob]

?



原因:
?? 當(dāng)把數(shù)據(jù)值增加超過(guò)100時(shí),hiberate就出現(xiàn)了這個(gè)異常--這意味著Oracle JDBC不允許流操作以批量方式執(zhí)行

解決方法:
?? 在jbpm.hibernate.cfg.xml文件的<session-factory>下,添加

 <property name="hibernate.jdbc.batch_size">0</property>  

?


?? 即可

7.無(wú)法布署zip流程定義文件
現(xiàn)象:
?? 提示錯(cuò)誤

 Could not synchronize database state with session
org.hibernate.exception.GenericJDBCException: could not insert: [org.jbpm.pvm.internal.lob.Lob]

?



原因:
?? 布署ZIP流程定義文件時(shí)hiberate無(wú)法插入blob
?? 用網(wǎng)絡(luò)上提議的方法,添加以下配置

 <property name="hibernate.jdbc.batch_size">0</property>
<property name="hibernate.jdbc.use_streams_for_binary">true</property>

?


?? 也不行

解決方法:
?? 采用以上方法,還是無(wú)法通過(guò),最后重啟操作系統(tǒng),就解決了,奶奶的。

8.布署zip流程定義文件成功,但是數(shù)據(jù)庫(kù)中中文為亂碼
現(xiàn)象:

???
<?xml version="1.0" encoding="GBK"?>
<process name="leave" xmlns="http://jbpm.org/4.0/jpdl">
<start g="201,14,48,48" name="開(kāi)始">
<transition g="-42,-10" name="請(qǐng)假" to="填寫(xiě)請(qǐng)假單"/>
</start>
...

?


?? 由于我的oracle9數(shù)據(jù)庫(kù)格式為GBK,所以XML文件頭為<?xml version="1.0" encoding="GBK"?>
?? 含有中文的流程定義zip文件已經(jīng)成功保存到了blob字段內(nèi),但是中文名為亂碼
?? 或者提示XML parse error,無(wú)法保存到數(shù)據(jù)庫(kù)

原因:
?? repositoryService.createDeployment().addResourcesFromZipInputStream(new ZipInputStream(item.getInputStream())).deploy();
?? 僅上面一句話,就不知道轉(zhuǎn)了多少次編碼,經(jīng)過(guò)測(cè)試發(fā)現(xiàn),還是編碼方式的問(wèn)題,最后決定將jbpm4.2的源代碼復(fù)制到項(xiàng)目中來(lái)調(diào)試。

解決方法:
?? 在網(wǎng)上發(fā)現(xiàn)了這篇文章《Java中壓縮與解壓--中文文件名亂碼解決辦法》
?? 結(jié)果問(wèn)題還是沒(méi)有解決
?? 最后經(jīng)過(guò)測(cè)試,將org.jbpm.pvm.internal.repository.DeploymentImpl類(lèi)中的方法進(jìn)行修改

???
public NewDeployment addResourcesFromZipInputStream(CnZipInputStream zipInputStream) {
try {
ZipEntry zipEntry
= zipInputStream.getNextEntry();
while(zipEntry!=null) {
String entryName
= zipEntry.getName();
byte[] bytes = IoUtil.readBytes(zipInputStream);

//如果是流程定義文件(不是圖片),則重新編碼,再生成字節(jié)數(shù)組
if(entryName.endsWith(".xml")){
String s
=new String(bytes,"utf-8");
bytes
=s.getBytes();
}

if (bytes!=null) {
addResourceFromStreamInput(entryName,
new ByteArrayStreamInput(bytes));
}
zipEntry
= zipInputStream.getNextEntry();
}
}
catch (Exception e) {
throw new JbpmException("couldn't read zip archive", e);
}
return this;
}

?


?? 問(wèn)題解決,肯定是開(kāi)始有一步編碼方式是用UTF-8,中間你就是再怎么用GBK轉(zhuǎn)碼,都不會(huì)成功,這里先用UTF-8編碼生成字符串,再轉(zhuǎn)一次編碼就成功了。

參考文獻(xiàn)
1.dzq2008. JBPM4項(xiàng)目和tomcat6.0的兼容問(wèn)題. http://dzq0371.javaeye.com/blog/509632
2.碰到j(luò)BPM的編碼問(wèn)題了. http://rednaxelafx.javaeye.com/blog/522436
3.如何解決Tomcat下中文亂碼問(wèn)題. http://www.javaeye.com/topic/251743?page=1
4.關(guān)于Hibernate一個(gè)配置參數(shù)hibernate.hbm2ddl.auto. http://linshiquan.javaeye.com/blog/263170

?

?

?

轉(zhuǎn)載于:https://www.cnblogs.com/gaoyoubo/articles/1838090.html

總結(jié)

以上是生活随笔為你收集整理的JBPM4常见错误汇总的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。