2

我正在为 Liferay 编写一个 Portlet,并且需要 ace:fileEntry 组件。我已经有一些我终于能够解决的问题。但现在我面临一个我无法理解的问题。

当包含 ace:fileEntry 的视图页是 openend 时,在正负 90 秒后将显示一个弹出窗口,其中显示消息“网络连接中断”,我必须重新加载页面。经过一番研究,我在浏览器控制台中发现了以下几行:

[icepush.0086c.async-connection] closing previous connection...
[icepush.0086c.async-connection] connect...
[icepush.0086c.async-connection] empty response received
[icepush.0086c.async-connection] closing previous connection...
[icepush.0086c.async-connection] connect...
[icepush.0086c.async-connection] empty response received
[icepush.0086c.async-connection] closing previous connection...
[icepush.0086c.async-connection] connect...
[icepush.0086c.async-connection] empty response received
[icepush.0086c.async-connection] blocking connection stopped, too many empty responses received...
[icepush.0086c.async-connection] failed to connect, first retry...
[icepush.0086c] connection in trouble
[icepush.0086c.async-connection] closing previous connection...
[icepush.0086c.async-connection] connect...
[icepush.0086c.async-connection] empty response received
[icepush.0086c.async-connection] blocking connection stopped, too many empty responses received...
[icepush.0086c.async-connection] failed to connect, second retry...
[icepush.0086c] connection in trouble
[icepush.0086c.async-connection] closing previous connection...
[icepush.0086c.async-connection] connect...
[icepush.0086c.async-connection] empty response received
[icepush.0086c.async-connection] blocking connection stopped, too many empty responses received...
[icepush.0086c] connection to server was lost

我正在使用以下版本的 Liferay 和 ICEFaces:

  • Liferay 门户 6.1.20-EE-GA2
  • Liferay-Faces-Bridge-Impl 3.1.2-ga3
  • ICEFaces 3.3.0

我的 web.xml 看起来像这样:

<?xml version="1.0"?>

