Hi Dieter,

Which version of wicket are you using? (I ask since I see you are using
onBeforeRender() to initialize your components, while since wicket 1.5
there is onInitialize() for that in each component).


For as far as I can see there are no references to your dao in the gist you
provided; However, since it is serialized somewhere in the component tree,
it could be in one of the smaller components used in your PersonenTable
page.

In any case, your page (or a component inside it) has a reference to your
dao.


Since I’ve seen this a lot when I started using wicket, please check if you
are referencing your dao somewhere inside an anonymous inner class /
component.


E.g.:


public Component createMyComponent(String id) {

DAO dao = getDaoFromPageOrElsewhere();

return new AjaxLink<Void>(id) {

public void onClick(AjaxRequestTarget target) {

// This is where an instance of DAO will get serialized into the component
tree!

dao.performAction();

}

}

}


Rewrite such code (if you have it) to look up the DAO reference at the time
you actually need it:


public void onClick(AjaxRequestTarget target) {

DAO dao = getDaoFromPageOrElsewhere();

dao.performAction();

}


My guess is that you’ll find the culprit by simply looking at all places in
your code where you use the PersonenDao.


Met vriendelijke groet,
Kind regards,

Bas Gooren

Op 15 juni 2016 bij 16:25:25, Dieter Tremel (tre...@tremel-computer.de)
schreef:

Hello Martin,

it is:

personenProvider = (com.sun.proxy.$Proxy24)
org.apache.wicket.proxy.LazyInitProxyFactory$JdkHandler@6eb3b9ea

wrapInProxies is true

I added a SignIn mechanism, SignInSession uses PersonenDao too to
authorize in the database. But I checked not to have any references to
it, that could be serialized. I added more of this this part to the gist:

https://gist.github.com/tremel/dd9bfa252282b5853d6d464feccaad29

Dieter

Am 15.06.2016 um 15:00 schrieb Martin Grigorov:
> Hi,
>
> Put a breakpoint at PersonenTable constructor and see what is the type of
'
> personenProvider'.
> It must be JDK Proxy instance.
> If it is not then something wrong is going on.
>
>
org.apache.wicket.guice.GuiceComponentInjector#GuiceComponentInjector(org.apache.wicket.Application,

> com.google.inject.Injector, boolean) - the last parameter here is
> 'wrapInProxies'. It must be 'true'.
>
> Martin Grigorov
> Wicket Training and Consulting
> https://twitter.com/mtgrigorov
>
> On Wed, Jun 15, 2016 at 2:18 PM, Dieter Tremel <tre...@tremel-computer.de>

> wrote:
>
>> Hi Bas,
>>
>> I put it in http://pastie.org/private/19zeomb8uy1beb1gfjegq
>>
>> I fear it is not really useful, since it starts with
>>
>> org.apache.wicket.WicketRuntimeException: A problem occurred while
>> trying to collect debug information about not serializable object
>>
>> Dieter
>>
>> Am 15.06.2016 um 13:39 schrieb Bas Gooren:
>>> Hi Dieter,
>>>
>>> Can you share the stack trace of the serialization checker error?
>>> Normally it points out where in the hierarchy it found a
>>> non-serializable object.
>>> My first guess is that you are referencing the dao class somewhere
>>> directly from your page. The stack trace will prove me right or wrong
:-)
>>>
>>> Met vriendelijke groet,
>>> Kind regards,
>>>
>>> Bas Gooren
>>>
>>> Op 15 juni 2016 bij 13:29:24, Dieter Tremel (tre...@tremel-computer.de
>>> <mailto:tre...@tremel-computer.de>) schreef:
>>>
>>>> Hello Bas,
>>>>
>>>> I try to cut small pieces of the code, please tell me if you want to
see
>>>> more.
>>>>
>>>> First the error:
>>>>
>>>> 12:59:03.919 [http-nio-8084-exec-6] WARN
>>>> o.a.w.c.u.o.c.CheckingObjectOutputStream - error delegating to
>>>> writeObject :
>>>>
>>
de.tremel_computer.abi81.datahandling.PersonenDao$$EnhancerByGuice$$4769627f,

>>>>
>>>> path: /children
>>>> 12:59:03.925 [http-nio-8084-exec-6] ERROR
>>>> o.a.w.serialize.java.JavaSerializer - Error serializing object class
>>>> de.tremel_computer.abi81.pages.PersonenTable [object=[Page class =
>>>> de.tremel_computer.abi81.pages.PersonenTable, id = 1, render count =
1]]
>>>> org.apache.wicket.WicketRuntimeException: A problem occurred while
>>>> trying to collect debug information about not serializable object
>>>> at
>>>>
>>
org.apache.wicket.serialize.java.JavaSerializer$SerializationCheckerObjectOutputStream.writeObjectOverride(JavaSerializer.java:278)

