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
<michael.r.presc...@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-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to