Monday, November 4, 2013

Apache Wicket - The object type is not Serializable

One of the common exceptions in Wicket is the Serialization exception as Wicket maintains the page maps and serializes and deserialize the page components along with components :

One of the solutions to the problem would be to either make the object in question "transient"
or make its class implement "Serializable" interace.

In this case the object of "TestDataServiceImpl" class needs to be declared with transient modifier
or its class should implement the Serializable interface.

Stacktrace :

22:53:33,267 WARN  [org.apache.wicket.pageStore.DefaultPageStore] (http-localhost-127.0.0.1-8080-1) Page [Page class = com.testwebapp.web.TestPage, id = 1, render count = 1] cannot be serialized. See previous logs for possible reasons.
22:53:33,791 ERROR [org.apache.wicket.serialize.java.JavaSerializer] (http-localhost-127.0.0.1-8080-1) Error serializing object class com.testwebapp.web.TestPage [object=[Page class = com.testwebapp.web.TestPage, id = 1, render count = 1]]: org.apache.wicket.core.util.objects.checker.CheckingObjectOutputStream$ObjectCheckException: The object type is not Serializable!
A problem occurred while checking object with type: com.testwebapp.service.impl.TestDataServiceImpl
Field hierarchy is:
  1 [class=com.testwebapp.web.TestPage, path=1]
    private java.lang.Object org.apache.wicket.MarkupContainer.children [class=[Ljava.lang.Object;]
      private final org.apache.wicket.datetime.DateConverter org.apache.wicket.datetime.markup.html.form.DateTextField.converter[2] [class=com.testwebapp.web.panel.OpportunityDetailsPanel, path=1:opportunityDetailContainer]
        private java.lang.Object org.apache.wicket.MarkupContainer.children [class=[Ljava.lang.Object;]
          private java.lang.Object org.apache.wicket.MarkupContainer.children[0] [class=com.testwebapp.web.panel.TestDetailsPanel, path=1:opportunityDetailContainer:eventDetailPanel]
            private java.lang.Object org.apache.wicket.MarkupContainer.children [class=[Ljava.lang.Object;]
              java.lang.Object org.apache.wicket.Component.data[1] [class=com.testwebapp.web.panel.TestExportRawDataPanel, path=1:opportunityDetailContainer:eventDetailPanel:supRawDataContainer]
                com.testwebapp.service.impl.TestDataServiceImpl com.testwebapp.web.panel.TestExportRawDataPanel.TestDataService [class=com.testwebapp.service.impl.TestDataServiceImpl] <----- field that is causing the problem
    at org.apache.wicket.core.util.objects.checker.CheckingObjectOutputStream.internalCheck(CheckingObjectOutputStream.java:387) [wicket-core-6.10.0.jar:6.10.0]
        at org.apache.wicket.core.util.objects.checker.CheckingObjectOutputStream.writeObjectOverride(CheckingObjectOutputStream.java:713) [wicket-core-6.10.0.jar:6.10.0]
    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:325) [classes.jar:1.6.0_65]
    at org.apache.wicket.serialize.java.JavaSerializer$SerializationCheckerObjectOutputStream.writeObjectOverride(JavaSerializer.java:268) [wicket-core-6.10.0.jar:6.10.0]
    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:325) [classes.jar:1.6.0_65]
    at org.apache.wicket.serialize.java.JavaSerializer.serialize(JavaSerializer.java:78) [wicket-core-6.10.0.jar:6.10.0]
    at org.apache.wicket.pageStore.DefaultPageStore.serializePage(DefaultPageStore.java:376) [wicket-core-6.10.0.jar:6.10.0]
    at org.apache.wicket.pageStore.DefaultPageStore.storePage(DefaultPageStore.java:150) [wicket-core-6.10.0.jar:6.10.0]
    at org.apache.wicket.page.PageStoreManager$PersistentRequestAdapter.storeTouchedPages(PageStoreManager.java:410) [wicket-core-6.10.0.jar:6.10.0]
    at org.apache.wicket.page.RequestAdapter.commitRequest(RequestAdapter.java:181) [wicket-core-6.10.0.jar:6.10.0]
    at org.apache.wicket.page.AbstractPageManager.commitRequest(AbstractPageManager.java:98) [wicket-core-6.10.0.jar:6.10.0]
    at org.apache.wicket.page.PageManagerDecorator.commitRequest(PageManagerDecorator.java:73) [wicket-core-6.10.0.jar:6.10.0]
    at org.apache.wicket.page.PageAccessSynchronizer$2.commitRequest(PageAccessSynchronizer.java:281) [wicket-core-6.10.0.jar:6.10.0]
    at org.apache.wicket.Application$2.onDetach(Application.java:1628) [wicket-core-6.10.0.jar:6.10.0]
    at org.apache.wicket.request.cycle.RequestCycleListenerCollection$3.notify(RequestCycleListenerCollection.java:105) [wicket-core-6.10.0.jar:6.10.0]
    at org.apache.wicket.request.cycle.RequestCycleListenerCollection$3.notify(RequestCycleListenerCollection.java:101) [wicket-core-6.10.0.jar:6.10.0]
    at org.apache.wicket.util.listener.ListenerCollection$1.notify(ListenerCollection.java:120) [wicket-util-6.10.0.jar:6.10.0]
    at org.apache.wicket.util.listener.ListenerCollection.reversedNotify(ListenerCollection.java:144) [wicket-util-6.10.0.jar:6.10.0]
    at org.apache.wicket.util.listener.ListenerCollection.reversedNotifyIgnoringExceptions(ListenerCollection.java:113) [wicket-util-6.10.0.jar:6.10.0]
    at org.apache.wicket.request.cycle.RequestCycleListenerCollection.onDetach(RequestCycleListenerCollection.java:100) [wicket-core-6.10.0.jar:6.10.0]
    at org.apache.wicket.request.cycle.RequestCycle.onDetach(RequestCycle.java:640) [wicket-core-6.10.0.jar:6.10.0]
    at org.apache.wicket.request.cycle.RequestCycle.detach(RequestCycle.java:589) [wicket-core-6.10.0.jar:6.10.0]
    at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:293) [wicket-core-6.10.0.jar:6.10.0]
    at org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:259) [wicket-core-6.10.0.jar:6.10.0]
    at org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:201) [wicket-core-6.10.0.jar:6.10.0]
    at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:282) [wicket-core-6.10.0.jar:6.10.0]
        at java.lang.Thread.run(Thread.java:695) [classes.jar:1.6.0_65]
Caused by: java.io.NotSerializableException: com.testwebapp.service.impl.TestDataServiceImpl
     at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:329) [classes.jar:1.6.0_65]
    at org.apache.wicket.serialize.java.JavaSerializer$SerializationCheckerObjectOutputStream.writeObjectOverride(JavaSerializer.java:260) [wicket-core-6.10.0.jar:6.10.0]
    ... 35 more

22:53:33,832 WARN  [org.apache.wicket.pageStore.DefaultPageStore] (http-localhost-127.0.0.1-8080-1) Page [Page class = com.testwebapp.web.TestPage, id = 1, render count = 1] cannot be serialized. See previous logs for possible reasons.


No comments:

Post a Comment