You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Peter Stavrinides <P....@albourne.com> on 2011/12/14 18:54:01 UTC

Managing the Tapestry 5.3 ApplicationStateManager SSO life-cycle

Hi everyone, 

We are using Tapestry 5.3; when writing some information directly into Tapestry's ApplicationStateManager service and we have been experiencing an odd runtime error which occurs after a time. 

The key we set in the ApplicationStateManager for our SSO's is a class type and the data stored is an instance of the class. Before retrieving an instance we check using exists() whether an instance already exists, and if it does not, we create the instance and write it into the ApplicationStateManager. The class instance shares an interface with an actual service, but the instance cannot be instantiated through the IOC and is a session specific override. 

We now find that occasionally the application state manager returns true for exists(), but then tries to create the instance through the IoC. The question is first of all why does the ApplicationStateManager attempt to instantiate an instance after indicating that an instance already exists, and secondly whether the fact that the instance implements the same interface as a service is part of the cause. Another hint is that in the stack trace (see below) there is a reference to the persistence strategy, so it may be that the ApplicationStateManager was serialised in some way? 

Trace: java.lang.RuntimeException: Error invoking constructor com.albourne.web.ioc.weakcache.ReportComponentExpiringCache(ReportComponentCacheEntryFactory, long) (at ReportComponentExpiringCache.java:11) (for service 'ApplicationStateManager'): No service implements the interface long. at org.apache.tapestry5.ioc.internal.ConstructorServiceCreator$1.invoke(ConstructorServiceCreator.java:81) at org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:65) at org.apache.tapestry5.ioc.internal.PerThreadOperationTracker.invoke(PerThreadOperationTracker.java:68) at org.apache.tapestry5.ioc.internal.RegistryImpl.invoke(RegistryImpl.java:1082) at org.apache.tapestry5.ioc.internal.ConstructorServiceCreator.createObject(ConstructorServiceCreator.java:48) at org.apache.tapestry5.ioc.internal.ServiceResourcesImpl$4.invoke(ServiceResourcesImpl.java:160) at org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:65) at org.apache.tapestry5.ioc.internal.PerThreadOperationTracker.invoke(PerThreadOperationTracker.java:68) at org.apache.tapestry5.ioc.internal.RegistryImpl.invoke(RegistryImpl.java:1082) at org.apache.tapestry5.ioc.internal.ServiceResourcesImpl.autobuild(ServiceResourcesImpl.java:146) at org.apache.tapestry5.internal.services.ApplicationStateManagerImpl$1.create(ApplicationStateManagerImpl.java:104) at org.apache.tapestry5.internal.services.SessionApplicationStatePersistenceStrategy.getOrCreate(SessionApplicationStatePersistenceStrategy.java:57) at org.apache.tapestry5.internal.services.SessionApplicationStatePersistenceStrategy.get(SessionApplicationStatePersistenceStrategy.java:44) at $ApplicationStatePersistenceStrategy_15c119b4caf670.get(Unknown Source) at org.apache.tapestry5.internal.services.ApplicationStateManagerImpl$ApplicationStateAdapter.getOrCreate(ApplicationStateManagerImpl.java:50) at 

Thanks for your help, 
Peter 

Re: Managing the Tapestry 5.3 ApplicationStateManager SSO life-cycle

Posted by Peter Stavrinides <P....@albourne.com>.
Hi Igor, 


Thanks very much for your response!! 


Just to clarify the behaviour, Tapestry's registry will always return a service even if it needs to reconstruct it, right? Is this why in our case the ASM returns a new service instance? 


If we were to use ApplicationStateContribution with an, appropriate ApplicationStateCreator this should make it behave better. I recall the no-args constructor was the reason why we looked for another way of doing this, will this work if we overload it providing more than one constructor ? 


I hope I am making sense. 


Thanks again, 
Peter 

----- Original Message -----

From: "Igor Drobiazko" <ig...@gmail.com> 
To: "Tapestry users" <us...@tapestry.apache.org> 
Sent: Wednesday, 14 December, 2011 10:12:06 PM 
Subject: Re: Managing the Tapestry 5.3 ApplicationStateManager SSO life-cycle 

