[英]Getting 'Missing Required Attribute' JiBX error after migrating to WebLogic 12
早上好,
我一直在從事以下項目:
我確定這無濟於事,但我是Java / Spring / WebLogic領域的新手。
我能夠從JRockit 1.6升級到Java 7,但是當涉及到WebLogic部分時,我在啟動應用程序時遇到了問題。
每次這樣做,都會出現以下錯誤
org.jibx.runtime.JiBXException: Missing required attribute "a" (line 1, col 71)
at org.jibx.runtime.impl.UnmarshallingContext.attributeText(UnmarshallingContext.java:975)
at com.mydomain.JiBX_rule_def_bindingMungeAdapter.JiBX_rule_def_binding_unmarshalAttr_1_0()
at com.mydomain.JiBX_rule_def_bindingMutableRuleDefinition_access.unmarshal()
at org.jibx.runtime.impl.UnmarshallingContext.unmarshalElement(UnmarshallingContext.java:2757)
at org.jibx.runtime.impl.UnmarshallingContext.unmarshalDocument(UnmarshallingContext.java:2900)
並且已經嘗試調試了一段時間。 真正奇怪的是,當我從Spring / WebLogic環境中取出代碼並執行時,它可以正常工作(即,將數據解組)。
當它在帶有JRockit 1.6和JiBX 1.2.1 jar的WebLogic 10.3.5環境中時,我的問題是零。
這是我嘗試過的
嘗試包括一個weblogic.xml文件(以前沒有一個文件),並嘗試使用
<preferred-web-inf>true</preferred-web-inf>
但沒有運氣
以下是有關我正在工作的環境的更多信息
沒有xsd文件,只有.xml綁定文件
<binding> <mapping name="rule" class="com.mydomain.MutableRuleDefinition"> <value name="a" field="a" style="attribute" /> <value name="b" field="b" style="attribute" /> <collection field="ruleElements"> <structure name="ruleElement" type="com.mydomain.MutableRuleElement"> <value name="c" field="c" style="attribute" /> <value name="d" field="d" style="attribute" /> <collection field="values" item-type="java.lang.String" usage="optional"> <value name="value" /> </collection> </structure> </collection> </mapping> </binding>
這是解組代碼:
private MutableRuleDefinition unmarshalXMLRuleDef(String _xmlRuleDef) {
MutableRuleDefinition mruleDef = null;
try {
IBindingFactory bfact = BindingDirectory
.getFactory(MutableRuleDefinition.class);
IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
mruleDef = (MutableRuleDefinition) uctx.unmarshalDocument(
new ByteArrayInputStream(_xmlRuleDef.getBytes()), null);
} catch (JiBXException e) {
logger.error("Could not un-marshalling the XML rule definition:["
+ _xmlRuleDef + "]", e);
}
顯然,這是JiBX 1.2.1中的一個問題,但在1.2.2中已解決:
https://www.mail-archive.com/jibx-users@lists.sourceforge.net/msg04200.html
任何幫助表示贊賞。 如果您需要更多信息,請告訴我...
更新#1
我努力了
<value name="a" field="a" style="attribute" usage=optional />
在所有屬性標志上都可以進行解組,但是,這些字段不是可選的,因此我不能將其用作解決方法。
更新#2
首先,這是一個未經編組的示例
<rule a="dataForA" b="dataForB">
<ruleElement c="dataForC1" d="dataForD1" />
<ruleElement c="dataForC2" d="dataForD2" />
<ruleElement c="dataForC3" d="dataForD3" />
<ruleElement c="dataForC4" d="dataForD3" />
</rule>
R漢娜,
我建議您查看JiBX依賴項,並確保所有Jars與JiBX使用的版本完全相同。 我們使用一些經常與Web服務器jar沖突的Eclipse庫。
另外,請記住,JiBX是開源的。 您可能需要單步執行代碼,然后查看導致JiBX失敗的原因。
還有一件事。 我看不到您的架構定義,但是奇怪的是該錯誤似乎表明您缺少屬性。 您確定不需要'source'屬性。
祝好運!
Don Corley JiBX貢獻者
R漢娜,
我在使用1.2.5版本的jibx之后為我解決了這個問題,但是我確保所有相關的jar也都更新到了1.2.5,並確保在我的戰爭中不存在由以前的jar創建的過時的類文件。對我來說這招希望它可以幫助您。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.