<web-app
    version="3.0"
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
>
    <listener>
       <listener-class>
          org.springframework.web.context.ContextLoaderListener
       </listener-class>
    </listener>
    <listener>
       <listener-class>
          org.springframework.web.context.request.RequestContextListener
       </listener-class>
    </listener>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/applicationContext.xml</param-value>
    </context-param>
    <!-- Instruct Mojarra to utilize JBoss-EL instead of the EL implementation provided by the servlet container. -->
    <context-param>
        <param-name>com.sun.faces.expressionFactory</param-name>
        <param-value>org.jboss.el.ExpressionFactoryImpl</param-value>
    </context-param>
    <!-- Instruct ICEfaces to abstain from adding a random query parameter to resource URLs (which it does by default -->
    <!-- in order to prevent caching of JavaScript resources like bridge.js in a servlet-based webapp). -->
    <context-param>
        <param-name>org.icefaces.uniqueResourceURLs</param-name>
        <param-value>false</param-value>
    </context-param>
    <!-- Production wegen Test ob bestimmte Messages verschwinden -->
    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Production</param-value>
    </context-param>
    <context-param>
      <param-name>com.icesoft.faces.concurrentDOMViews</param-name>
      <param-value>true</param-value>
    </context-param>
    <context-param>
        <param-name>org.icefaces.mandatoryResourceConfiguration</param-name>
        <param-value>dataTable richTextEntry fileEntry</param-value>
    </context-param>
    <!-- Although the FacesServlet will not be invoked by any portlet requests, it is required to initialize JSF. -->
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/icefaces/*</url-pattern> 
    </servlet-mapping>
    <servlet>
        <servlet-name>Resource Servlet</servlet-name>
        <servlet-class>com.icesoft.faces.webapp.CompatResourceServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Resource Servlet</servlet-name>
        <url-pattern>/xmlhttp/*</url-pattern>
    </servlet-mapping>
    <resource-ref>
        <res-ref-name>mail/MailSession</res-ref-name>
        <res-type>javax.mail.Session</res-type>
        <res-auth>Container</res-auth>
    </resource-ref>
</web-app>

我的 face-config.xml 看起来像这样:

<?xml version="1.0" encoding="UTF-8"?>
<faces-config
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
    version="2.0">
        <application>
            <el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
        </application>
        <lifecycle>
            <phase-listener>com.liferay.faces.util.lifecycle.DebugPhaseListener</phase-listener>
            <phase-listener>com.liferay.faces.util.lifecycle.ViewScopePhaseListener</phase-listener>
        </lifecycle>
        <navigation-rule>
            <from-view-id>/views/*</from-view-id>
            <navigation-case>
                <from-outcome>warenkorb</from-outcome>
                <to-view-id>/views/warenkorb.xhtml</to-view-id>
            </navigation-case>
            <navigation-case>
                <from-outcome>checkout</from-outcome>
                <to-view-id>/views/bestellprozess.xhtml</to-view-id>
            </navigation-case>
            <navigation-case>
                <from-outcome>bestelluebersicht</from-outcome>
                <to-view-id>/views/bestelluebersicht.xhtml</to-view-id>
            </navigation-case>
            <navigation-case>
                <to-view-id>/views/index.xhtml</to-view-id>
            </navigation-case>
        </navigation-rule>
        <navigation-rule>
            <from-view-id>/adminviews/*</from-view-id>
            <navigation-case>
                <from-outcome>neueKategorie</from-outcome>
                <to-view-id>/adminviews/neueKategorie.xhtml</to-view-id>
            </navigation-case>
            <navigation-case>
                <from-outcome>verwaltungKategorie</from-outcome>
                <to-view-id>/adminviews/verwaltungKategorie.xhtml</to-view-id>
            </navigation-case>
            <navigation-case>
                <from-outcome>neuerArtikel</from-outcome>
                <to-view-id>/adminviews/neuerArtikel.xhtml</to-view-id>
            </navigation-case>
            <navigation-case>
                <from-outcome>absenderMail</from-outcome>
                <to-view-id>/adminviews/absenderMail.xhtml</to-view-id>
            </navigation-case>
            <navigation-case>
                <from-outcome>bestaetigungsMail</from-outcome>
                <to-view-id>/adminviews/bestaetigungsMail.xhtml</to-view-id>
            </navigation-case>
            <navigation-case>
                <to-view-id>/adminviews/index.xhtml</to-view-id>
            </navigation-case>
        </navigation-rule>
</faces-config>

ace:fileEntry 所在的 viewpage.xhtml 如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html   xmlns="http://www.w3.org/1999/xhtml"
        xmlns:ace="http://www.icefaces.org/icefaces/components"
        xmlns:ice="http://www.icesoft.com/icefaces/component"
        xmlns:f="http://java.sun.com/jsf/core"
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:ui="http://java.sun.com/jsf/facelets">
    <h:body>
        <ui:composition template="/adminviews/index.xhtml">
            <ui:define name="content">
                <ace:panel header="Neuen Artikel anlegen">
                    <ice:form>
                        <ace:textEntry  id="artikelnr"
                                    label="Artikelnummer:"
                                    labelPosition="left"
                                    required="true"
                                    requiredMessage="required"
                                    value="#{addingBean.newArtikel.artikelnummer}">
                        </ace:textEntry>
                        <br />
                        <ace:textEntry  id="bezeichnung"
                                    label="Bezeichnung:"
                                    labelPosition="left"
                                    required="true"
                                    requiredMessage="required"
                                    value="#{addingBean.newArtikel.bezeichnung}">
                        </ace:textEntry>
                        <br />
                        <ace:textEntry  id="preis"
                                    label="Einzelpreis (netto):"
                                    labelPosition="left"
                                    required="true"
                                    requiredMessage="required"
                                    value="#{addingBean.newArtikel.preis1}">
                        </ace:textEntry>
                        <br />
                        <ace:textEntry  id="bestand"
                                    label="Bestand:"
                                    labelPosition="left"
                                    required="true"
                                    requiredMessage="required"
                                    value="#{addingBean.newArtikel.bestand}">
                        </ace:textEntry>
                        <br />
                        <ace:textAreaEntry  id="beschreibung"
                                    label="Beschreibung:"
                                    labelPosition="left"
                                    value="#{addingBean.newArtikel.beschreibung}">
                        </ace:textAreaEntry>
                        <br />
                        <ace:simpleSelectOneMenu label="Steuerschlüssel:"
                                                labelPosition="left"
                                                value="#{addingBean.steuerId}"
                                                required="true">
                            <f:selectItem itemValue="" itemLabel="bitte auswählen ..." />
                            <f:selectItems value="#{requestBean.allSteuerItems}"/>
                        </ace:simpleSelectOneMenu>
                        <br />
                        <ace:simpleSelectOneMenu label="Kategorie:"
                                                labelPosition="left"
                                                value="#{addingBean.kategorieId}">
                            <f:selectItem itemValue="null" itemLabel="keine Kategorie" />
                            <f:selectItems value="#{requestBean.allKategorieItems}" />
                        </ace:simpleSelectOneMenu>
                        <br />
                        <ice:commandButton value="Speichern"
                                    actionListener="#{addingBean.addArtikel}"
                                    action="default"/>
                    </ice:form>
                    <ice:form>
                        <ice:commandButton value="Abbrechen"
                                            action="default"/>
                    </ice:form>
                    <h:form id="bildupload">
                        <ace:fileEntry id="bild"
                                    label="Bildupload"
                                    fileEntryListener="#{addingBean.bildListener}"
                                    maxFileCount="1"
                                    relativePath="/images/"/>
                        <h:commandButton value="Upload"/>
                    </h:form>
                    <ace:messages/>
                </ace:panel>
            </ui:define>
        </ui:composition>
    </h:body>
</html>

你们中有人知道如何解决问题或为什么会发生这种情况吗?

4

1 回答 1

3

Liferay Faces 团队已经在我们的一个测试环境中看到了这种情况,解决方法是从项目中排除 icepush.jar 依赖项:

<dependency>
    <groupId>org.icefaces</groupId>
    <artifactId>icefaces</artifactId>
    <version>3.3.0</version>
    <exclusions>
        <exclusion>
            <groupId>org.icepush</groupId>
            <artifactId>icepush</artifactId>
        </exclusion>
    </exclusions>
</dependency>
于 2013-09-09T20:17:12.623 回答