You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Michael Prescott <mi...@gmail.com> on 2013/03/28 21:21:15 UTC

ServiceOverride IoC recursion exception

Just spent a painful afternoon learning something - if you specify no
system properties, Tapestry will fail to initialize if you provide a:

contributeApplicationDefaults(MappedConfiguration<String, String>
configuration)


..method in your TapestryModule.  The symptom is the dreaded recursive
definition exception:

Caused by: org.apache.tapestry5.ioc.internal.OperationException:
Construction of service 'ServiceOverride' has failed due to recursion: the
service depends on itself in some way. Please check
org.apache.tapestry5.ioc.internal.services.ServiceOverrideImpl(Map) (at
ServiceOverrideImpl.java:31) via
org.apache.tapestry5.ioc.services.TapestryIOCModule.bind(ServiceBinder) (at
TapestryIOCModule.java:49) for references to another service that is itself
dependent on service 'ServiceOverride'.

I'm the first to say that Tapestry IoC is all magic and rainbows to me, but
I suspect that's because without any system properties whatsoever, there's
no application default doodad created for my tapestry module to contribute
to.  Is that correct?

Gratefully,

Michael

Re: ServiceOverride IoC recursion exception

Posted by Ivan Khalopik <ik...@gmail.com>.
And the third option is to play with ApplicationDefaults,
FactoryDefaults, e.g. ApplicationDefaults has no service dependencies,
tapestr.production-mode symbol should be configured here,
FactoryDefaults can depend on your services.

On Fri, Mar 29, 2013 at 11:11 AM, Ivan Khalopik <ik...@gmail.com> wrote:
> Had the same issue when tried to use some service inside
> SymbolProvider contribution. E.g.
>
>     @ApplicationDefaults
>     @Contribute(SymbolProvider.class)
>     public void contributeApplicationDefaults(final
> MappedConfiguration<String, String> configuration, final MyService
> myService) {
>         configuration.add("test", "test");
>     }
>
>     public MyService buildMyService() {
>         return new MyService() {};
>     }
>
> Precondition: tapestry.production-mode symbol should not be specified
> in web.xml or sytem properties.
>
> This error ocurs because of this lines of code(TapestryModule):
>
>     /**
>      * In production mode, override {@link UpdateListenerHub} to be an
> empty placeholder.
>      */
>     @Contribute(ServiceOverride.class)
>     public static void
> productionModeOverrides(MappedConfiguration<Class, Object>
> configuration,
>
> @Symbol(SymbolConstants.PRODUCTION_MODE)
>                                                boolean productionMode)
>     {
>         if (productionMode)
>         {
>             configuration.add(UpdateListenerHub.class, new UpdateListenerHub()
>             {
>                 public void fireCheckForUpdates()
>                 {
>                 }
>
>                 public void addUpdateListener(UpdateListener listener)
>                 {
>
>                 }
>             });
>         }
>     }
>
> So MyService depends on ServiceOverride, ServiceOverride depends on
> tapestry.production-mode symbol, it depends on
> SymbolProviders(SystemProperties,EnvironmentVariables,ServletContext,ApplicationDefaults,FactoryDefaults).
> If there is no configured tapestry.production-mode symbol within
> SystemProperties,ServletContext symbol providers it will depend on
> ApplicationDefaults that depends on MyService. As result cycle
> dependency:
>
> ServiceOverride=>(tapestry.production-mode
> symbol)=>ApplicatioDefaults=>MyService=>ServiceOverride
>
> To fix this problem you can do one of the following:
> 1. configure tapestry.production-mode inside web.xml or in system properties
> 2. design your app to not use services in SymbolProviders contribution
>
> On Thu, Mar 28, 2013 at 11:21 PM, Michael Prescott
> <mi...@gmail.com> wrote:
>> Just spent a painful afternoon learning something - if you specify no
>> system properties, Tapestry will fail to initialize if you provide a:
>>
>> contributeApplicationDefaults(MappedConfiguration<String, String>
>> configuration)
>>
>>
>> ..method in your TapestryModule.  The symptom is the dreaded recursive
>> definition exception:
>>
>> Caused by: org.apache.tapestry5.ioc.internal.OperationException:
>> Construction of service 'ServiceOverride' has failed due to recursion: the
>> service depends on itself in some way. Please check
>> org.apache.tapestry5.ioc.internal.services.ServiceOverrideImpl(Map) (at
>> ServiceOverrideImpl.java:31) via
>> org.apache.tapestry5.ioc.services.TapestryIOCModule.bind(ServiceBinder) (at
>> TapestryIOCModule.java:49) for references to another service that is itself
>> dependent on service 'ServiceOverride'.
>>
>> I'm the first to say that Tapestry IoC is all magic and rainbows to me, but
>> I suspect that's because without any system properties whatsoever, there's
>> no application default doodad created for my tapestry module to contribute
>> to.  Is that correct?
>>
>> Gratefully,
>>
>> Michael
>
>
>
> --
> BR
> Ivan



