群集上的CDI Bean序列化问题 [英] CDI Beans Serialization issue on Cluster

查看:74
本文介绍了群集上的CDI Bean序列化问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试以独立集群模式在Wildfly 9.2(也尝试10.0)上运行EJB + CDI + JSF应用程序时,我遇到了一个大问题。



当我的集群容器尝试反序列化会话范围的CDI Bean时,会发生此问题,它会引发以下异常:

  2016-02 -06 02:17:22,650错误[io.undertow.request](默认任务9)UT005071:Undertow请求失败HttpServerExchange {GET /login.xhtml request {Accept = [text / html,application / xhtml + xml,application / xml; q = 0.9,image / webp,* / *; q = 0.8],Accept-Language = [en-US,en; q = 0.8],Cache-Control = [max-age = 0],Accept-Encoding = [gzip,deflate,sdch],User-Agent = [Mozilla / 5.0(Windows NT 6.3; WOW64)AppleWebKit / 537.36(KHTML,例如Gecko)Chrome / 48.0.2564.97 Safari / 537.36],连接= [保持活动状态] ,Cookie = [__ utma = 111872281.273659443.1454265274.1454265274.1454265274.1; __utmz = 111872281.1454265274.1.1.utmcsr =(直接)| utmccn =(直接)| utmcmd =(无); JSESSIONID = oiC7sg_tinxBz6BWghg5PQ2urzCMw4Kh5oPqPRqU.ahmed-pc],Upgrade-Insecure-Requests = [1],Host = [localhost:8180]}响应{Connection = [keep-alive],Content-Type = [text / html; charset = UTF- 8],Content-Length = [12371],Date = [Fri,2016年2月5日23:17:22 GMT]}}:org.jboss.weld.exceptions.IllegalStateException:WELD-001122:无法反序列化使用标识的带注释类型AnnotatedTypeIdentifier [contextId = EAR-1.0.0.ear,bdaId = / C:/ Web服务器/wildfly-10.0.0.Final/standalone/deployments/EAR-1.0.0.ear/MySystemView-1.0.0.war/WEB -INF / lib / MySystemController-1.0.0.jar,className = com.sh.controller.MySystemController,后缀= null,修改= false] 