Tapestry creates your SSO using the 
constructor ReportComponentExpiringCache(ReportComponentCacheEntryFactory, 
long). Same autobuild logic is used as for services. Tapestry tries to 
resolve a service of long type which is the second argument of the 
constructor. You should either annotate a no-args constructor with @Inject 
or contribute a ApplicationStateContribution with an 
appropriate ApplicationStateCreator. 

On Wed, Dec 14, 2011 at 6:54 PM, Peter Stavrinides < 
P.Stavrinides@albourne.com> wrote: 

> Hi everyone, 
> 
> We are using Tapestry 5.3; when writing some information directly into 
> Tapestry's ApplicationStateManager service and we have been experiencing an 
> odd runtime error which occurs after a time. 
> 
> The key we set in the ApplicationStateManager for our SSO's is a class 
> type and the data stored is an instance of the class. Before retrieving an 
> instance we check using exists() whether an instance already exists, and if 
> it does not, we create the instance and write it into the 
> ApplicationStateManager. The class instance shares an interface with an 
> actual service, but the instance cannot be instantiated through the IOC and 
> is a session specific override. 
> 
> We now find that occasionally the application state manager returns true 
> for exists(), but then tries to create the instance through the IoC. The 
> question is first of all why does the ApplicationStateManager attempt to 
> instantiate an instance after indicating that an instance already exists, 
> and secondly whether the fact that the instance implements the same 
> interface as a service is part of the cause. Another hint is that in the 
> stack trace (see below) there is a reference to the persistence strategy, 
> so it may be that the ApplicationStateManager was serialised in some way? 
> 
> Trace: java.lang.RuntimeException: Error invoking constructor 
> com.albourne.web.ioc.weakcache.ReportComponentExpiringCache(ReportComponentCacheEntryFactory, 
> long) (at ReportComponentExpiringCache.java:11) (for service 
> 'ApplicationStateManager'): No service implements the interface long. at 
> org.apache.tapestry5.ioc.internal.ConstructorServiceCreator$1.invoke(ConstructorServiceCreator.java:81) 
> at 
> org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:65) 
> at 
> org.apache.tapestry5.ioc.internal.PerThreadOperationTracker.invoke(PerThreadOperationTracker.java:68) 
> at 
> org.apache.tapestry5.ioc.internal.RegistryImpl.invoke(RegistryImpl.java:1082) 
> at 
> org.apache.tapestry5.ioc.internal.ConstructorServiceCreator.createObject(ConstructorServiceCreator.java:48) 
> at 
> org.apache.tapestry5.ioc.internal.ServiceResourcesImpl$4.invoke(ServiceResourcesImpl.java:160) 
> at 
> org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:65) 
> at 
> org.apache.tapestry5.ioc.internal.PerThreadOperationTracker.invoke(PerThreadOperationTracker.java:68) 
> at 
> org.apache.tapestry5.ioc.internal.RegistryImpl.invoke(RegistryImpl.java:1082) 
> at 
> org.apache.tapestry5.ioc.internal.ServiceResourcesImpl.autobuild(ServiceResourcesImpl.java:146) 
> at 
> org.apache.tapestry5.internal.services.ApplicationStateManagerImpl$1.create(ApplicationStateManagerImpl.java:104) 
> at 
> org.apache.tapestry5.internal.services.SessionApplicationStatePersistenceStrategy.getOrCreate(SessionApplicationStatePersistenceStrategy.java:57) 
> at 
> org.apache.tapestry5.internal.services.SessionApplicationStatePersistenceStrategy.get(SessionApplicationStatePersistenceStrategy.java:44) 
> at $ApplicationStatePersistenceStrategy_15c119b4caf670.get(Unknown Source) 
> at 
> org.apache.tapestry5.internal.services.ApplicationStateManagerImpl$ApplicationStateAdapter.getOrCreate(ApplicationStateManagerImpl.java:50) 
> at 
> 
> Thanks for your help, 
> Peter 
> 



-- 
Best regards, 

