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

Stack Overflow | Alex Derksen | 5 months ago
  1. 0

    Exception when combining Omnifaces and PrimeFaces LazyDataModel on Payara Micro

    Stack Overflow | 5 months ago | Alex Derksen
    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
  2. 0

    Recently I switched from Mojarra 2.0.2 (SNAPSHOT 20100105) to Mojarra 2.1.0-b11 And started to get the following exceptions: java.io.NotSerializableException: javax.faces.component.UINamingContainer at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1164) at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1518) at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1483) at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1400) at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1158) at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1346) at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1154) at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1346) at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1154) at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1346) at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1154) at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1346) at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1154) at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1346) at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1154) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:330) at java.util.HashMap.writeObject(HashMap.java:1001) at sun.reflect.GeneratedMethodAccessor28.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:945) at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1469) at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1400) at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1158) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:330) at com.sun.faces.renderkit.ClientSideStateHelper.doWriteState(ClientSideStateHelper.java:325) at com.sun.faces.renderkit.ClientSideStateHelper.writeState(ClientSideStateHelper.java:173) at com.sun.faces.renderkit.ResponseStateManagerImpl.writeState(ResponseStateManagerImpl.java:122) at com.sun.faces.application.StateManagerImpl.writeState(StateManagerImpl.java:166) at com.sun.faces.application.view.WriteBehindStateWriter.flushToWriter(WriteBehindStateWriter.java:225) at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:418) at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131) at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:410) After some debugging I found that serialization brokes on ContextualCompositeMethodExpression which has 'cc' field which is not serializable. Probably this thing shouldn't get into state saving... I found that the issue is caused by using valueChangeListener (attribute) in a composite component: I have a page calling a component: <ui:composition template="/template.xhtml"> <ui:define name="body"> <gc:groupsTable belongsToManager="#{reportsEditBean.groupSetManager}" caption="Template Belongs To Groups" readOnly="#{reportsEditBean.readOnly}"/> </ui:define> </ui:composition> The offending part of the component is: <composite:interface name="groupsTable"> <composite:attribute name="belongsToManager" required="true" shortDescription="a controller" type="com.sun.aurora.web.AbstractBelongsToManager"/> <composite:attribute name="caption" required="false"/> <composite:attribute name="readOnly" default="false" required="false" type="Boolean"/> </composite:interface> <composite:implementation> <h:selectOneListbox value="#{cc.attrs.belongsToManager.groupToAdd}" valueChangeListener="#{cc.attrs.belongsToManager.groupToAddChangeListener}" immediate="true" hideNoSelectionOption="false" /> </composite:implementation> relevant part of the bean is: (I wanted to show the signatures) public abstract class AbstractBelongsToManager implements Serializable { private static final long serialVersionUID = 1L; private String groupToAdd = GROUP_TO_ADD_LABEL; private static final String GROUP_TO_ADD_LABEL = "- select -"; public String getGroupToAdd() { return groupToAdd; } public void groupToAddChangeListener(ValueChangeEvent valueChangeEvent) { ... } public void setGroupToAdd(String groupToAdd) { } } Actually, I looked at jsf-demo samples and haven't found any usages of valueChangeListener attribute.

    Java.net JIRA | 6 years ago | nzinoviev
    java.lang.ClassCastException: cannot assign instance of java.lang.String to field com.sun.faces.facelets.el.ContextualCompositeMethodExpression.cc of type javax.faces.component.UIComponent in instance of com.sun.faces.facelets.el.ContextualCompositeMethodExpression
  3. 0

    java.io.NotSerializableException: org.primefaces.component.datatable.DataTable after PrimeFaces is upgraded to 5.1

    Stack Overflow | 2 years ago
    java.lang.ClassCastException: cannot assign instance of java.lang.String to field org.primefaces.component.datatable.DataTable$MultiSortState.this$0 of type org.primefaces.component.datatable.DataTable in instance of org.primefaces.component.datatable.DataTable$MultiSortState
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    RequestContext via timer nullpointer exception

    Stack Overflow | 3 years ago | NoodleMage
    java.lang.ClassCastException: cannot assign instance of java.lang.String to field beans.IndexBean.timer of type java.util.Timer in instance of beans.IndexBean
  6. 0

    CJ's DW

    blogspot.com | 1 year ago
    java.lang.ClassCastException: cannot assign instance of java.lang.String to field cn.beans.UserSession.time of type java.util.Date in instance of cn.beans.UserSession

  1. bpbhat77 2 times, last 4 months ago
  2. shiva768 1 times, last 11 months ago