,位于org.jboss.weld.annotated.slim.SlimAnnotatedType $ SerializationProxy。 readResolve(SlimAnnotatedType.java:60)
在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)
在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
在sun。反映。DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java: 43)java.lang.reflect.Method.invoke(Method.java:497)的
org.jboss.marshalling.reflect.SerializableClass.callReadResolve(SerializableClass.java:413)的
在org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshalls.java:276)
at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1286)
.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:224)
在org.jboss.marshalling.river.RiverUnmarshaller.readFields(RiverUnmarshaller.java:1745)
在org.jboss。 .RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1658)
在org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1606)
在org.jbosRead。 (RiverUnmarshaller.java:1285)
在org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:276)
在org.jboss.marshalling.river.RiverUnmarshaller.doRe adObject(RiverUnmarshaller.java:224)
在org.jboss.marshalling.river.RiverUnmarshaller.readFields(RiverUnmarshaller.java:1745)
在org.jboss.marshalling.river.RiverUnmarshaller.doInit java:1658)org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1285)
org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller。
在org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:224)
在org.jboss.marshalling.river.RiverUnmarshaller.readFields(RiverUnmarshaller.java:1745)b在org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.j $ bbo)上org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarsshaller.j $ bbo)在org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1658)
.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:276)
在org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.jav a:224)org.jboss.marshalling.river.RiverUnmarshaller.readFields(RiverUnmarshaller.java:1745)
org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshall658)的
在org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1606)处的
在org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(River $ marbhallb。在org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:224)
在org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:276)
.marshalling.river.RiverUnmarshaller.readFields(RiverUnmarshaller.java:1745)
在org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshallersjavas:1658)
在org.j. .RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1285)
在org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:276)
在org.jbos s.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:224)
在org.jboss.marshalling.river.RiverUnmarshaller.readFields(RiverUnmarshaller.java:1745)
在org.jbos river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1658)
在org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1285)
在org.jboss.mars doReadObject(RiverUnmarshaller.java:276)
在org.jboss.marshalling.river.BlockUnmarshaller.readObject(BlockUnmarshaller.java:149)
在org.jboss.marshalling.river.BlockUnmarshaller.readObject(BlockUnmarshaller.java:149)
java:135)org.jboss.marshalling.MarshallerObjectInputStream.readObjectOverride(MarshallerObjectInputStream.java:53)
org.jboss.marshalling.river.RiverObjectInputStream.readObjectOverride(RiverObjectInputStream.java:307)
$ b在java.io.ObjectInputStream.readObject(ObjectInputStream.java:365)
在java.util.HashMap.readObject(HashMap.ja va:1396)sun.reflect.GeneratedMethodAccessor63.invoke(未知源)
在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
在java.lang.reflect。 org.jboss.marshalling.reflect.SerializableClass.callReadObject(SerializableClass.java:307)的Method.invoke(Method.java:497)
org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable( RiverUnmarshaller.java:1637)在org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1285)处
在org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:1285)
276)org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:209)
org.jboss.marshalling.AbstractObjectInput.readObject(AbstractObjectInput.java:41)
在org.wildfly.clustering.marshalling.jboss.SimpleMarshalledValue.get(SimpleMarshalledValue.java:101)处
在org.wildfly.clustering.marshalling.jboss.SimpleMarshalledValue.get(SimpleMars mustedValue.java:44)org.wildfly.clustering.marshalling.jboss.MarshalledValueMarshaller.read(MarshalledValueMarshaller.java:45)
,在org.wildfly.clustering.marshalling.jboss.MarshalledValueMarshaller MarshalledValueMarshaller.java:32)在org.wildfly.clustering.web.infinispan.session.coarse.CoarseSessionAttributesFactory.findValue(CoarseSessionAttributesFactory.java:84)
在org.wildfly.clustering.web.infinispan处session.coarse.CoarseSessionAttributesFactory.findValue(CoarseSessionAttributesFactory.java:48)在org.wildfly.clustering.web.infinispan.session.InfinispanSessionFactory.findValue(InfinispanSessionFactory.java:63)
在org.wildfly。 clustering.web.infinispan.session.InfinispanSessionFactory.findValue(InfinispanSessionFactory.java:40)
在org.wildfly.clustering.web.infinispan.session.InfinispanSessionManager.findSession(InfinispanSessionManager.java:234)
org.wildfly.clustering.web.undertow.session.DistributableSessionManager.getSession(D istributableSessionManager.java:140)io.undertow.servlet.spec.ServletContextImpl.getSession(ServletContextImpl.java:726)
io.undertow.servlet.spec.ServletContextImpl.getSession(ServletContextImpl.java:
756)io.undertow.servlet.spec.ServletContextImpl.updateSessionAccessTime(ServletContextImpl.java:760)
io.undertow.servlet.spec.HttpServletResponseImpl.responseDone(HttpServletResponseImpl.java:557)
$ b在io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:331)
在io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:263)
在io .undertow.servlet.handlers.ServletInitialHandler.access $ 000(ServletInitialHandler.java:81)
在io.undertow.servlet.handlers.ServletInitialHandler $ 1.handleRequest(ServletInitialHandler.java:174)
在io.undertow .server.Connectors.executeRootHandler(Connectors.java:202)
在io.undertow.server.HttpServerExchange $ 1.run(HttpServerExcha nge.java:793)java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)中的
java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617)中的

