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.stavrini...@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