11 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. 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()
  2. Java RT
    ObjectInputStream.readObject
    1. java.io.ObjectStreamClass$FieldReflector.setObjFieldValues(ObjectStreamClass.java:2083)
    2. java.io.ObjectStreamClass.setObjFieldValues(ObjectStreamClass.java:1261)
    3. java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1995)
    4. java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1913)
    5. java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1796)
    6. java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1348)
    7. java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1989)
    8. java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1913)
    9. java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1796)
    10. java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1348)
    11. java.io.ObjectInputStream.readObject(ObjectInputStream.java:370)
    12. java.util.HashMap.readObject(HashMap.java:1155)
    13. sun.reflect.GeneratedMethodAccessor48.invoke(Unknown Source)
    14. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    15. java.lang.reflect.Method.invoke(Method.java:606)
    16. java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1017)
    17. java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1891)
    18. java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1796)
    19. java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1348)
    20. java.io.ObjectInputStream.readObject(ObjectInputStream.java:370)
    21. java.util.HashMap.readObject(HashMap.java:1155)
    22. sun.reflect.GeneratedMethodAccessor48.invoke(Unknown Source)
    23. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    24. java.lang.reflect.Method.invoke(Method.java:606)
    25. java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1017)
    26. java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1891)
    27. java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1796)
    28. java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1348)
    29. java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1989)
    30. java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1913)
    31. java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1796)
    32. java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1348)
    33. java.io.ObjectInputStream.readObject(ObjectInputStream.java:370)
    33 frames
  3. Glassfish Core
    StandardSession.readObject
    1. org.apache.catalina.session.StandardSession.readRemainingObject(StandardSession.java:2079)
    2. org.apache.catalina.session.StandardSession.readObject(StandardSession.java:1987)
    2 frames
  4. Java RT
    ObjectInputStream.readObject
    1. sun.reflect.GeneratedMethodAccessor49.invoke(Unknown Source)
    2. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    3. java.lang.reflect.Method.invoke(Method.java:606)
    4. java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1017)
    5. java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1891)
    6. java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1796)
    7. java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1348)
    8. java.io.ObjectInputStream.readObject(ObjectInputStream.java:370)
    8 frames
  5. Glassfish Core
    StoreBase.readSession
    1. org.apache.catalina.session.StandardSession.deserialize(StandardSession.java:1274)
    2. org.apache.catalina.session.StoreBase.readSession(StoreBase.java:296)
    2 frames
  6. Embedded GlassFish Web
    ReplicationStore.load
    1. org.glassfish.web.ha.session.management.ReplicationStore.getSession(ReplicationStore.java:567)
    2. org.glassfish.web.ha.session.management.ReplicationStore.getSession(ReplicationStore.java:519)
    3. org.glassfish.web.ha.session.management.ReplicationStore.loadFromBackingStore(ReplicationStore.java:433)
    4. org.glassfish.web.ha.session.management.ReplicationStore.load(ReplicationStore.java:416)
    4 frames
  7. Glassfish Core
    PersistentManagerBase.swapIn
    1. org.apache.catalina.session.PersistentManagerBase.doSwapIn(PersistentManagerBase.java:1215)
    2. org.apache.catalina.session.PersistentManagerBase.swapIn(PersistentManagerBase.java:1175)
    2 frames
  8. Embedded GlassFish Web
    ReplicationManagerBase.findSession
    1. org.glassfish.web.ha.session.management.ReplicationManagerBase.findSession(ReplicationManagerBase.java:161)
    1 frame
  9. Glassfish Core
    CoyoteAdapter.service
    1. org.apache.catalina.connector.Request.isRequestedSessionIdValid(Request.java:2996)
    2. org.apache.catalina.connector.Request.parseSessionCookiesId(Request.java:4113)
    3. org.apache.catalina.connector.CoyoteAdapter.postParseRequest(CoyoteAdapter.java:672)
    4. org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:354)
    5. org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:283)
    5 frames
  10. Kernel Classes
    ContainerMapper.service
    1. com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
    2. com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
    2 frames
  11. Grizzly Server
    HttpServerFilter.handleRead
    1. org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
    2. org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
    3. org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
    3 frames
  12. Grizzly
    AbstractThreadPool$Worker.run
    1. org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
    2. org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
    3. org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
    4. org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
    5. org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
    6. org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
    7. org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:526)
    8. org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
    9. org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
    10. org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
    11. org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
    12. org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591)
    13. org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571)
    13 frames
  13. Java RT
    Thread.run
    1. java.lang.Thread.run(Thread.java:724)
    1 frame