在java.lang.Thread.run(Thread.java:745)
原因:发生的异常:
在org.jboss.weld.annotated.slim.SlimAnnotatedType类型的对象中字段类型为org.jboss.weld.annotated.slim.backed.BackedAnnotatedField $ SerializationProxy
的字段类型为
的字段类型为org.jboss类型的对象中的$ SerializationProxy
.weld.injection.attributes.InferringFieldInjectionPointAttributes字段属性
在类型org.jboss.weld.injection.FieldInjectionPoint中的
在字段注入中
在字段org.jboss类型中的对象字段事件中的.weld.event.EventImpl $ SerializationProxy
com.sh.controller.MySystemController类型的对象中的
字段实例org.jboss.weld中的对象
中的
.context.SerializableContextualInstanceImpl
在对象中类型为java.util.HashMap的ct

我在stackoverflow上发现了这个问题,并提到我不应将我的CDI注入的bean标记为瞬态以跳过序列化,所以问题出在哪里?我需要瞬变注入的豆吗?



类源代码超过2500行,我在这里处理类运算符:

  @Named( sysControl)
@SessionScoped
公共类MySystemController扩展了VenusAbstractBean实现

BundleFiles,Serializable {
private静态最终长serialVersionUID = 9021710761540108681L;

私人机票;
私有Logger日志= LoggerFactory.getLogger(this.getClass());
私人TicketData数据;
@Inject
私人瞬态票务主题;
@Inject
私有TicketListController ticketListCont;
@EJB
私有SMSHandler smsHandler;
@EJB
私有TypeFacade typeFacade;
@EJB
private UsersFacade usersFacade;
@EJB
private StatusFacade statusFacade;
@EJB
私有TicketFacade ticketFacade;
@EJB
private AttachmentsFacade attachementFacade;
@EJB
私有SourceChannelFacade sourceFacade;
@EJB
私有TicketDataFacade dataFacade;
@EJB
私有LockFacade lockFacade;
@EJB
private UsersAssignedTicketsFacade ticketAssignFacade;
@EJB
私有TicketHistoryFacade historyFacade;
@EJB
private UsersAssignedTicketsFacadesignedFacade;
@EJB
私有EmailHandler emailHandlerFacade;
@EJB
private GlobalConfigurationFacade globalConfigFacade;
@EJB
private EscalationHistoryFacade escalationHistoryFacade;
@EJB
私人EmailMessageFacade emailMessageFacade;
@EJB
私有TicketDataFacade ticketDataFacade;
@EJB
私有CalendarFacade calFacade;
@EJB
私人EmailHistoryFacade emailHistoryFacade;
private boolean enableLastReplyEdit = false;
MainCategory私人猫;
私人SubCategory子项目;
私人主题主题;
个人TicketHistory历史记录;
个私有字节[]附件;
private List< String> uploadFile;
私人字符串回复;
private String reassignNote;
private Lock myLock;
个私人状态;
private String mimeType;
private boolean enableReopen;
私人TicketData selectedData;
私人Long lockSeconds;
私有布尔值可以重新打开;
私人列表< Integer> reopenStatusList;

个私人用户selectedUser;
private String changeDeptCaller;
private Integer viewMode;
private boolean printContent;
private boolean printReplies;
private boolean printEscalation;
私人列表<附件>附件列表;
私人列表<附件> uploadAttachementsList ;;
private boolean displayTimeoutMessage;
私人列表< Ticketactions>行动;
个私有Ticketactions selectedAction;
私人TicketHoldReason holdReason;
私有布尔值跳过;
private int Assign_changeDept;
私有布尔值canSetOnHold;
private boolean lockRequired;
私人清单< Ticket> selectedTickets;
私有布尔editLastRowMode;
私人List< TicketData> ticketDataList;

@Inject
私人事件< TicketEvent>事件;
@EJB
私有TicketEventObserver侦听器;

@EJB
私有SLATimeCalculator slaCalc;
@EJB
私有SlaFacade slaFacade;

@EJB
私人EJBUtils ejbUtils;
私人日期到期日期;

私人Long DueDateRemainingSec;
}

TicketEvent类

  import java.util.EventObject; 

import com.sh.entity.Ticket;

公共类TicketEvent扩展了EventObject {

private static final long serialVersionUID = 1L;
张私人机票;
个私有Object []值;

public TicketEvent(对象源,票证,对象...值){
super(source);
this.ticket =票;
this.values =值;
}

公开票getTicket(){
来回票;
}

public void setTicket(Ticket ticket){
this.ticket = ticket;
}

public Object [] getValues(){
返回值;
}

public void setValues(Object [] values){
this.values = values;
}

}


解决方案

基本上,您可以执行以下操作:




  • 使您的bean实现可序列化


  • 向没有实现<$的类成员添加 transient 修饰符c $ c>可序列化。







AFAIK,从Java EE 6开始,在注入CDI托管bean时,可以使用 @Inject 代替 @EJB 。 / p>

I'm facing a big issue when I tried to run my EJB+CDI+JSF application on Wildfly 9.2 (Also I tried 10.0) on Standalone Clustered mode.

The issue happens when my cluster container tries to deserialize my session scoped CDI beans, it throws the following exception :

2016-02-06 02:17:22,650 ERROR [io.undertow.request] (default task-9) UT005071: Undertow request failed HttpServerExchange{ GET /login.xhtml request {Accept=[text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8], Accept-Language=[en-US,en;q=0.8], Cache-Control=[max-age=0], Accept-Encoding=[gzip, deflate, sdch], User-Agent=[Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.97 Safari/537.36], Connection=[keep-alive], Cookie=[__utma=111872281.273659443.1454265274.1454265274.1454265274.1; __utmz=111872281.1454265274.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); JSESSIONID=oiC7sg_tinxBz6BWghg5PQ2urzCMw4Kh5oPqPRqU.ahmed-pc], Upgrade-Insecure-Requests=[1], Host=[localhost:8180]} response {Connection=[keep-alive], Content-Type=[text/html;charset=UTF-8], Content-Length=[12371], Date=[Fri, 05 Feb 2016 23:17:22 GMT]}}: org.jboss.weld.exceptions.IllegalStateException: WELD-001122: Failed to deserialize annotated type identified with AnnotatedTypeIdentifier [contextId=EAR-1.0.0.ear, bdaId=/C:/Web Server/wildfly-10.0.0.Final/standalone/deployments/EAR-1.0.0.ear/MySystemView-1.0.0.war/WEB-INF/lib/MySystemController-1.0.0.jar, className=com.sh.controller.MySystemController, suffix=null, modified=false]
at org.jboss.weld.annotated.slim.SlimAnnotatedType$SerializationProxy.readResolve(SlimAnnotatedType.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.jboss.marshalling.reflect.SerializableClass.callReadResolve(SerializableClass.java:413)
at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1286)
at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:276)
at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:224)
at org.jboss.marshalling.river.RiverUnmarshaller.readFields(RiverUnmarshaller.java:1745)
at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1658)
at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1606)
at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1285)
at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:276)
at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:224)
at org.jboss.marshalling.river.RiverUnmarshaller.readFields(RiverUnmarshaller.java:1745)
at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1658)
at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1285)
at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:276)
at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:224)
at org.jboss.marshalling.river.RiverUnmarshaller.readFields(RiverUnmarshaller.java:1745)
at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1658)
at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1285)
at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:276)
at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:224)
at org.jboss.marshalling.river.RiverUnmarshaller.readFields(RiverUnmarshaller.java:1745)
at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1658)
at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1606)
at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1285)
at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:276)
at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:224)
at org.jboss.marshalling.river.RiverUnmarshaller.readFields(RiverUnmarshaller.java:1745)
at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1658)
at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1285)
at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:276)
at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:224)
at org.jboss.marshalling.river.RiverUnmarshaller.readFields(RiverUnmarshaller.java:1745)
at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1658)
at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1285)
at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:276)
at org.jboss.marshalling.river.BlockUnmarshaller.readObject(BlockUnmarshaller.java:149)
at org.jboss.marshalling.river.BlockUnmarshaller.readObject(BlockUnmarshaller.java:135)
at org.jboss.marshalling.MarshallerObjectInputStream.readObjectOverride(MarshallerObjectInputStream.java:53)
at org.jboss.marshalling.river.RiverObjectInputStream.readObjectOverride(RiverObjectInputStream.java:307)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:365)
at java.util.HashMap.readObject(HashMap.java:1396)
at sun.reflect.GeneratedMethodAccessor63.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.jboss.marshalling.reflect.SerializableClass.callReadObject(SerializableClass.java:307)
at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1637)
at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1285)
at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:276)
at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:209)
at org.jboss.marshalling.AbstractObjectInput.readObject(AbstractObjectInput.java:41)
at org.wildfly.clustering.marshalling.jboss.SimpleMarshalledValue.get(SimpleMarshalledValue.java:101)
at org.wildfly.clustering.marshalling.jboss.SimpleMarshalledValue.get(SimpleMarshalledValue.java:44)
at org.wildfly.clustering.marshalling.jboss.MarshalledValueMarshaller.read(MarshalledValueMarshaller.java:45)
at org.wildfly.clustering.marshalling.jboss.MarshalledValueMarshaller.read(MarshalledValueMarshaller.java:32)
at org.wildfly.clustering.web.infinispan.session.coarse.CoarseSessionAttributesFactory.findValue(CoarseSessionAttributesFactory.java:84)
at org.wildfly.clustering.web.infinispan.session.coarse.CoarseSessionAttributesFactory.findValue(CoarseSessionAttributesFactory.java:48)
at org.wildfly.clustering.web.infinispan.session.InfinispanSessionFactory.findValue(InfinispanSessionFactory.java:63)
at org.wildfly.clustering.web.infinispan.session.InfinispanSessionFactory.findValue(InfinispanSessionFactory.java:40)
at org.wildfly.clustering.web.infinispan.session.InfinispanSessionManager.findSession(InfinispanSessionManager.java:234)
at org.wildfly.clustering.web.undertow.session.DistributableSessionManager.getSession(DistributableSessionManager.java:140)
at io.undertow.servlet.spec.ServletContextImpl.getSession(ServletContextImpl.java:726)
at io.undertow.servlet.spec.ServletContextImpl.getSession(ServletContextImpl.java:756)
at io.undertow.servlet.spec.ServletContextImpl.updateSessionAccessTime(ServletContextImpl.java:760)
at io.undertow.servlet.spec.HttpServletResponseImpl.responseDone(HttpServletResponseImpl.java:557)
at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:331)
at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:263)
at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:174)
at io.undertow.server.Connectors.executeRootHandler(Connectors.java:202)
at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:793)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: an exception which occurred:
in object of type org.jboss.weld.annotated.slim.SlimAnnotatedType$SerializationProxy
in field type
in object of type org.jboss.weld.annotated.slim.backed.BackedAnnotatedField$SerializationProxy
in field field
in object of type org.jboss.weld.injection.attributes.InferringFieldInjectionPointAttributes
in field attributes
in object of type org.jboss.weld.injection.FieldInjectionPoint
in field injectionPoint
in object of type org.jboss.weld.event.EventImpl$SerializationProxy
in field events
in object of type com.sh.controller.MySystemController
in field instance
in object of type org.jboss.weld.context.SerializableContextualInstanceImpl
in object of type java.util.HashMap

I have found this question here on stackoverflow and it mentioned that I shouldn't mark my CDI injected beans as transient to skip serialization, so where is the problem ?? do I need to transient the Injected beans ?

The class source code is more than 2500 Lines of code, I'm coping here the class operators:

@Named("sysControl")
@SessionScoped
public class MySystemController extends VenusAbstractBean implements 

BundleFiles,Serializable {
    private static final long serialVersionUID = 9021710761540108681L;

    private Ticket ticket;
    private Logger log = LoggerFactory.getLogger(this.getClass());
    private TicketData data;
    @Inject
    private transient TicketingSubject subject;
    @Inject
    private TicketListController ticketListCont;
    @EJB
    private SMSHandler smsHandler;
    @EJB
    private TypeFacade typeFacade;
    @EJB
    private UsersFacade usersFacade;
    @EJB
    private StatusFacade statusFacade;
    @EJB
    private TicketFacade ticketFacade;
    @EJB
    private AttachmentsFacade attachementFacade;
    @EJB
    private SourceChannelFacade sourceFacade;
    @EJB
    private TicketDataFacade dataFacade;
    @EJB
    private LockFacade lockFacade;
    @EJB
    private UsersAssignedTicketsFacade ticketAssignFacade;
    @EJB
    private TicketHistoryFacade historyFacade;
    @EJB
    private UsersAssignedTicketsFacade assignedFacade;
    @EJB
    private EmailHandler emailHandlerFacade;
    @EJB
    private GlobalConfigurationFacade globalConfigFacade;
    @EJB
    private EscalationHistoryFacade escalationHistoryFacade;
    @EJB
    private EmailMessageFacade emailMessageFacade;
    @EJB
    private TicketDataFacade ticketDataFacade;
    @EJB
    private CalendarFacade calFacade;
    @EJB
    private EmailHistoryFacade emailHistoryFacade;
    private boolean enableLastReplyEdit = false;
    private MainCategory cat;
    private SubCategory sub;
    private Topic topic;
    private TicketHistory history;
    private byte[] attachment;
    private List<String> uploadedFile;
    private String reply;
    private String reassignNote;
    private Lock myLock;
    private Status status;
    private String mimeType;
    private boolean enableReopen;
    private TicketData selectedData;
    private Long lockSeconds;
    private boolean canbeReopened;
    private List<Integer> reopenStatusList;

    private Users selectedUser;
    private String changeDeptCaller;
    private Integer viewMode;
    private boolean printContent;
    private boolean printReplies;
    private boolean printEscalation;
    private List<Attachments> attachmentsList;
    private List<Attachments> uploadAttachementsList;;
    private boolean displayTimeoutMessage;
    private List<Ticketactions> actions;
    private Ticketactions selectedAction;
    private TicketHoldReason holdReason;
    private boolean skip;
    private int assign_changeDept;
    private boolean canSetOnHold;
    private boolean lockRequired;
    private List<Ticket> selectedTickets;
    private boolean editLastRowMode;
    private List<TicketData> ticketDataList;

    @Inject
    private Event<TicketEvent> events;
    @EJB
    private TicketEventObserver listener;

    @EJB
    private SLATimeCalculator slaCalc;
    @EJB
    private SlaFacade slaFacade;

    @EJB
    private EJBUtils ejbUtils;
    private Date dueDate;

    private Long dueDateRemainingSec;
    }

TicketEvent Class

import java.util.EventObject;

import com.sh.entity.Ticket;

public class TicketEvent extends EventObject {

    private static final long serialVersionUID = 1L;
    private Ticket ticket;
    private Object[] values;

    public TicketEvent(Object source, Ticket ticket, Object... values) {
        super(source);
        this.ticket = ticket;
        this.values = values;
    }

    public Ticket getTicket() {
        return ticket;
    }

    public void setTicket(Ticket ticket) {
        this.ticket = ticket;
    }

    public Object[] getValues() {
        return values;
    }

    public void setValues(Object[] values) {
        this.values = values;
    }

}

解决方案

Basically, you can do the following:

  • Make your beans implement Serializable.

  • Add the transient modifier to the class members that do not implement Serializable.


AFAIK, since Java EE 6, you can use @Inject instead of @EJB when injecting CDI managed beans.

这篇关于群集上的CDI Bean序列化问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