Uploaded image for project: 'Causeway'
  1. Causeway
  2. CAUSEWAY-2399

Spring bean resolution issues when configuring TenantedAuthorizationFacet

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Resolved
    • 2.0.0-M3
    • 2.0.0-M4
    • Core
    • None

    Description

      It seems that attempting to access QueryResultsCache (which is @InteractionScoped) from within a facet (TenantedAuthorizationFacet) causes issues.

      To reproduce, in the demo app:

      just add this silly implementation:

      @Service
      public class ApplicationTenancyEvaluatorImpl implements ApplicationTenancyEvaluator {
      
          @Override
          public boolean handles(Class<?> cls) {
              return PrimitiveByteHolder.class.isAssignableFrom(cls);
          }
      
          @Override
          public String hides(Object domainObject, ApplicationUser applicationUser) {
              PrimitiveByteHolder byteHolder = (PrimitiveByteHolder) domainObject;
              return byteHolder.getReadOnlyProperty() == 3 ? "hidden" : null;
          }
      
          @Override
          public String disables(Object domainObject, ApplicationUser applicationUser) {
              return null;
          }
      }
       

      which for me generated this stack trace:

      org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'isisRuntime.QueryResultsCacheDefault': Scope 'isis-interaction' is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton; nested exception is java.lang.IllegalStateException: Creation of bean isisRuntime.QueryResultsCacheDefault with @IsisInteractionScope requires the calling Thread[ForkJoinPool.commonPool-worker-5 (453)]) to have an open IsisInteraction on the thread-local stack. Running into this issue might be caused by use of ... @Inject MyScopedBean bean ..., instead of ... @Inject Provider<MyScopedBean> provider ...org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'isisRuntime.QueryResultsCacheDefault': Scope 'isis-interaction' is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton; nested exception is java.lang.IllegalStateException: Creation of bean isisRuntime.QueryResultsCacheDefault with @IsisInteractionScope requires the calling Thread[ForkJoinPool.commonPool-worker-5 (453)]) to have an open IsisInteraction on the thread-local stack. Running into this issue might be caused by use of ... @Inject MyScopedBean bean ..., instead of ... @Inject Provider<MyScopedBean> provider ... at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:368) ~[spring-beans-5.2.7.RELEASE.jar:5.2.7.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.7.RELEASE.jar:5.2.7.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory$1.orderedStream(DefaultListableBeanFactory.java:407) ~[spring-beans-5.2.7.RELEASE.jar:5.2.7.RELEASE] at org.apache.isis.core.commons.internal.ioc.spring.IocContainerSpring.select(IocContainerSpring.java:115) ~[isis-core-commons-2.0.0-SNAPSHOT.jar:2.0.0-SNAPSHOT] at org.apache.isis.core.metamodel.services.registry.ServiceRegistryDefault.select(ServiceRegistryDefault.java:77) ~[isis-core-metamodel-2.0.0-SNAPSHOT.jar:2.0.0-SNAPSHOT] at org.apache.isis.applib.services.registry.ServiceRegistry.select(ServiceRegistry.java:68) ~[isis-applib-2.0.0-SNAPSHOT.jar:2.0.0-SNAPSHOT] at org.apache.isis.applib.services.registry.ServiceRegistry.lookupService(ServiceRegistry.java:131) ~[isis-applib-2.0.0-SNAPSHOT.jar:2.0.0-SNAPSHOT] at org.apache.isis.extensions.secman.model.facets.TenantedAuthorizationFacetFactory.createFacet(TenantedAuthorizationFacetFactory.java:102) ~[isis-extensions-secman-model-2.0.0-SNAPSHOT.jar:2.0.0-SNAPSHOT] at org.apache.isis.extensions.secman.model.facets.TenantedAuthorizationFacetFactory.process(TenantedAuthorizationFacetFactory.java:62) ~[isis-extensions-secman-model-2.0.0-SNAPSHOT.jar:2.0.0-SNAPSHOT] at org.apache.isis.core.metamodel.specloader.facetprocessor.FacetProcessor.lambda$process$1(FacetProcessor.java:307) ~[isis-core-metamodel-2.0.0-SNAPSHOT.jar:2.0.0-SNAPSHOT] at java.util.ArrayList.forEach(ArrayList.java:1540) ~[?:?] at org.apache.isis.core.metamodel.specloader.facetprocessor.FacetProcessor.process(FacetProcessor.java:307) ~[isis-core-metamodel-2.0.0-SNAPSHOT.jar:2.0.0-SNAPSHOT] at org.apache.isis.core.metamodel.specloader.specimpl.FacetedMethodsBuilder.introspectClass(FacetedMethodsBuilder.java:174) ~[isis-core-metamodel-2.0.0-SNAPSHOT.jar:2.0.0-SNAPSHOT] at org.apache.isis.core.metamodel.specloader.specimpl.dflt.ObjectSpecificationDefault.introspectTypeHierarchy(ObjectSpecificationDefault.java:124) ~[isis-core-metamodel-2.0.0-SNAPSHOT.jar:2.0.0-SNAPSHOT] at org.apache.isis.core.metamodel.specloader.specimpl.ObjectSpecificationAbstract.introspectUpTo(ObjectSpecificationAbstract.java:286) ~[isis-core-metamodel-2.0.0-SNAPSHOT.jar:2.0.0-SNAPSHOT] at org.apache.isis.core.metamodel.specloader.SpecificationLoaderDefault.introspect(SpecificationLoaderDefault.java:508) ~[isis-core-metamodel-2.0.0-SNAPSHOT.jar:2.0.0-SNAPSHOT] at org.apache.isis.core.metamodel.specloader.SpecificationLoaderDefault.createMetaModel(SpecificationLoaderDefault.java:252) ~[isis-core-metamodel-2.0.0-SNAPSHOT.jar:2.0.0-SNAPSHOT] at org.apache.isis.core.commons.internal.concurrent._ConcurrentTask$3.innerCall(_ConcurrentTask.java:157) ~[isis-core-commons-2.0.0-SNAPSHOT.jar:2.0.0-SNAPSHOT] at org.apache.isis.core.commons.internal.concurrent._ConcurrentTask$3.innerCall(_ConcurrentTask.java:153) ~[isis-core-commons-2.0.0-SNAPSHOT.jar:2.0.0-SNAPSHOT] at org.apache.isis.core.commons.internal.concurrent._ConcurrentTask$1.innerCall(_ConcurrentTask.java:112) ~[isis-core-commons-2.0.0-SNAPSHOT.jar:2.0.0-SNAPSHOT] at org.apache.isis.core.commons.internal.concurrent._ConcurrentTask.run(_ConcurrentTask.java:87) ~[isis-core-commons-2.0.0-SNAPSHOT.jar:2.0.0-SNAPSHOT] at java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1407) ~[?:?] at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290) ~[?:?] at java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020) ~[?:?] at java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656) ~[?:?] at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594) ~[?:?] at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177) ~[?:?]Caused by: java.lang.IllegalStateException: Creation of bean isisRuntime.QueryResultsCacheDefault with @IsisInteractionScope requires the calling Thread[ForkJoinPool.commonPool-worker-5 (453)]) to have an open IsisInteraction on the thread-local stack. Running into this issue might be caused by use of ... @Inject MyScopedBean bean ..., instead of ... @Inject Provider<MyScopedBean> provider ... at org.apache.isis.core.commons.internal.exceptions._Exceptions.illegalState(_Exceptions.java:87) ~[isis-core-commons-2.0.0-SNAPSHOT.jar:2.0.0-SNAPSHOT] at org.apache.isis.core.runtime.iactn.scope.IsisInteractionScope.get(IsisInteractionScope.java:69) ~[isis-core-runtime-2.0.0-SNAPSHOT.jar:2.0.0-SNAPSHOT] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:356) ~[spring-beans-5.2.7.RELEASE.jar:5.2.7.RELEASE] ... 26 more 

      Attachments

        Activity

          People

            hobrom Andi Huber
            danhaywood Daniel Keir Haywood
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: