you are holding a reference to your database object directly.

wicket serializes sessions, so if you hold a reference you have to make sure
that object is serializable.

you have two options:

make the object serializable or keep it in some kind of detachable model,
since its a db object most likely a LoadableDetachableModel. there is a page
on the wiki that describes models.

-igor


On 4/18/07, galbu <[EMAIL PROTECTED]> wrote:


Hello world I'm a beginner and I have a problem with my first Wicket
Application:
I get from a database a list of objects "Ordine" and I have a "ViewOrdini"
page
that correctly show me the list; now I want check an "Ordine" from that
list
and
generate a "ViewDettaglioOrdini" page that must show me all the objects
"DettaglioOrdine"
contained in the db that are associated with the "Ordine" I checked
before.
When I try to generate this page where I have the details of the checked
"Ordine"
I get this error:

WicketMessage: Internal error cloning object. Make sure all dependent
objects implement Serializable.
Class: wicket.consapplication.ViewDettaglioOrdini

Root cause:

java.io.NotSerializableException:
wicket.services.AppService$$EnhancerByCGLIB$$b5498fd0
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1156)
at
java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java
:1509)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java
:1474)
at
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java
:1392)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
at
java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java
:1509)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java
:1474)
at
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java
:1392)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1338)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1146)
at
java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java
:1509)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java
:1474)
at
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java
:1392)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
at
wicket.protocol.http.HttpSessionStore.setAttribute(HttpSessionStore.java
:57)
at wicket.Session.setAttribute(Session.java:952)
at wicket.PageMap.put(PageMap.java:526)
at wicket.Session.touch(Session.java:744)
at wicket.Page.renderPage(Page.java:419)
at wicket.protocol.http.WebRequestCycle.redirectTo(WebRequestCycle.java
:160)
at
wicket.request.target.component.PageRequestTarget.respond(
PageRequestTarget.java:60)
at
wicket.request.compound.DefaultResponseStrategy.respond(
DefaultResponseStrategy.java:49)
at
wicket.request.compound.AbstractCompoundRequestCycleProcessor.respond(
AbstractCompoundRequestCycleProcessor.java:66)
at wicket.RequestCycle.doProcessEventsAndRespond(RequestCycle.java:902)
at wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:929)
at wicket.RequestCycle.step(RequestCycle.java:1010)
at wicket.RequestCycle.steps(RequestCycle.java:1084)
at wicket.RequestCycle.request(RequestCycle.java:454)
at wicket.protocol.http.WicketServlet.doGet(WicketServlet.java:219)
at wicket.protocol.http.WicketServlet.doPost(WicketServlet.java:262)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:358)
at
org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(
WebApplicationHandler.java:294)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java
:567)
at org.mortbay.http.HttpContext.handle(HttpContext.java:1807)
at
org.mortbay.jetty.servlet.WebApplicationContext.handle(
WebApplicationContext.java:525)
at org.mortbay.http.HttpContext.handle(HttpContext.java:1757)
at org.mortbay.http.HttpServer.service(HttpServer.java:879)
at org.mortbay.http.HttpConnection.service(HttpConnection.java:789)
at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:960)
at org.mortbay.http.HttpConnection.handle(HttpConnection.java:806)
at org.mortbay.http.SocketListener.handleConnection(SocketListener.java
:218)
at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:331)
at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:520)

Complete stack:

wicket.WicketRuntimeException: Internal error cloning object. Make sure
all
dependent objects implement Serializable. Class:
wicket.consapplication.ViewDettaglioOrdini
at
wicket.protocol.http.HttpSessionStore.setAttribute(HttpSessionStore.java
:63)
at wicket.Session.setAttribute(Session.java:952)
at wicket.PageMap.put(PageMap.java:526)
at wicket.Session.touch(Session.java:744)
at wicket.Page.renderPage(Page.java:419)
at wicket.protocol.http.WebRequestCycle.redirectTo(WebRequestCycle.java
:160)
at
wicket.request.target.component.PageRequestTarget.respond(
PageRequestTarget.java:60)
at
wicket.request.compound.DefaultResponseStrategy.respond(
DefaultResponseStrategy.java:49)
at
wicket.request.compound.AbstractCompoundRequestCycleProcessor.respond(
AbstractCompoundRequestCycleProcessor.java:66)
at wicket.RequestCycle.doProcessEventsAndRespond(RequestCycle.java:902)
at wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:929)
at wicket.RequestCycle.step(RequestCycle.java:1010)
at wicket.RequestCycle.steps(RequestCycle.java:1084)
at wicket.RequestCycle.request(RequestCycle.java:454)
at wicket.protocol.http.WicketServlet.doGet(WicketServlet.java:219)

