在Payara Micro上组合Omnifaces和PrimeFaces LazyDataModel时出现异常

时间:2016-06-28 22:19:49

标签: jsf serialization primefaces omnifaces payara-micro

在将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重现Exception,因此看起来原因不在我的代码中。

这是使用PrimeFaces展示的再现方式:

  1. 从github下载PrimeFaces 6.0 showcase来源。

  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示例,你应该得到例外。

  6. 当删除OmniFaces依赖项时,不会发生此操作。它不会发生在Payara Application Server上,而只会发生在Payara Micro上。

    所以我不确定错误是在OmniFaces,Payara Micro,PrimeFaces还是在任何地方。

1 个答案:

答案 0 :(得分:2)

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

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

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

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

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