Igor Drobiazko 
http://tapestry5.de 


Re: Managing the Tapestry 5.3 ApplicationStateManager SSO life-cycle

Posted by Igor Drobiazko <ig...@gmail.com>.
Tapestry creates your SSO using the
constructor ReportComponentExpiringCache(ReportComponentCacheEntryFactory,
long). Same autobuild logic is used as for services. Tapestry tries to
resolve a service of long type which is the second argument of the
constructor. You should either annotate a no-args constructor with @Inject
or contribute a ApplicationStateContribution with an
appropriate ApplicationStateCreator.

On Wed, Dec 14, 2011 at 6:54 PM, Peter Stavrinides <
P.Stavrinides@albourne.com> wrote:

> Hi everyone,
>
> We are using Tapestry 5.3; when writing some information directly into
> Tapestry's ApplicationStateManager service and we have been experiencing an
> odd runtime error which occurs after a time.
>
> The key we set in the ApplicationStateManager for our SSO's is a class
> type and the data stored is an instance of the class. Before retrieving an
> instance we check using exists() whether an instance already exists, and if
> it does not, we create the instance and write it into the
> ApplicationStateManager. The class instance shares an interface with an
> actual service, but the instance cannot be instantiated through the IOC and
> is a session specific override.
>
> We now find that occasionally the application state manager returns true
> for exists(), but then tries to create the instance through the IoC. The
> question is first of all why does the ApplicationStateManager attempt to
> instantiate an instance after indicating that an instance already exists,
> and secondly whether the fact that the instance implements the same
> interface as a service is part of the cause. Another hint is that in the
> stack trace (see below) there is a reference to the persistence strategy,
> so it may be that the ApplicationStateManager was serialised in some way?
>
> Trace: java.lang.RuntimeException: Error invoking constructor
> com.albourne.web.ioc.weakcache.ReportComponentExpiringCache(ReportComponentCacheEntryFactory,
> long) (at ReportComponentExpiringCache.java:11) (for service
> 'ApplicationStateManager'): No service implements the interface long. at
> org.apache.tapestry5.ioc.internal.ConstructorServiceCreator$1.invoke(ConstructorServiceCreator.java:81)
> at
> org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:65)
> at
> org.apache.tapestry5.ioc.internal.PerThreadOperationTracker.invoke(PerThreadOperationTracker.java:68)
> at
> org.apache.tapestry5.ioc.internal.RegistryImpl.invoke(RegistryImpl.java:1082)
> at
> org.apache.tapestry5.ioc.internal.ConstructorServiceCreator.createObject(ConstructorServiceCreator.java:48)
> at
> org.apache.tapestry5.ioc.internal.ServiceResourcesImpl$4.invoke(ServiceResourcesImpl.java:160)
> at
> org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:65)
> at
> org.apache.tapestry5.ioc.internal.PerThreadOperationTracker.invoke(PerThreadOperationTracker.java:68)
> at
> org.apache.tapestry5.ioc.internal.RegistryImpl.invoke(RegistryImpl.java:1082)
> at
> org.apache.tapestry5.ioc.internal.ServiceResourcesImpl.autobuild(ServiceResourcesImpl.java:146)
> at
> org.apache.tapestry5.internal.services.ApplicationStateManagerImpl$1.create(ApplicationStateManagerImpl.java:104)
> at
> org.apache.tapestry5.internal.services.SessionApplicationStatePersistenceStrategy.getOrCreate(SessionApplicationStatePersistenceStrategy.java:57)
> at
> org.apache.tapestry5.internal.services.SessionApplicationStatePersistenceStrategy.get(SessionApplicationStatePersistenceStrategy.java:44)
> at $ApplicationStatePersistenceStrategy_15c119b4caf670.get(Unknown Source)
> at
> org.apache.tapestry5.internal.services.ApplicationStateManagerImpl$ApplicationStateAdapter.getOrCreate(ApplicationStateManagerImpl.java:50)
> at
>
> Thanks for your help,
> Peter
>



-- 
Best regards,

Igor Drobiazko
http://tapestry5.de