You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Felix Gonschorek <fe...@netzgut.net> on 2012/04/15 02:07:30 UTC

Not serializable: org.apache.tapestry5.tree.TreeExpansionModel

Hi all,

i'am currently trying to improve our tapestry application framework to
support session persistence across server restarts (and maybe across
multiple nodes in our server farm in the future).

i managed to made it to change all our own business objects that are
stored in the session to implement the interface "serializable", so that
the session manager of our servlet container (jetty 8) can store it to
the file system.

the class org.apache.tapestry5.tree.DefaultTreeExpansionModel which is
used in the 5.3.2 Tree component to save the tree state is not
serializable. i can't replace the model without extending and changing
the whole tree component. The DefaultTreeExpansionModel implements the
interface "org.apache.tapestry5.OptimizedSessionPersistedObject" which
letst one assume, that a optimized session management is desired.

There are no fields in the class (or superclass) that are not
serializable, so as far as i can see a proper solution would be to just
add the "Serializable" interface and everyhting should be fine.

Is it okay to open a jira task for this? I would highly appreciate this
fix for the next version of tapestry.


Thanks,

Felix

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Not serializable: org.apache.tapestry5.tree.TreeExpansionModel

Posted by Felix Gonschorek <fe...@netzgut.net>.
Am 17.04.2012 10:06, schrieb Lance Java:
> That just flags that you don't have enough test coverage then ;)

haha, you got me ;)

> Running through the object reflectively won't work. In the case of
> List<SomeObject>  the generic type is lost at runtime through type erasure.

you're right. more unit tests it shall be!

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Not serializable: org.apache.tapestry5.tree.TreeExpansionModel

Posted by Lance Java <la...@googlemail.com>.
That just flags that you don't have enough test coverage then ;)

Running through the object reflectively won't work. In the case of
List<SomeObject>  the generic type is lost at runtime through type erasure.

Re: Not serializable: org.apache.tapestry5.tree.TreeExpansionModel

Posted by Felix Gonschorek <fe...@netzgut.net>.
Am 17.04.2012 09:32, schrieb Lance Java:
> A simpler option could be to serialize the data to a temp OutputStream
> instead of checking instanceof Serializable.

yeah, but as i wrote: you wont catch nested non serializable data this
way, if it is not instantiated.


@SessionState
private Cart cart;

the test will succeed (assuming you did not initialize ALL the nested
cart properties for the test), but when the nested data structures
(like: "cart.customer.shippingAddress") is filled with data in
production and "shippingAddress" is not serializable, the serialization
will fail in production even when it succeeded with the temp output
stream (which only wrote "cart", not the nested "customer" and
"shippingAddress" fields).



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Not serializable: org.apache.tapestry5.tree.TreeExpansionModel

Posted by Lance Java <la...@googlemail.com>.
A simpler option could be to serialize the data to a temp OutputStream
instead of checking instanceof Serializable.

Re: Not serializable: org.apache.tapestry5.tree.TreeExpansionModel

Posted by Felix Gonschorek <fe...@netzgut.net>.
Am 16.04.2012 09:44, schrieb Lance Java:
> I think that SeleniumTestCase should inject a Session implementation that
> fails when setAttribute() is called with a non-Serializable object so that
> we can catch this in the future


that would be a start, but you won't catch nested (uninitialized,
non-serializable) classes like:


class A implements Serializable {
 class B {}

 B b = null;

 public void initB() {
  b = new B();
 }
}


... and in the page:

@Persist
private A a;

@SetupRender() {
 a = new A();
}

in this case the selenium test case will not fail.

in this case:

@Persist
private A a;

@SetupRender() {
 a = new A();
 a.initB(); // <--- b initialized
}

the test case will fail ("class B not serializable")

i am currently fighting with nested data structures in our business
objects where non-serializable instances are failing to persist.

one solution would be to traverse all possible paths in the nested data
structure (by-class, not by-value) und check all possible
(non-transient) fields recursivly for serialization.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Not serializable: org.apache.tapestry5.tree.TreeExpansionModel

Posted by Lance Java <la...@googlemail.com>.
I think that SeleniumTestCase should inject a Session implementation that
fails when setAttribute() is called with a non-Serializable object so that
we can catch this in the future

Re: Not serializable: org.apache.tapestry5.tree.TreeExpansionModel

Posted by Felix Gonschorek <fe...@netzgut.net>.
Am 15.04.2012 04:25, schrieb Kalle Korhonen:
> Sounds reasonable to me, please open a jira.

https://issues.apache.org/jira/browse/TAP5-1905

-- 
Netzgut Unternehmergesellschaft (haftungsbeschränkt)

Kirchstr. 18
69115 Heidelberg

