You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Jun Tsai <ju...@gmail.com> on 2007/07/06 04:05:14 UTC
[T5] How to call hibernate session in TypeCoercer?
hi,
I want to add a TypeCoercer using tapestry-hibernate.
public static void contributeTypeCoercer(
Configuration<CoercionTuple> configuration,
@Inject
final Session session) {
Coercion<PersistModel, String> coercion1 = new
Coercion<PersistModel, String>() {
public String coerce(PersistModel input) {
return getEntityClass(input).getName()+ ":"
+ session.getIdentifier(input);
}
};
configuration.add(new CoercionTuple<PersistModel, String>(
PersistModel.class, String.class, coercion1));
Coercion<String,PersistModel> coercion2= new
Coercion<String,PersistModel>() {
public PersistModel coerce(String input) {
String [] strs=input.split(":");
return (PersistModel) session.get(strs[0],strs[1]);
}
};
configuration.add(new CoercionTuple< String,PersistModel>(
String.class, PersistModel.class, coercion2));
}
java.lang.RuntimeException: Exception constructing service
'ServletApplicationInitializer': Unable to instantiate class
org.apache.tapestry.services.TapestryModule as a module builder: Exception
constructing service 'Alias': Error invoking service builder method
org.apache.tapestry.services.TapestryModule.build(Log, String, AliasManager,
Collection) (at TapestryModule.java:249) (for service 'Alias'): Exception
constructing service 'TypeCoercer': Error invoking constructor
org.apache.tapestry.ioc.internal.services.TypeCoercerImpl(Collection) (at
TypeCoercerImpl.java:101) (for service 'TypeCoercer'): Error invoking
service contribution method
lichen.services.AppModule.contributeTypeCoercer(Configuration,
Session): 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.tapestry.services.TapestryModule.build(Log,
String, AliasManager, Collection) (at TapestryModule.java:249) for
references to another service that is itself dependent on service 'Alias'.
Session depends Alias ,and Alias depends TypeCoercer.
How to fix?
Thanks.
Jun Tsai
--
Welcome to China Java Users Group(CNJUG).
http://cnjug.dev.java.net
Re: [T5] How to call hibernate session in TypeCoercer?
Posted by Davor Hrg <hr...@gmail.com>.
TypeCoercer is at very core of tapestry,
Alias service also, so using @Inject
will fail when contributing to TypeCorcer,
use @InjectService instead @Inject:
public static void contributeTypeCoercer(
Configuration<CoercionTuple> configuration,
@InjectService("Session")
final Session session) {
Davor Hrg
On 7/6/07, Jun Tsai <ju...@gmail.com> wrote:
>
> or how to access the registry object in TypeCorercer?
>
>
>
> --
> Welcome to China Java Users Group(CNJUG).
> http://cnjug.dev.java.net
>
Re: [T5] How to call hibernate session in TypeCoercer?
Posted by Jun Tsai <ju...@gmail.com>.
or how to access the registry object in TypeCorercer?
--
Welcome to China Java Users Group(CNJUG).
http://cnjug.dev.java.net