error@malformedXML with ajax requests in JSF

早过忘川 提交于 2019-12-25 09:26:11

问题


Context : Weblogic 12.2.1 / JSF 2.1.6 / Richfaces 4.2.2 / Primefaces 3.4

I have a JSF application that was on Weblogic 10.3.6 and that I successfully deploy on Weblogic 12.2.1.

I am facing the following error after each ajax request :

Received 'error@malformedXML' event from <input ...
[200] undefined: undefined

This error usually occurres when the component to be rendered is not present in the page but as you'll see in the following pieces of code, this is not the case :

Java

private int count = 0;

public void commandButton() {
    System.out.println("Click");
    count++;
}

public int getCount() {
    return count;
}

public void setCount(int count) {
    this.count = count;
}

HTML


JSF with Ajax

<h:form>
    <h:commandButton value="JSF with ajax">
        <f:ajax listener="#{myBean.commandButton}" render="count1" />
    </h:commandButton>
    <h:outputText id="count1" value="#{myBean.count}" />
</h:form>

The click on this button correctly executes myBean.commandButton but then produces the error described below and does a "refresh" of the page.


Richfaces

<h:form>
    <a4j:commandButton value="Richfaces" action="#{myBean.commandButton}" render="count2" />
    <h:outputText id="count2" value="#{myBean.count}" />
</h:form>

The click on this button correctly executes myBean.commandButton but then produces the error described below and does a "refresh" of the page.


Primefaces

<h:form>
    <p:commandButton value="Primefaces" action="#{myBean.commandButton}" update="count3" />
    <h:outputText id="count3" value="#{myBean.count}" />
</h:form>

The click on this button correctly executes myBean.commandButton and renders the output text with the incremented value.


EDIT 1 :

In order to deploy on Weblogic 12.2.1, I had to force Weblogic to use the given JSF 2.1.6 package through the weblogic-application.xml as mentioned here, such as :

<prefer-application-packages>
    <package-name>javax.faces.*</package-name>
    <package-name>com.sun.faces.*</package-name>
    <package-name>com.bea.faces.*</package-name>
</prefer-application-packages>

<prefer-application-resources> 
    <resource-name>javax.faces.*</resource-name> 
    <resource-name>com.sun.faces.*</resource-name> 
    <resource-name>com.bea.faces.*</resource-name> 
    <resource-name>META-INF/services/javax.servlet.ServletContainerInitializer</resource-name>
    <resource-name>META-INF/services/com.sun.faces.spi.FacesConfigResourceProvider</resource-name>
    <resource-name>META-INF/resources/javax.faces/jsf.js</resource-name>
</prefer-application-resources>

I am pretty sure that JSF packages are not conflicting since FacesContext.class.getPackage().getImplementationVersion() returns 2.1.6-SNAPSHOT and the wls-cat tool returns the following conflicted packages list and JSF's packages are not among them.

But I notice that even if I force Weblogic to use META-INF/resources/javax.faces/jsf.js from my JSF package, it actually uses the jsf.js file from Weblogic's JSF package : Web browser jsf.js

Conflicted packages list :

com.google.common.*
com.sun.mail.*
javax.el.*
javax.mail.*
javax.mail.event.*
javax.mail.internet.*
javax.mail.search.*
javax.mail.util.*
javax.persistence.*
javax.persistence.spi.*
javax.servlet.*
javax.servlet.http.*
javax.servlet.jsp.*
javax.transaction.*
javax.transaction.xa.*
javax.validation.*
javax.validation.bootstrap.*
javax.validation.constraints.*
javax.validation.groups.*
javax.validation.metadata.*
javax.validation.spi.*
net.jcip.annotations.*
net.sf.cglib.*
oracle.core.lmx.*
oracle.core.lvf.*
oracle.jdbc.*
oracle.jdbc.connector.*
oracle.jdbc.driver.*
oracle.jdbc.internal.*
oracle.jdbc.oci.*
oracle.jdbc.oracore.*
oracle.jdbc.pool.*
oracle.jdbc.rowset.*
oracle.jdbc.util.*
oracle.jdbc.xa.*
oracle.jpub.runtime.*
oracle.net.ano.*
oracle.net.jndi.*
oracle.net.ns.*
oracle.net.nt.*
oracle.net.resolver.*
oracle.security.o3logon.*
oracle.sql.*
oracle.sql.converter.*
org.aopalliance.aop.*
org.aopalliance.intercept.*
org.apache.commons.*
org.apache.oro.*
org.apache.xerces.*
org.apache.xmlbeans.*
org.bouncycastle.*
org.bouncycastle.asn1.*
org.bouncycastle.crypto.*
org.bouncycastle.i18n.*
org.bouncycastle.jce.*
org.bouncycastle.math.*
org.bouncycastle.ocsp.*
org.bouncycastle.util.*
org.bouncycastle.x509.*
org.slf4j.*
org.slf4j.helpers.*
org.slf4j.spi.*
org.w3c.dom.*
repackage.*
schemaorg_apache_xmlbeans.system.sXMLCONFIG.*
schemaorg_apache_xmlbeans.system.sXMLLANG.*
schemaorg_apache_xmlbeans.system.sXMLSCHEMA.*
schemaorg_apache_xmlbeans.system.sXMLTOOLS.*

Does anyone have an idea for this problem ?
Thanks in advance.


回答1:


I finally solved the problem :
The real file sent by the serveur is not META-INF/resources/javax.faces/jsf.js but META-INF/resources/javax.faces/jsf-uncompressed.js.

So the weblogic-application.xml file must have the following configuration :

<prefer-application-packages>
    <package-name>javax.faces.*</package-name>
    <package-name>com.sun.faces.*</package-name>
</prefer-application-packages>

<prefer-application-resources> 
    <resource-name>javax.faces.*</resource-name>
    <resource-name>com.sun.faces.*</resource-name>
    <resource-name>META-INF/services/javax.servlet.ServletContainerInitializer</resource-name>
    <resource-name>META-INF/services/com.sun.faces.spi.FacesConfigResourceProvider</resource-name>
    <resource-name>META-INF/resources/javax.faces/jsf.js</resource-name>
    <resource-name>META-INF/resources/javax.faces/jsf-uncompressed.js</resource-name>
</prefer-application-resources>


来源:https://stackoverflow.com/questions/41449303/errormalformedxml-with-ajax-requests-in-jsf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!