Tapestry 5
  1. Tapestry 5
  2. TAP5-308

Injecting dependencies into contributeTypeCoercer method causes circular dependency error

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 5.0.15
    • Fix Version/s: 5.0.16
    • Component/s: tapestry-ioc
    • Labels:
      None

      Description

      If the contributeTypeCoercer only has the configuration parameter everything works fine:

      public static void contributeTypeCoercer(Configuration<CoercionTuple> configuration)
      {
      ...
      }

      But if i want to inject into the method any other service or even value like so:

      public static void contributeTypeCoercer(Configuration<CoercionTuple> configuration, Logger logger) {
      }

      I get the following exception:

      java.lang.RuntimeException: Error invoking constructor org.apache.tapestry5.ioc.internal.services.TypeCoercerImpl(Collection) (at TypeCoercerImpl.java:93) via org.apache.tapestry5.ioc.services.TapestryIOCModule.bind(ServiceBinder) (at TapestryIOCModule.java:38) (for service 'TypeCoercer'): Error invoking service contribution method pt.viaverde.ecm.classification.web.services.ClassificacaoModule.contributeTypeCoercer(Configuration, String): Exception constructing service 'TypeCoercer': Construction of service 'TypeCoercer' has failed due to recursion: the service depends on itself in some way. Please check org.apache.tapestry5.ioc.internal.services.TypeCoercerImpl(Collection) (at TypeCoercerImpl.java:93) via org.apache.tapestry5.ioc.services.TapestryIOCModule.bind(ServiceBinder) (at TapestryIOCModule.java:38) for references to another service that is itself dependent on service 'TypeCoercer'.
      at org.apache.tapestry5.ioc.internal.ConstructorServiceCreator.createObject(ConstructorServiceCreator.java:63)
      at org.apache.tapestry5.ioc.internal.SingletonServiceLifecycle.createService(SingletonServiceLifecycle.java:29)
      at org.apache.tapestry5.ioc.internal.LifecycleWrappedServiceCreator.createObject(LifecycleWrappedServiceCreator.java:52)
      at org.apache.tapestry5.ioc.internal.RecursiveServiceCreationCheckWrapper.createObject(RecursiveServiceCreationCheckWrapper.java:60)
      at org.apache.tapestry5.ioc.internal.services.JustInTimeObjectCreator.createObject(JustInTimeObjectCreator.java:65)
      at $TypeCoercer_11d26e6f77f.delegate($TypeCoercer_11d26e6f77f.java)
      at $TypeCoercer_11d26e6f77f.coerce($TypeCoercer_11d26e6f77f.java)
      at org.apache.tapestry5.ioc.internal.services.ValueObjectProvider.provide(ValueObjectProvider.java:58)
      at org.apache.tapestry5.ioc.internal.services.MasterObjectProviderImpl.provide(MasterObjectProviderImpl.java:38)
      at $MasterObjectProvider_11d26e6f77b.provide($MasterObjectProvider_11d26e6f77b.java)
      at org.apache.tapestry5.ioc.internal.RegistryImpl.getObject(RegistryImpl.java:626)
      at org.apache.tapestry5.ioc.internal.RegistryImpl.getObject(RegistryImpl.java:733)
      at org.apache.tapestry5.ioc.internal.ObjectLocatorImpl.getObject(ObjectLocatorImpl.java:49)
      at org.apache.tapestry5.ioc.internal.util.InternalUtils.calculateParameterValue(InternalUtils.java:205)
      at org.apache.tapestry5.ioc.internal.util.InternalUtils.calculateParameters(InternalUtils.java:235)
      at org.apache.tapestry5.ioc.internal.util.InternalUtils.calculateParametersForMethod(InternalUtils.java:214)
      at org.apache.tapestry5.ioc.internal.ServiceBuilderMethodInvoker.createObject(ServiceBuilderMethodInvoker.java:67)
      at org.apache.tapestry5.ioc.internal.ModuleImpl.create(ModuleImpl.java:233)
      at org.apache.tapestry5.ioc.internal.ModuleImpl.access$100(ModuleImpl.java:35)
      at org.apache.tapestry5.ioc.internal.ModuleImpl$1.invoke(ModuleImpl.java:168)
      at org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier.withWrite(ConcurrentBarrier.java:138)
      at org.apache.tapestry5.ioc.internal.ModuleImpl$2.invoke(ModuleImpl.java:185)
      at org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier.withRead(ConcurrentBarrier.java:83)
      at org.apache.tapestry5.ioc.internal.ModuleImpl.findOrCreate(ModuleImpl.java:192)
      at org.apache.tapestry5.ioc.internal.ModuleImpl.getService(ModuleImpl.java:89)
      at org.apache.tapestry5.ioc.internal.RegistryImpl.getService(RegistryImpl.java:303)
      at org.apache.tapestry5.ioc.internal.RegistryImpl.findServiceByMarkerAndType(RegistryImpl.java:684)
      at org.apache.tapestry5.ioc.internal.RegistryImpl.getObject(RegistryImpl.java:619)
      at org.apache.tapestry5.ioc.internal.RegistryImpl.getObject(RegistryImpl.java:733)
      at org.apache.tapestry5.ioc.internal.ObjectLocatorImpl.getObject(ObjectLocatorImpl.java:49)
      at org.apache.tapestry5.ioc.internal.util.InternalUtils.calculateParameterValue(InternalUtils.java:205)
      at org.apache.tapestry5.ioc.internal.util.InternalUtils.calculateParameters(InternalUtils.java:235)
      at org.apache.tapestry5.ioc.internal.util.InternalUtils.calculateParametersForMethod(InternalUtils.java:214)
      at org.apache.tapestry5.ioc.internal.ContributionDefImpl.invokeMethod(ContributionDefImpl.java:90)
      at org.apache.tapestry5.ioc.internal.ContributionDefImpl.contribute(ContributionDefImpl.java:56)
      at org.apache.tapestry5.ioc.internal.RegistryImpl.addToUnorderedConfiguration(RegistryImpl.java:481)
      at org.apache.tapestry5.ioc.internal.RegistryImpl.getUnorderedConfiguration(RegistryImpl.java:355)
      at org.apache.tapestry5.ioc.internal.ServiceResourcesImpl.getUnorderedConfiguration(ServiceResourcesImpl.java:72)
      at org.apache.tapestry5.ioc.internal.AbstractServiceCreator.addUnorderedConfigurationParameter(AbstractServiceCreator.java:140)
      at org.apache.tapestry5.ioc.internal.AbstractServiceCreator.getParameterDefaultsWithConfiguration(AbstractServiceCreator.java:106)
      at org.apache.tapestry5.ioc.internal.ServiceBuilderMethodInvoker.getParameterDefaultsWithConfigurations(ServiceBuilderMethodInvoker.java:46)
      at org.apache.tapestry5.ioc.internal.ServiceBuilderMethodInvoker.createObject(ServiceBuilderMethodInvoker.java:67)
      at org.apache.tapestry5.ioc.internal.SingletonServiceLifecycle.createService(SingletonServiceLifecycle.java:29)
      at org.apache.tapestry5.ioc.internal.LifecycleWrappedServiceCreator.createObject(LifecycleWrappedServiceCreator.java:52)
      at org.apache.tapestry5.ioc.internal.InterceptorStackBuilder.createObject(InterceptorStackBuilder.java:50)
      at org.apache.tapestry5.ioc.internal.RecursiveServiceCreationCheckWrapper.createObject(RecursiveServiceCreationCheckWrapper.java:60)
      at org.apache.tapestry5.ioc.internal.services.JustInTimeObjectCreator.createObject(JustInTimeObjectCreator.java:65)
      at $Alias_11d26e6f77c.delegate($Alias_11d26e6f77c.java)
      at $Alias_11d26e6f77c.getObjectProvider($Alias_11d26e6f77c.java)
      at org.apache.tapestry5.services.TapestryModule$1.provide(TapestryModule.java:556)
      at org.apache.tapestry5.ioc.internal.services.MasterObjectProviderImpl.provide(MasterObjectProviderImpl.java:38)
      at $MasterObjectProvider_11d26e6f77b.provide($MasterObjectProvider_11d26e6f77b.java)
      at org.apache.tapestry5.ioc.internal.RegistryImpl.getObject(RegistryImpl.java:626)
      at org.apache.tapestry5.ioc.internal.RegistryImpl.getObject(RegistryImpl.java:733)
      at org.apache.tapestry5.ioc.internal.ObjectLocatorImpl.getObject(ObjectLocatorImpl.java:49)
      at org.apache.tapestry5.ioc.internal.util.InternalUtils.calculateParameterValue(InternalUtils.java:205)
      at org.apache.tapestry5.ioc.internal.util.InternalUtils.calculateParameters(InternalUtils.java:235)
      at org.apache.tapestry5.ioc.internal.ModuleImpl.constructModuleBuilder(ModuleImpl.java:337)
      at org.apache.tapestry5.ioc.internal.ModuleImpl.access$400(ModuleImpl.java:35)
      at org.apache.tapestry5.ioc.internal.ModuleImpl$3.run(ModuleImpl.java:274)
      at org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier$2.invoke(ConcurrentBarrier.java:198)
      at org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier$2.invoke(ConcurrentBarrier.java:196)
      at org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier.withWrite(ConcurrentBarrier.java:138)
      at org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier.withWrite(ConcurrentBarrier.java:204)
      at org.apache.tapestry5.ioc.internal.ModuleImpl$4.invoke(ModuleImpl.java:282)
      at org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier.withRead(ConcurrentBarrier.java:83)
      at org.apache.tapestry5.ioc.internal.ModuleImpl.getModuleBuilder(ModuleImpl.java:290)
      at org.apache.tapestry5.ioc.internal.ServiceResourcesImpl.getModuleBuilder(ServiceResourcesImpl.java:105)
      at org.apache.tapestry5.ioc.internal.ServiceBuilderMethodInvoker.createObject(ServiceBuilderMethodInvoker.java:59)
      at org.apache.tapestry5.ioc.internal.SingletonServiceLifecycle.createService(SingletonServiceLifecycle.java:29)
      at org.apache.tapestry5.ioc.internal.LifecycleWrappedServiceCreator.createObject(LifecycleWrappedServiceCreator.java:52)
      at org.apache.tapestry5.ioc.internal.InterceptorStackBuilder.createObject(InterceptorStackBuilder.java:50)
      at org.apache.tapestry5.ioc.internal.RecursiveServiceCreationCheckWrapper.createObject(RecursiveServiceCreationCheckWrapper.java:60)
      at org.apache.tapestry5.ioc.internal.services.JustInTimeObjectCreator.createObject(JustInTimeObjectCreator.java:65)
      at $ServletApplicationInitializer_11d26e6f77a.delegate($ServletApplicationInitializer_11d26e6f77a.java)
      at $ServletApplicationInitializer_11d26e6f77a.initializeApplication($ServletApplicationInitializer_11d26e6f77a.java)
      at org.apache.tapestry5.TapestryFilter.init(TapestryFilter.java:91)
      at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:223)
      at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:304)
      at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:77)
      at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3598)
      at org.apache.catalina.core.StandardContext.start(StandardContext.java:4168)
      at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1012)
      at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
      at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1012)
      at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
      at org.apache.catalina.startup.Embedded.start(Embedded.java:821)
      at org.codehaus.mojo.tomcat.AbstractRunMojo.startContainer(AbstractRunMojo.java:253)
      at org.codehaus.mojo.tomcat.AbstractRunMojo.execute(AbstractRunMojo.java:113)
      at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:451)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:558)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:512)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:482)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:330)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:291)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:142)
      at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:336)
      at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129)
      at org.apache.maven.cli.MavenCli.main(MavenCli.java:287)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
      at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
      at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
      at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)

        Activity

        Hugo Palma created issue -
        Hide
        Howard M. Lewis Ship added a comment -

        A certain set of services, including TypeCoercer and MasterObjectProvider, are directly involved in the process of injection: the analysis of injection points (constructor parameters & their annotations) to resolve to a service or other object.

        When making a contribution to a service, such as TypeCoercer, be careful to use @InjectService (which does not use MasterObjectProvider, a chain of command that makes use of TypeCoercer).

        Show
        Howard M. Lewis Ship added a comment - A certain set of services, including TypeCoercer and MasterObjectProvider, are directly involved in the process of injection: the analysis of injection points (constructor parameters & their annotations) to resolve to a service or other object. When making a contribution to a service, such as TypeCoercer, be careful to use @InjectService (which does not use MasterObjectProvider, a chain of command that makes use of TypeCoercer).
        Hide
        Hugo Palma added a comment -

        Using @InjectService is indeed a workaround.

        I understand the problem but i don't think that the normal developer should have to be aware of this and probably spend a day trying to figure out why he can't inject services to TypeCoercer just like he does for "normal" services.

        It would be great if Tapestry took care of this for the developer.

        Show
        Hugo Palma added a comment - Using @InjectService is indeed a workaround. I understand the problem but i don't think that the normal developer should have to be aware of this and probably spend a day trying to figure out why he can't inject services to TypeCoercer just like he does for "normal" services. It would be great if Tapestry took care of this for the developer.
        Hide
        Howard M. Lewis Ship added a comment -

        Could I see some code from

        pt.viaverde.ecm.classification.web.services.ClassificacaoModule.contributeTypeCoercer(Configuration, String)

        ?

        I have two approaches to this bug.

        One; institute a proxy for TypeCoercer that checks if coercion is necessary before delegating the real service.

        Second, track what is being constructed and integrate that into the exception report, somehow.

        Show
        Howard M. Lewis Ship added a comment - Could I see some code from pt.viaverde.ecm.classification.web.services.ClassificacaoModule.contributeTypeCoercer(Configuration, String) ? I have two approaches to this bug. One; institute a proxy for TypeCoercer that checks if coercion is necessary before delegating the real service. Second, track what is being constructed and integrate that into the exception report, somehow.
        Hide
        Hugo Palma added a comment -

        Sure:

        public static void contributeTypeCoercer(Configuration<CoercionTuple> configuration,
        @InjectService("JSONObjectToProcessTypeCoercer") JSONObjectToProcessTypeCoercer jsonObjectToProcessTypeCoercer)

        { configuration.add( new CoercionTuple(JSONObject.class, pt.viaverde.ecm.classification.web.entities.Process.class, jsonObjectToProcessTypeCoercer)); }

        That's the method with the @InjectService workaround. I have to make JSONObjectToProcessTypeCoercer a service because it has to receive some injected values in order to work properly.

        Show
        Hugo Palma added a comment - Sure: public static void contributeTypeCoercer(Configuration<CoercionTuple> configuration, @InjectService("JSONObjectToProcessTypeCoercer") JSONObjectToProcessTypeCoercer jsonObjectToProcessTypeCoercer) { configuration.add( new CoercionTuple(JSONObject.class, pt.viaverde.ecm.classification.web.entities.Process.class, jsonObjectToProcessTypeCoercer)); } That's the method with the @InjectService workaround. I have to make JSONObjectToProcessTypeCoercer a service because it has to receive some injected values in order to work properly.
        Hide
        Howard M. Lewis Ship added a comment -

        What did it look like before you used @InjectService; that is the state of the code reflected in the stack trace?

        Show
        Howard M. Lewis Ship added a comment - What did it look like before you used @InjectService; that is the state of the code reflected in the stack trace?
        Hide
        Hugo Palma added a comment -

        Before i used @InjectService the code didn't work, that's why i created this issue. In order for my use case to be implemented i need to inject services into the TypeCoercer configuration and AFAIK using the @InjectService is the only way to achieve that right now.

        Regarding the stack trace, no it's not. That stack trace is from a time when i was trying to inject the Logger into the contributeTypeCoercer. Here's the stack trace when the method looks like "public static void contributeTypeCoercer(Configuration<CoercionTuple> configuration, JSONObjectToProcessTypeCoercer jsonObjectToProcessTypeCoercer)":

        java.lang.RuntimeException: Error invoking constructor org.apache.tapestry5.ioc.internal.services.TypeCoercerImpl(Collection) (at TypeCoercerImpl.java:93) via org.apache.tapestry5.ioc.services.TapestryIOCModule.bind(ServiceBinder) (at TapestryIOCModule.java:38) (for service 'TypeCoercer'): Error invoking service contribution method pt.viaverde.ecm.classification.web.services.ClassificacaoModule.contributeTypeCoercer(Configuration, JSONObjectToProcessTypeCoercer): Exception constructing service 'Alias': Construction of service 'Alias' has failed due to recursion: the service depends on itself in some way. Please check org.apache.tapestry5.services.TapestryModule.buildAlias(Logger, String, AliasManager, Collection) (at TapestryModule.java:217) for references to another service that is itself dependent on service 'Alias'.
        at org.apache.tapestry5.ioc.internal.ConstructorServiceCreator.createObject(ConstructorServiceCreator.java:63)
        at org.apache.tapestry5.ioc.internal.SingletonServiceLifecycle.createService(SingletonServiceLifecycle.java:29)
        at org.apache.tapestry5.ioc.internal.LifecycleWrappedServiceCreator.createObject(LifecycleWrappedServiceCreator.java:52)
        at org.apache.tapestry5.ioc.internal.RecursiveServiceCreationCheckWrapper.createObject(RecursiveServiceCreationCheckWrapper.java:60)
        at org.apache.tapestry5.ioc.internal.services.JustInTimeObjectCreator.createObject(JustInTimeObjectCreator.java:65)
        at $TypeCoercer_11d4842642f.delegate($TypeCoercer_11d4842642f.java)
        at $TypeCoercer_11d4842642f.coerce($TypeCoercer_11d4842642f.java)
        at org.apache.tapestry5.ioc.internal.services.ValueObjectProvider.provide(ValueObjectProvider.java:58)
        at org.apache.tapestry5.ioc.internal.services.MasterObjectProviderImpl.provide(MasterObjectProviderImpl.java:38)
        at $MasterObjectProvider_11d4842642d.provide($MasterObjectProvider_11d4842642d.java)
        at org.apache.tapestry5.ioc.internal.RegistryImpl.getObject(RegistryImpl.java:626)
        at org.apache.tapestry5.ioc.internal.RegistryImpl.getObject(RegistryImpl.java:733)
        at org.apache.tapestry5.ioc.internal.ObjectLocatorImpl.getObject(ObjectLocatorImpl.java:49)
        at org.apache.tapestry5.ioc.internal.util.InternalUtils.calculateParameterValue(InternalUtils.java:205)
        at org.apache.tapestry5.ioc.internal.util.InternalUtils.calculateParameters(InternalUtils.java:235)
        at org.apache.tapestry5.ioc.internal.util.InternalUtils.calculateParametersForMethod(InternalUtils.java:214)
        at org.apache.tapestry5.ioc.internal.ServiceBuilderMethodInvoker.createObject(ServiceBuilderMethodInvoker.java:67)
        at org.apache.tapestry5.ioc.internal.ModuleImpl.create(ModuleImpl.java:233)
        at org.apache.tapestry5.ioc.internal.ModuleImpl.access$100(ModuleImpl.java:35)
        at org.apache.tapestry5.ioc.internal.ModuleImpl$1.invoke(ModuleImpl.java:168)
        at org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier.withWrite(ConcurrentBarrier.java:138)
        at org.apache.tapestry5.ioc.internal.ModuleImpl$2.invoke(ModuleImpl.java:185)
        at org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier.withRead(ConcurrentBarrier.java:83)
        at org.apache.tapestry5.ioc.internal.ModuleImpl.findOrCreate(ModuleImpl.java:192)
        at org.apache.tapestry5.ioc.internal.ModuleImpl.getService(ModuleImpl.java:89)
        at org.apache.tapestry5.ioc.internal.RegistryImpl.getService(RegistryImpl.java:303)
        at org.apache.tapestry5.ioc.internal.RegistryImpl.findServiceByMarkerAndType(RegistryImpl.java:684)
        at org.apache.tapestry5.ioc.internal.RegistryImpl.getObject(RegistryImpl.java:619)
        at org.apache.tapestry5.ioc.internal.RegistryImpl.getObject(RegistryImpl.java:733)
        at org.apache.tapestry5.ioc.internal.ObjectLocatorImpl.getObject(ObjectLocatorImpl.java:49)
        at org.apache.tapestry5.ioc.internal.util.InternalUtils.calculateParameterValue(InternalUtils.java:205)
        at org.apache.tapestry5.ioc.internal.util.InternalUtils.calculateParameters(InternalUtils.java:235)
        at org.apache.tapestry5.ioc.internal.util.InternalUtils.calculateParametersForMethod(InternalUtils.java:214)
        at org.apache.tapestry5.ioc.internal.ContributionDefImpl.invokeMethod(ContributionDefImpl.java:90)
        at org.apache.tapestry5.ioc.internal.ContributionDefImpl.contribute(ContributionDefImpl.java:56)
        at org.apache.tapestry5.ioc.internal.RegistryImpl.addToUnorderedConfiguration(RegistryImpl.java:481)
        at org.apache.tapestry5.ioc.internal.RegistryImpl.getUnorderedConfiguration(RegistryImpl.java:355)
        at org.apache.tapestry5.ioc.internal.ServiceResourcesImpl.getUnorderedConfiguration(ServiceResourcesImpl.java:72)
        at org.apache.tapestry5.ioc.internal.AbstractServiceCreator.addUnorderedConfigurationParameter(AbstractServiceCreator.java:140)
        at org.apache.tapestry5.ioc.internal.AbstractServiceCreator.getParameterDefaultsWithConfiguration(AbstractServiceCreator.java:106)
        at org.apache.tapestry5.ioc.internal.ServiceBuilderMethodInvoker.getParameterDefaultsWithConfigurations(ServiceBuilderMethodInvoker.java:46)
        at org.apache.tapestry5.ioc.internal.ServiceBuilderMethodInvoker.createObject(ServiceBuilderMethodInvoker.java:67)
        at org.apache.tapestry5.ioc.internal.SingletonServiceLifecycle.createService(SingletonServiceLifecycle.java:29)
        at org.apache.tapestry5.ioc.internal.LifecycleWrappedServiceCreator.createObject(LifecycleWrappedServiceCreator.java:52)
        at org.apache.tapestry5.ioc.internal.InterceptorStackBuilder.createObject(InterceptorStackBuilder.java:50)
        at org.apache.tapestry5.ioc.internal.RecursiveServiceCreationCheckWrapper.createObject(RecursiveServiceCreationCheckWrapper.java:60)
        at org.apache.tapestry5.ioc.internal.services.JustInTimeObjectCreator.createObject(JustInTimeObjectCreator.java:65)
        at $Alias_11d48426430.delegate($Alias_11d48426430.java)
        at $Alias_11d48426430.getObjectProvider($Alias_11d48426430.java)
        at org.apache.tapestry5.services.TapestryModule$1.provide(TapestryModule.java:556)
        at org.apache.tapestry5.ioc.internal.services.MasterObjectProviderImpl.provide(MasterObjectProviderImpl.java:38)
        at $MasterObjectProvider_11d4842642d.provide($MasterObjectProvider_11d4842642d.java)
        at org.apache.tapestry5.ioc.internal.RegistryImpl.getObject(RegistryImpl.java:626)
        at org.apache.tapestry5.ioc.internal.RegistryImpl.getObject(RegistryImpl.java:733)
        at org.apache.tapestry5.ioc.internal.ObjectLocatorImpl.getObject(ObjectLocatorImpl.java:49)
        at org.apache.tapestry5.ioc.internal.util.InternalUtils.calculateParameterValue(InternalUtils.java:205)
        at org.apache.tapestry5.ioc.internal.util.InternalUtils.calculateParameters(InternalUtils.java:235)
        at org.apache.tapestry5.ioc.internal.ModuleImpl.constructModuleBuilder(ModuleImpl.java:337)
        at org.apache.tapestry5.ioc.internal.ModuleImpl.access$400(ModuleImpl.java:35)
        at org.apache.tapestry5.ioc.internal.ModuleImpl$3.run(ModuleImpl.java:274)
        at org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier$2.invoke(ConcurrentBarrier.java:198)
        at org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier$2.invoke(ConcurrentBarrier.java:196)
        at org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier.withWrite(ConcurrentBarrier.java:138)
        at org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier.withWrite(ConcurrentBarrier.java:204)
        at org.apache.tapestry5.ioc.internal.ModuleImpl$4.invoke(ModuleImpl.java:282)
        at org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier.withRead(ConcurrentBarrier.java:83)
        at org.apache.tapestry5.ioc.internal.ModuleImpl.getModuleBuilder(ModuleImpl.java:290)
        at org.apache.tapestry5.ioc.internal.ServiceResourcesImpl.getModuleBuilder(ServiceResourcesImpl.java:105)
        at org.apache.tapestry5.ioc.internal.ServiceBuilderMethodInvoker.createObject(ServiceBuilderMethodInvoker.java:59)
        at org.apache.tapestry5.ioc.internal.SingletonServiceLifecycle.createService(SingletonServiceLifecycle.java:29)
        at org.apache.tapestry5.ioc.internal.LifecycleWrappedServiceCreator.createObject(LifecycleWrappedServiceCreator.java:52)
        at org.apache.tapestry5.ioc.internal.InterceptorStackBuilder.createObject(InterceptorStackBuilder.java:50)
        at org.apache.tapestry5.ioc.internal.RecursiveServiceCreationCheckWrapper.createObject(RecursiveServiceCreationCheckWrapper.java:60)
        at org.apache.tapestry5.ioc.internal.services.JustInTimeObjectCreator.createObject(JustInTimeObjectCreator.java:65)
        at $ServletApplicationInitializer_11d4842642c.delegate($ServletApplicationInitializer_11d4842642c.java)
        at $ServletApplicationInitializer_11d4842642c.initializeApplication($ServletApplicationInitializer_11d4842642c.java)
        at org.apache.tapestry5.TapestryFilter.init(TapestryFilter.java:91)

        Show
        Hugo Palma added a comment - Before i used @InjectService the code didn't work, that's why i created this issue. In order for my use case to be implemented i need to inject services into the TypeCoercer configuration and AFAIK using the @InjectService is the only way to achieve that right now. Regarding the stack trace, no it's not. That stack trace is from a time when i was trying to inject the Logger into the contributeTypeCoercer. Here's the stack trace when the method looks like "public static void contributeTypeCoercer(Configuration<CoercionTuple> configuration, JSONObjectToProcessTypeCoercer jsonObjectToProcessTypeCoercer)": java.lang.RuntimeException: Error invoking constructor org.apache.tapestry5.ioc.internal.services.TypeCoercerImpl(Collection) (at TypeCoercerImpl.java:93) via org.apache.tapestry5.ioc.services.TapestryIOCModule.bind(ServiceBinder) (at TapestryIOCModule.java:38) (for service 'TypeCoercer'): Error invoking service contribution method pt.viaverde.ecm.classification.web.services.ClassificacaoModule.contributeTypeCoercer(Configuration, JSONObjectToProcessTypeCoercer): Exception constructing service 'Alias': Construction of service 'Alias' has failed due to recursion: the service depends on itself in some way. Please check org.apache.tapestry5.services.TapestryModule.buildAlias(Logger, String, AliasManager, Collection) (at TapestryModule.java:217) for references to another service that is itself dependent on service 'Alias'. at org.apache.tapestry5.ioc.internal.ConstructorServiceCreator.createObject(ConstructorServiceCreator.java:63) at org.apache.tapestry5.ioc.internal.SingletonServiceLifecycle.createService(SingletonServiceLifecycle.java:29) at org.apache.tapestry5.ioc.internal.LifecycleWrappedServiceCreator.createObject(LifecycleWrappedServiceCreator.java:52) at org.apache.tapestry5.ioc.internal.RecursiveServiceCreationCheckWrapper.createObject(RecursiveServiceCreationCheckWrapper.java:60) at org.apache.tapestry5.ioc.internal.services.JustInTimeObjectCreator.createObject(JustInTimeObjectCreator.java:65) at $TypeCoercer_11d4842642f.delegate($TypeCoercer_11d4842642f.java) at $TypeCoercer_11d4842642f.coerce($TypeCoercer_11d4842642f.java) at org.apache.tapestry5.ioc.internal.services.ValueObjectProvider.provide(ValueObjectProvider.java:58) at org.apache.tapestry5.ioc.internal.services.MasterObjectProviderImpl.provide(MasterObjectProviderImpl.java:38) at $MasterObjectProvider_11d4842642d.provide($MasterObjectProvider_11d4842642d.java) at org.apache.tapestry5.ioc.internal.RegistryImpl.getObject(RegistryImpl.java:626) at org.apache.tapestry5.ioc.internal.RegistryImpl.getObject(RegistryImpl.java:733) at org.apache.tapestry5.ioc.internal.ObjectLocatorImpl.getObject(ObjectLocatorImpl.java:49) at org.apache.tapestry5.ioc.internal.util.InternalUtils.calculateParameterValue(InternalUtils.java:205) at org.apache.tapestry5.ioc.internal.util.InternalUtils.calculateParameters(InternalUtils.java:235) at org.apache.tapestry5.ioc.internal.util.InternalUtils.calculateParametersForMethod(InternalUtils.java:214) at org.apache.tapestry5.ioc.internal.ServiceBuilderMethodInvoker.createObject(ServiceBuilderMethodInvoker.java:67) at org.apache.tapestry5.ioc.internal.ModuleImpl.create(ModuleImpl.java:233) at org.apache.tapestry5.ioc.internal.ModuleImpl.access$100(ModuleImpl.java:35) at org.apache.tapestry5.ioc.internal.ModuleImpl$1.invoke(ModuleImpl.java:168) at org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier.withWrite(ConcurrentBarrier.java:138) at org.apache.tapestry5.ioc.internal.ModuleImpl$2.invoke(ModuleImpl.java:185) at org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier.withRead(ConcurrentBarrier.java:83) at org.apache.tapestry5.ioc.internal.ModuleImpl.findOrCreate(ModuleImpl.java:192) at org.apache.tapestry5.ioc.internal.ModuleImpl.getService(ModuleImpl.java:89) at org.apache.tapestry5.ioc.internal.RegistryImpl.getService(RegistryImpl.java:303) at org.apache.tapestry5.ioc.internal.RegistryImpl.findServiceByMarkerAndType(RegistryImpl.java:684) at org.apache.tapestry5.ioc.internal.RegistryImpl.getObject(RegistryImpl.java:619) at org.apache.tapestry5.ioc.internal.RegistryImpl.getObject(RegistryImpl.java:733) at org.apache.tapestry5.ioc.internal.ObjectLocatorImpl.getObject(ObjectLocatorImpl.java:49) at org.apache.tapestry5.ioc.internal.util.InternalUtils.calculateParameterValue(InternalUtils.java:205) at org.apache.tapestry5.ioc.internal.util.InternalUtils.calculateParameters(InternalUtils.java:235) at org.apache.tapestry5.ioc.internal.util.InternalUtils.calculateParametersForMethod(InternalUtils.java:214) at org.apache.tapestry5.ioc.internal.ContributionDefImpl.invokeMethod(ContributionDefImpl.java:90) at org.apache.tapestry5.ioc.internal.ContributionDefImpl.contribute(ContributionDefImpl.java:56) at org.apache.tapestry5.ioc.internal.RegistryImpl.addToUnorderedConfiguration(RegistryImpl.java:481) at org.apache.tapestry5.ioc.internal.RegistryImpl.getUnorderedConfiguration(RegistryImpl.java:355) at org.apache.tapestry5.ioc.internal.ServiceResourcesImpl.getUnorderedConfiguration(ServiceResourcesImpl.java:72) at org.apache.tapestry5.ioc.internal.AbstractServiceCreator.addUnorderedConfigurationParameter(AbstractServiceCreator.java:140) at org.apache.tapestry5.ioc.internal.AbstractServiceCreator.getParameterDefaultsWithConfiguration(AbstractServiceCreator.java:106) at org.apache.tapestry5.ioc.internal.ServiceBuilderMethodInvoker.getParameterDefaultsWithConfigurations(ServiceBuilderMethodInvoker.java:46) at org.apache.tapestry5.ioc.internal.ServiceBuilderMethodInvoker.createObject(ServiceBuilderMethodInvoker.java:67) at org.apache.tapestry5.ioc.internal.SingletonServiceLifecycle.createService(SingletonServiceLifecycle.java:29) at org.apache.tapestry5.ioc.internal.LifecycleWrappedServiceCreator.createObject(LifecycleWrappedServiceCreator.java:52) at org.apache.tapestry5.ioc.internal.InterceptorStackBuilder.createObject(InterceptorStackBuilder.java:50) at org.apache.tapestry5.ioc.internal.RecursiveServiceCreationCheckWrapper.createObject(RecursiveServiceCreationCheckWrapper.java:60) at org.apache.tapestry5.ioc.internal.services.JustInTimeObjectCreator.createObject(JustInTimeObjectCreator.java:65) at $Alias_11d48426430.delegate($Alias_11d48426430.java) at $Alias_11d48426430.getObjectProvider($Alias_11d48426430.java) at org.apache.tapestry5.services.TapestryModule$1.provide(TapestryModule.java:556) at org.apache.tapestry5.ioc.internal.services.MasterObjectProviderImpl.provide(MasterObjectProviderImpl.java:38) at $MasterObjectProvider_11d4842642d.provide($MasterObjectProvider_11d4842642d.java) at org.apache.tapestry5.ioc.internal.RegistryImpl.getObject(RegistryImpl.java:626) at org.apache.tapestry5.ioc.internal.RegistryImpl.getObject(RegistryImpl.java:733) at org.apache.tapestry5.ioc.internal.ObjectLocatorImpl.getObject(ObjectLocatorImpl.java:49) at org.apache.tapestry5.ioc.internal.util.InternalUtils.calculateParameterValue(InternalUtils.java:205) at org.apache.tapestry5.ioc.internal.util.InternalUtils.calculateParameters(InternalUtils.java:235) at org.apache.tapestry5.ioc.internal.ModuleImpl.constructModuleBuilder(ModuleImpl.java:337) at org.apache.tapestry5.ioc.internal.ModuleImpl.access$400(ModuleImpl.java:35) at org.apache.tapestry5.ioc.internal.ModuleImpl$3.run(ModuleImpl.java:274) at org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier$2.invoke(ConcurrentBarrier.java:198) at org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier$2.invoke(ConcurrentBarrier.java:196) at org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier.withWrite(ConcurrentBarrier.java:138) at org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier.withWrite(ConcurrentBarrier.java:204) at org.apache.tapestry5.ioc.internal.ModuleImpl$4.invoke(ModuleImpl.java:282) at org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier.withRead(ConcurrentBarrier.java:83) at org.apache.tapestry5.ioc.internal.ModuleImpl.getModuleBuilder(ModuleImpl.java:290) at org.apache.tapestry5.ioc.internal.ServiceResourcesImpl.getModuleBuilder(ServiceResourcesImpl.java:105) at org.apache.tapestry5.ioc.internal.ServiceBuilderMethodInvoker.createObject(ServiceBuilderMethodInvoker.java:59) at org.apache.tapestry5.ioc.internal.SingletonServiceLifecycle.createService(SingletonServiceLifecycle.java:29) at org.apache.tapestry5.ioc.internal.LifecycleWrappedServiceCreator.createObject(LifecycleWrappedServiceCreator.java:52) at org.apache.tapestry5.ioc.internal.InterceptorStackBuilder.createObject(InterceptorStackBuilder.java:50) at org.apache.tapestry5.ioc.internal.RecursiveServiceCreationCheckWrapper.createObject(RecursiveServiceCreationCheckWrapper.java:60) at org.apache.tapestry5.ioc.internal.services.JustInTimeObjectCreator.createObject(JustInTimeObjectCreator.java:65) at $ServletApplicationInitializer_11d4842642c.delegate($ServletApplicationInitializer_11d4842642c.java) at $ServletApplicationInitializer_11d4842642c.initializeApplication($ServletApplicationInitializer_11d4842642c.java) at org.apache.tapestry5.TapestryFilter.init(TapestryFilter.java:91)
        Hide
        Howard M. Lewis Ship added a comment -

        I've recently documented much more about injection:

        http://tapestry.formos.com/nightly/tapestry5/tapestry-ioc/injection.html

        which gives some insight into how this happens and how to avoid it.

        Show
        Howard M. Lewis Ship added a comment - I've recently documented much more about injection: http://tapestry.formos.com/nightly/tapestry5/tapestry-ioc/injection.html which gives some insight into how this happens and how to avoid it.
        Howard M. Lewis Ship made changes -
        Field Original Value New Value
        Assignee Howard M. Lewis Ship [ hlship ]
        Howard M. Lewis Ship made changes -
        Status Open [ 1 ] In Progress [ 3 ]
        Hide
        Howard M. Lewis Ship added a comment -

        So there isn't an easy way to eliminate this problem, but between the better docs and the new and much, much improved exception reporting (which now identifies, in the log, a stack of operations leading up to the failure), diagnosing these in the future should be much easier.

        Show
        Howard M. Lewis Ship added a comment - So there isn't an easy way to eliminate this problem, but between the better docs and the new and much, much improved exception reporting (which now identifies, in the log, a stack of operations leading up to the failure), diagnosing these in the future should be much easier.
        Hide
        Hugo Palma added a comment -

        Ok, fair enough

        Show
        Hugo Palma added a comment - Ok, fair enough
        Howard M. Lewis Ship made changes -
        Resolution Fixed [ 1 ]
        Fix Version/s 5.0.16 [ 12313427 ]
        Status In Progress [ 3 ] Closed [ 6 ]

          People

          • Assignee:
            Howard M. Lewis Ship
            Reporter:
            Hugo Palma
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development