-- 
BR
Ivan

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: ServiceOverride IoC recursion exception

Posted by Ivan Khalopik <ik...@gmail.com>.
Had the same issue when tried to use some service inside
SymbolProvider contribution. E.g.

    @ApplicationDefaults
    @Contribute(SymbolProvider.class)
    public void contributeApplicationDefaults(final
MappedConfiguration<String, String> configuration, final MyService
myService) {
        configuration.add("test", "test");
    }

    public MyService buildMyService() {
        return new MyService() {};
    }

Precondition: tapestry.production-mode symbol should not be specified
in web.xml or sytem properties.

This error ocurs because of this lines of code(TapestryModule):

    /**
     * In production mode, override {@link UpdateListenerHub} to be an
empty placeholder.
     */
    @Contribute(ServiceOverride.class)
    public static void
productionModeOverrides(MappedConfiguration<Class, Object>
configuration,

@Symbol(SymbolConstants.PRODUCTION_MODE)
                                               boolean productionMode)
    {
        if (productionMode)
        {
            configuration.add(UpdateListenerHub.class, new UpdateListenerHub()
            {
                public void fireCheckForUpdates()
                {
                }

                public void addUpdateListener(UpdateListener listener)
                {

                }
            });
        }
    }

So MyService depends on ServiceOverride, ServiceOverride depends on
tapestry.production-mode symbol, it depends on
SymbolProviders(SystemProperties,EnvironmentVariables,ServletContext,ApplicationDefaults,FactoryDefaults).
If there is no configured tapestry.production-mode symbol within
SystemProperties,ServletContext symbol providers it will depend on
ApplicationDefaults that depends on MyService. As result cycle
dependency:

ServiceOverride=>(tapestry.production-mode
symbol)=>ApplicatioDefaults=>MyService=>ServiceOverride

To fix this problem you can do one of the following:
1. configure tapestry.production-mode inside web.xml or in system properties
2. design your app to not use services in SymbolProviders contribution

On Thu, Mar 28, 2013 at 11:21 PM, Michael Prescott
<mi...@gmail.com> wrote:
> Just spent a painful afternoon learning something - if you specify no
> system properties, Tapestry will fail to initialize if you provide a:
>
> contributeApplicationDefaults(MappedConfiguration<String, String>
> configuration)
>
>
> ..method in your TapestryModule.  The symptom is the dreaded recursive
> definition exception:
>
> Caused by: org.apache.tapestry5.ioc.internal.OperationException:
> Construction of service 'ServiceOverride' has failed due to recursion: the
> service depends on itself in some way. Please check
> org.apache.tapestry5.ioc.internal.services.ServiceOverrideImpl(Map) (at
> ServiceOverrideImpl.java:31) via
> org.apache.tapestry5.ioc.services.TapestryIOCModule.bind(ServiceBinder) (at
> TapestryIOCModule.java:49) for references to another service that is itself
> dependent on service 'ServiceOverride'.
>
> I'm the first to say that Tapestry IoC is all magic and rainbows to me, but
> I suspect that's because without any system properties whatsoever, there's
> no application default doodad created for my tapestry module to contribute
> to.  Is that correct?
>
> Gratefully,
>
> Michael



-- 
BR
Ivan

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org