>>>>
>>>>
>>>>
>>>>
>>>> public class PersonenTable extends BasePage {
>>>>
>>>> @Inject
>>>> private ICachingAbiDataProvider<Personen> personenProvider;
>>>> ...
>>>> }
>>>>
>>>> public class AbstractProvider<E extends JPAEntity> extends
>>>> SortableDataProvider<E, String> implements IAbiDataProvider<E> {
>>>>
>>>> @Inject
>>>> private ReadOnlyDao<E> dao;
>>>> ...
>>>> }
>>>>
>>>> public abstract class JPAReadOnlyDao<E extends JPAEntity> implements
>>>> ReadOnlyDao<E> {
>>>>
>>>> private Provider<EntityManager> emProvider;
>>>> private final Class<E> entityClass;
>>>>
>>>> public JPAReadOnlyDao(Class<E> entityClass) {
>>>> this.entityClass = entityClass;
>>>> }
>>>> ...
>>>>
>>>> @Inject
>>>> public void setEntityManagerProvider(Provider<EntityManager>
>>>> emProvider) {
>>>> this.emProvider = emProvider;
>>>> }
>>>> ...
>>>> }
>>>>
>>>> public class Abi81GuiceModule extends AbstractModule {
>>>>
>>>> @Override
>>>> protected void configure() {
>>>> bind(PersistServiceInitializer.class).asEagerSingleton();
>>>> bind(new TypeLiteral<ReadOnlyDao<Abiartikel>>()
>>>> {}).to(AbiartikelDao.class);
>>>> bind(new TypeLiteral<ReadOnlyDao<Personen>>()
>>>> {}).to(PersonenDao.class);
>>>> bind(new TypeLiteral<WritingDao<Personen>>()
>>>> {}).to(PersonenDao.class);
>>>> bind(new TypeLiteral<ICachingAbiDataProvider<Abiartikel>>()
>>>> {}).to(CachingAbiartikelProvider.class);
>>>> bind(new TypeLiteral<ICachingAbiDataProvider<Personen>>()
>>>> {}).to(CachingPersonenProvider.class);
>>>> }
>>>> }
>>>>
>>>> BasePage creates a SignInPanel that links to a SignIn-Page, that uses
>>>> methods of SignInSession, that makes use a PersonenDao in only in a
>>>> method.
>>>>
>>>> I also made a gist:
>>>> https://gist.github.com/tremel/dd9bfa252282b5853d6d464feccaad29
>>>>
>>>> Thank you
>>>> Dieter
>>>>
>>>>
>>>> Am 15.06.2016 um 08:17 schrieb Bas Gooren:
>>>>> Dieter,
>>>>>
>>>>> Since the data provider is inject as a proxy, only the proxy should
be
>>>>> serialized. On deserialization it should look up the actual data
>>>>> provider again.
>>>>>
>>>>> Can you share some code so we can see how you set things up? What you
>>>>> are trying is something that should work out of the box - it does for
>>>>> us.
>>>>>
>>>>> Bas
>>>>>
>>>>> Verstuurd vanaf mijn iPhone
>>>>>
>>>>>> Op 15 jun. 2016 om 07:53 heeft Dieter Tremel <
>> tre...@tremel-computer.de> het volgende geschreven:
>>>>>>
>>>>>> Hallo wicket-user,
>>>>>>
>>>>>> IMHO combining wicket with non serializable objects is a challenging
>> topic.
>>>>>>
>>>>>> On a page I have a DataProvider, that is injected by wicked-guice.
>>>>>> Inside this provider an injected dao is used for fetching the data.
>>>>>> Inside the dao a provider for a JPA2 entity manager (EclipseLink) is
>>>>>> injected.
>>>>>>
>>>>>> Page -> DataProvider -> Dao -> Provider<EntityManager>
>>>>>>
>>>>>> Seems to be useful, but since the page is stateful I recognized the
>> non
>>>>>> serializeable error for the dao at the end of page rendering.
>>>>>>
>>>>>> After some code studies I think wicket-guice is only using a proxy
>> for
>>>>>> the DataProvider, the second second and third level of injection is
>> done
>>>>>> only by guice, not handled by wicket-guice and wicket-ioc. This
>> causes
>>>>>> serializable error for dao. Am I right here? wicket-guice is not as
>>>>>> useful as it could be, if it would not be restricted to the fields
in
>>>>>> the first level. Setter injection is another topic. The name-pair
>> lets
>>>>>> associate a transparent combination of the two technologies, but it
>> isn't.
>>>>>>
>>>>>> At the moment I have no solution for this.
>>>>>> I still struggle with the right architecture fore using generic JPA2
>>>>>> provided entities on my pages. The only idea so far is not to use
>> guice
>>>>>> and use the application as a link to the non serializable JPA
objects
>>>>>> and using detachable models to handle the on pages.
>>>>>>
>>>>>> Any hints for my confused mind welcome. Thanks!
>>>>>>
>>>>>> Dieter Tremel
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>> For additional commands, e-mail: users-h...@wicket.apache.org
>>
>>
>


-- 
Tremel Computer http://www.tremel-computer.de
Dieter Tremel mailto:tre...@tremel-computer.de
Rebenring 16 Tel +49 871 9357080
84032 Altdorf Fax +49 871 9357081

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to