Here you have the package structure of my application:
-wicket
  -common
    -auth.model
      -Group.class
      -User.class
    -model
      -Provincia.class
      -Stato.class
      -Indirizzo.class
      -Money.class
      -MoneyType.class
      -Macroregione.class
  -consapplication
    -...all wicket pages
  -consumi
    -dao
      -OrdineDAO.Interface
      -DettaglioOrdineDAO.Interface
      -...others
      -hibernate
        -OrdineHibernateDAO.Interface
        -DettaglioOrdineHibernateDAO.Interface
        -...others
    -loading
    -model
      -Ordine.class
      -DettaglioOrdine.class
      -....others
  -services
    -AppService.class

The AppService it's an utility class in which there are all DAO methods:

public class AppService {

        private AnagraficaProdottoDAO anagraficaProdottoDAO;
        private OrdineDAO ordineDAO;
        private DettaglioOrdineDAO dettaglioOrdineDAO;
        private ClasseCNDDAO classeCNDDAO;
        private EnteDAO enteDAO;
        private UserDAO userDAO;

        public void setUserDAO(UserDAO dao) {
                userDAO = dao;
        }

        public void setAnagraficaProdottoDAO(AnagraficaProdottoDAO dao) {
                anagraficaProdottoDAO = dao;
        }

        public void setOrdineDAO(OrdineDAO dao) {
                ordineDAO = dao;
        }

        public void setEnteDAO(EnteDAO dao) {
                enteDAO = dao;
        }

        public void setDettaglioOrdineDAO(DettaglioOrdineDAO dao) {
                dettaglioOrdineDAO = dao;
        }

        public void setClasseCNDDAO(ClasseCNDDAO dao) {
                classeCNDDAO = dao;
        }

        //methods
}

In wicket.consumi.model.* and in wicket.common.* I have my static classes
mapped
with Java Annotations.

Here there's the code of "ViewDettaglioOrdini" page:

public class ViewDettaglioOrdini extends  ConsumiTemplateMenuPage
implements
Serializable{

        private static final long serialVersionUID = 1L;
        private ConsumiSession session = (ConsumiSession)getSession();
        private Ordine ordine;

        public ViewDettaglioOrdini() {
                super();
                verifyAccess();
                final FeedbackPanel feedback = new
FeedbackPanel("feedback");
                add(feedback);

                /*
                 * recupero l'ordine precedentemente salvato nella
sessione
                 */
                this.ordine = session.getOrdine();

                final DettaglioOrdiniDataProvider dataProvider = new
DettaglioOrdiniDataProvider(ordine);
                final DataView dettagli = new
DettaglioOrdiniDataView("dettagliOrdini",dataProvider);

                //vincolo il numero di righe viste per pagina
                add(dettagli);
                dettagli.setItemsPerPage(5);
                add(new PagingNavigator("navigator",dettagli));
        }

        public String getPageTitle() {
                return "Visualizza Lista Dettagli Ordine";
        }

        class DettaglioOrdiniDataView extends DataView{

                private static final long serialVersionUID = 1L;
                public DettaglioOrdiniDataView(String id, IDataProvider
dataProvider) {
                        super(id, dataProvider);
                }

                protected void populateItem(final Item item) {
                        DettaglioOrdine dettaglioOrdine =
(DettaglioOrdine)
item.getModelObject();

                        String codiceOrdine = ordine.getCodiceOrdine();
                        String anagraficaProdotto =
dettaglioOrdine.getAnagraficaProdotto().getDescrizione();

                        item.setModel(new
CompoundPropertyModel(dettaglioOrdine));
                        item.add(new Label("id"));
                        item.add(new Label("fornitore"));
                        item.add(new Label("qtaOrdinato"));
                        item.add(new Label("valOrdinato"));
                        item.add(new Label("ordine",codiceOrdine));
                        item.add(new
Label("prodotto",anagraficaProdotto));
                }

                /*
                 * serve per creare gli item che modificano le features
dell'html
                 */
                protected Item newItem(final String id, int index, final
IModel model){
                        return new OddEvenItem(id, index, model);
                }
        }
}

I know it's difficult understand the context but any suggest to solve the
error
will be appreciate.
Thanks in advance !
--
View this message in context:
http://www.nabble.com/Internal-error-cloning-object-tf3602033.html#a10062107
Sent from the Wicket - User mailing list archive at Nabble.com.


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to