1

将 OmniFaces maven 依赖项添加到现有工作项目时遇到异常:

[2016-06-28T17:19:09.280+0200] [Payara Micro 4.1] [SEVERE] [AS-WEB-CORE-00037] [javax.enterprise.web.core] [tid: _ThreadID=17 _ThreadName=http-listener(7)] [timeMillis: 1467127149280] [levelValue: 1000] [[An exception or error occurred in the container during the request processing
java.lang.ClassCastException: cannot assign instance of java.lang.String to field org.primefaces.model.LazyDataModel.data of type java.util.List in instance of org.primefaces.showcase.view.data.datatable.LazyCarDataModel
    at java.io.ObjectStreamClass$FieldReflector.setObjFieldValues(ObjectStreamClass.java:2083)
    at java.io.ObjectStreamClass.setObjFieldValues(ObjectStreamClass.java:1261)
    at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1995)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1913)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1796)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1348)
    at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1989)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1913)    
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1796)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1348)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:370)
    at java.util.HashMap.readObject(HashMap.java:1155)
    at sun.reflect.GeneratedMethodAccessor48.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1017)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1891)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1796)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1348)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:370)
    at java.util.HashMap.readObject(HashMap.java:1155)
    at sun.reflect.GeneratedMethodAccessor48.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1017)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1891)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1796)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1348)
    at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1989)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1913)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1796)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1348)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:370)
    at org.apache.catalina.session.StandardSession.readRemainingObject(StandardSession.java:2079)
    at org.apache.catalina.session.StandardSession.readObject(StandardSession.java:1987)
    at sun.reflect.GeneratedMethodAccessor49.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1017)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1891)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1796)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1348)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:370)
    at org.apache.catalina.session.StandardSession.deserialize(StandardSession.java:1274)
    at org.apache.catalina.session.StoreBase.readSession(StoreBase.java:296)
    at org.glassfish.web.ha.session.management.ReplicationStore.getSession(ReplicationStore.java:567)
    at org.glassfish.web.ha.session.management.ReplicationStore.getSession(ReplicationStore.java:519)
    at org.glassfish.web.ha.session.management.ReplicationStore.loadFromBackingStore(ReplicationStore.java:433)
    at org.glassfish.web.ha.session.management.ReplicationStore.load(ReplicationStore.java:416)
    at org.apache.catalina.session.PersistentManagerBase.doSwapIn(PersistentManagerBase.java:1215)
    at org.apache.catalina.session.PersistentManagerBase.swapIn(PersistentManagerBase.java:1175)
    at org.glassfish.web.ha.session.management.ReplicationManagerBase.findSession(ReplicationManagerBase.java:161)
    at org.apache.catalina.connector.Request.isRequestedSessionIdValid(Request.java:2996)
    at org.apache.catalina.connector.Request.parseSessionCookiesId(Request.java:4113)
    at org.apache.catalina.connector.CoyoteAdapter.postParseRequest(CoyoteAdapter.java:672)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:354)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:283)
    at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
    at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
    at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
    at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
    at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
    at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
    at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:526)
    at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571)
    at java.lang.Thread.run(Thread.java:724)
]]

我可以使用 PrimeFaces 6.0 Showcase 重现异常,因此看起来原因不在我的代码中。

这是如何使用 PrimeFaces 展示重现:

  1. 从 github下载PrimeFaces 6.0 展示源。

  2. 将 OnmiFaces 依赖项添加到pom.xml

    <dependency>
        <groupId>org.omnifaces</groupId>
        <artifactId>omnifaces</artifactId>
        <version>2.3</version>
    </dependency>
    
  3. 将用于创建 Payara Micro Uber Jar 的 Maven 代码从http://blog.payara.fish/creating-uber-jar-with-payara-micro添加到pom.xml

  4. 构建,mvn package然后开始java -jar showcase-6.0.jar

  5. 现在在 localhost 上启动展示并打开 DataTable Lazy Loading 示例,您应该会得到异常。

移除 OmniFaces 依赖项后,不会发生异常。它不会发生在 Payara Application Server 上,而仅发生在 Payara Micro 上。

所以我不确定错误是否出现在 OmniFaces、Payara Micro、PrimeFaces 或其他任何地方。

4

1 回答 1

2

此行为是由添加到 OmniFaces 2.1 以支持在集群上运行的<distributable>标志引起的。

这反过来又发现了 PrimeFaces 6.0、PrimeFaces 展示应用程序和 Payara Micro 中的一些错误。

  • PrimeFaces 6.0 新PhaseInfo类 implements Serializable,但有一个PhaseId根本没有的属性Serializable
  • 在 PrimeFaces 展示中,有几个Serializable视图范围的 bean 具有不可序列化的服务属性,例如CarServiceLazyView惰性数据表演示页面后面的支持 bean。
  • Payara Micro 似乎没有考虑 WAR 自己web.xml是否<distributable>设置了标志。如果未设置此标志,则容器不应假定 WAR 是可分发的。

当您完全删除 OmniFaces,但在 PrimeFaces 展示中设置<distributable>标志时,PrimeFaces 6.0 和 PrimeFaces 展示的相同序列化问题是可重现web.xml的。这些问题中的每一个都需要单独报告。我至少已将PhaseInfo此事报告为问题 1570 ,并在您的 Payara Micro 问题上发表了评论。

在一个稍微相关的说明中,我还注意到 PrimeFaces 展示web.xml已将 Mojarra-specific 设置 com.sun.faces.serializeServerStatefalse. 我没有调查设置回 时的效果true,但不建议使用此设置,false因为可能会隐藏与视图构建和状态管理相关的其他错误。

于 2016-07-02T09:07:04.970 回答