T5.3-rc-3: FieldTranslatorSource "sees" an overriden service

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

T5.3-rc-3: FieldTranslatorSource "sees" an overriden service

Michael Capper
Hi,
I've run into a problem when upgrading to T5.3-rc-3.
We used the contributeServiceOverride method to override the ComponentMessageSource service with an different implementation of ours.
After the switch to 5.3, the webapp (in jetty) starts, and a simple test page can be rendered, using our messages.
But when calling a page with a form (i.e. login form), the following exception occurs:
org.apache.tapestry5.internal.services.RenderQueueException
Render queue error in BeginRender[StartDefault:login.username]: Failure reading parameter 'translate' of component StartDefault:login.username: Exception constructing service 'FieldTranslatorSource': Service interface org.apache.tapestry5.services.messages.ComponentMessagesSource is matched by 2 services: OurComponentMessagesSourceImpl, ComponentMessagesSource. Automatic dependency resolution requires that exactly one service implement the interface.

org.apache.tapestry5.ioc.internal.util.TapestryException
Failure reading parameter 'translate' of component StartDefault:login.username: Exception constructing service 'FieldTranslatorSource': Service interface org.apache.tapestry5.services.messages.ComponentMessagesSource is matched by 2 services...

java.lang.RuntimeException
Exception constructing service 'FieldTranslatorSource': Service interface org.apache.tapestry5.services.messages.ComponentMessagesSource is matched by 2 services...

for the first FieldTranslatorSource in the first Text field

<t:TextField
15	t:id="username"
16	value="username"
17	size="10" />


I've seen such exceptions before when adding the same service twice, but these always were thrown before the webapp was ready.

Is this a bug?

Mike
Reply | Threaded
Open this post in threaded view
|

Re: T5.3-rc-3: FieldTranslatorSource "sees" an overriden service

Michael Capper
It seems that, when getting Messages from the MasterObjectProvider for a ComponentMessagesSource used "somewhere" for the translations in my Templates or Classes when Injecting the Messages, it finds the one bound in the AppModule and contributed to the ServiceOverride.
org.apache.tapestry5.ioc.internal.RegistryImpl.invoke(RegistryImpl.java:662)	
org.apache.tapestry5.ioc.internal.services.MasterObjectProviderImpl.provide(MasterObjectProviderImpl.java:56)
$MasterObjectProvider_125445e222bf5d52.provide(Unknown Source)
org.apache.tapestry5.ioc.internal.RegistryImpl.getObject(RegistryImpl.java:518)
org.apache.tapestry5.ioc.internal.ObjectLocatorImpl.getObject(ObjectLocatorImpl.java:57)
org.apache.tapestry5.ioc.internal.util.InternalUtils.calculateInjection(InternalUtils.java:228)

But when geting Messages from the MasterObjectProvider for a Messages, done so for the Constructor of FieldTranslatorSource, it gets both the original ComponentMessagesSource bound in the TapestryModule and the one from our AppModule.
org.apache.tapestry5.ioc.internal.RegistryImpl.getServiceByTypeAlone(RegistryImpl.java:1267)
org.apache.tapestry5.ioc.internal.RegistryImpl.getServiceByTypeAndMarkers(RegistryImpl.java:1284)
org.apache.tapestry5.ioc.internal.RegistryImpl.getService(RegistryImpl.java:575)
org.apache.tapestry5.ioc.internal.ObjectLocatorImpl.getService(ObjectLocatorImpl.java:47)
org.apache.tapestry5.internal.services.ApplicationMessageCatalogObjectProvider.getProxy(ApplicationMessageCatalogObjectProvider.java:85)

I've added a small workaround, overriding the RegistryImpl's findServiceIdsForInterface to only return our Service in this case, until I know how to properly do it.



Michael Capper wrote
Hi,
I've run into a problem when upgrading to T5.3-rc-3.
We used the contributeServiceOverride method to override the ComponentMessageSource service with an different implementation of ours.
After the switch to 5.3, the webapp (in jetty) starts, and a simple test page can be rendered, using our messages.
But when calling a page with a form (i.e. login form), the following exception occurs:
org.apache.tapestry5.internal.services.RenderQueueException
Render queue error in BeginRender[StartDefault:login.username]: Failure reading parameter 'translate' of component StartDefault:login.username: Exception constructing service 'FieldTranslatorSource': Service interface org.apache.tapestry5.services.messages.ComponentMessagesSource is matched by 2 services: OurComponentMessagesSourceImpl, ComponentMessagesSource. Automatic dependency resolution requires that exactly one service implement the interface.

org.apache.tapestry5.ioc.internal.util.TapestryException
Failure reading parameter 'translate' of component StartDefault:login.username: Exception constructing service 'FieldTranslatorSource': Service interface org.apache.tapestry5.services.messages.ComponentMessagesSource is matched by 2 services...

java.lang.RuntimeException
Exception constructing service 'FieldTranslatorSource': Service interface org.apache.tapestry5.services.messages.ComponentMessagesSource is matched by 2 services...

for the first FieldTranslatorSource in the first Text field

<t:TextField
15	t:id="username"
16	value="username"
17	size="10" />


I've seen such exceptions before when adding the same service twice, but these always were thrown before the webapp was ready.
Reply | Threaded
Open this post in threaded view
|

Re: T5.3-rc-3: FieldTranslatorSource "sees" an overriden service

Thiago H de Paula Figueiredo
In reply to this post by Michael Capper
On Tue, 08 Nov 2011 12:10:14 -0200, Michael Capper <[hidden email]>  
wrote:

> I've added a small workaround, overriding the RegistryImpl's
> findServiceIdsForInterface to only return our Service in this case,  
> until I know how to properly do it.

What about not declaring your service override as a service and using  
ObjectLocator.autobuild() to instantiate it?

--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]