Telefon:
+49 6221 39298 51

Telefax:
+49 6221 39298 59

E-Mail:
felix@netzgut.net

Handelsregister: Amtsgericht Mannheim, HRB 709833
Sitz der Gesellschaft: Heidelberg
Geschäftsführer: Felix Gonschorek
Ust-IdNr.: DE272871752

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Not serializable: org.apache.tapestry5.tree.TreeExpansionModel

Posted by Kalle Korhonen <ka...@gmail.com>.
Sounds reasonable to me, please open a jira.

Kalle


On Sat, Apr 14, 2012 at 5:07 PM, Felix Gonschorek <fe...@netzgut.net> wrote:
> Hi all,
>
> i'am currently trying to improve our tapestry application framework to
> support session persistence across server restarts (and maybe across
> multiple nodes in our server farm in the future).
>
> i managed to made it to change all our own business objects that are
> stored in the session to implement the interface "serializable", so that
> the session manager of our servlet container (jetty 8) can store it to
> the file system.
>
> the class org.apache.tapestry5.tree.DefaultTreeExpansionModel which is
> used in the 5.3.2 Tree component to save the tree state is not
> serializable. i can't replace the model without extending and changing
> the whole tree component. The DefaultTreeExpansionModel implements the
> interface "org.apache.tapestry5.OptimizedSessionPersistedObject" which
> letst one assume, that a optimized session management is desired.
>
> There are no fields in the class (or superclass) that are not
> serializable, so as far as i can see a proper solution would be to just
> add the "Serializable" interface and everyhting should be fine.
>
> Is it okay to open a jira task for this? I would highly appreciate this
> fix for the next version of tapestry.
>
>
> Thanks,
>
> Felix
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Not serializable: org.apache.tapestry5.tree.TreeExpansionModel

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Sun, 15 Apr 2012 09:23:55 -0300, Felix Gonschorek <fe...@netzgut.net>  
wrote:

> hi thiago,

Hi, Felix!

>
> it's not me persisting the model ;-) - it's the Tree component:
>
> org.apache.tapestry5.corelib.components.Tree, Line 113:
>
>     @Persist
>     private TreeExpansionModel defaultTreeExpansionModel;

Ouch! I shoudn't answer questions about parts of Tapestry I haven't used  
myself yet. :P Sorry for the confusion . . .

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Not serializable: org.apache.tapestry5.tree.TreeExpansionModel

Posted by Felix Gonschorek <fe...@netzgut.net>.
Am 15.04.2012 14:23, schrieb Felix Gonschorek:
> i will try to fix this issue for me and implement a tree expansion model
> that extends the default expansion model and adds a serializable
> interface. will get back to the list with results.

confirmed: it works. example serializable model:

import java.io.Serializable;
import org.apache.tapestry5.tree.DefaultTreeExpansionModel;

public class SerializableTreeExpansionModel<T> extends
DefaultTreeExpansionModel<T> implements Serializable {

    private static final long serialVersionUID = 88777116818436263L;

}

state is not lost acress server restarts.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Not serializable: org.apache.tapestry5.tree.TreeExpansionModel

Posted by Felix Gonschorek <fe...@netzgut.net>.
Am 15.04.2012 13:52, schrieb Thiago H. de Paula Figueiredo:
> Why are you persisting TreeExpansionModels in the session? I'd avoid that.

hi thiago,

it's not me persisting the model ;-) - it's the Tree component:

org.apache.tapestry5.corelib.components.Tree, Line 113:

    @Persist
    private TreeExpansionModel defaultTreeExpansionModel;

i just found out that i can control the expansion model with the
"expansionModel" component parameter, but the default implementation
works perfect (apart from the serialization issue), i like it that the
expansion state is not lost when i leave the page containing the component.

i will try to fix this issue for me and implement a tree expansion model
that extends the default expansion model and adds a serializable
interface. will get back to the list with results.

felix


-- 
Netzgut Unternehmergesellschaft (haftungsbeschränkt)

Kirchstr. 18
69115 Heidelberg

Telefon:
+49 6221 39298 51

Telefax:
+49 6221 39298 59

E-Mail:
felix@netzgut.net

Handelsregister: Amtsgericht Mannheim, HRB 709833
Sitz der Gesellschaft: Heidelberg
Geschäftsführer: Felix Gonschorek
Ust-IdNr.: DE272871752

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Not serializable: org.apache.tapestry5.tree.TreeExpansionModel

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Sat, 14 Apr 2012 21:07:30 -0300, Felix Gonschorek <fe...@netzgut.net>  
wrote:

> Hi all,

Hi!

Why are you persisting TreeExpansionModels in the session? I'd avoid that.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org