geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick McGuire <>
Subject Bean validation tck failures and JNDI contexts
Date Thu, 21 Oct 2010 11:48:01 GMT
We're down to 13 bean validation failures in the tck now, but these 
failures are a little puzzling.   The tests in error are all giving 
deploy failures, with the root cause being an exception triggered by 

java.lang.RuntimeException: javax.naming.NamingException: Validator [Root exception is javax.validation.ValidationException:
Unable to find suitable provider: class org.hibernate.jsr303.tck.common.TCKValidationProvider]
         at org.apache.xbean.naming.context.ContextUtil$ReadOnlyBinding.getObject(
         at org.apache.xbean.naming.context.ContextFederation.getFederatedBindings(
         at org.apache.xbean.naming.context.AbstractFederatedContext.getBindings(
         at org.apache.xbean.naming.context.AbstractFederatedContext.getBinding(
         at org.apache.xbean.naming.context.AbstractContext.lookup(
         at org.apache.xbean.naming.context.AbstractContext.lookup(
         at org.apache.geronimo.jetty8.handler.GeronimoWebAppContext.<init>(
         at org.apache.geronimo.jetty8.WebAppContextWrapper.<init>(
         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance(
         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
         at java.lang.reflect.Constructor.newInstance(
         at org.apache.xbean.recipe.ReflectionUtil$ConstructorFactory.create(
         at org.apache.xbean.recipe.ObjectRecipe.internalCreate(
         at org.apache.xbean.recipe.AbstractRecipe.create(
         at org.apache.xbean.recipe.AbstractRecipe.create(
         at org.apache.geronimo.gbean.runtime.GBeanInstance.createInstance(
         at org.apache.geronimo.gbean.runtime.GBeanInstanceState.attemptFullStart(
         at org.apache.geronimo.gbean.runtime.GBeanInstanceState.start(

The root cause of this failure is an exception in 

     public  Object  getContent()throws  NamingException  {
         ValidatorFactory  factory  =null;
         try  {
             factory  = (ValidatorFactory)new  InitialContext().lookup("java:comp/ValidatorFactory");
         }catch(NamingException  e) {
             factory  =Validation.buildDefaultValidatorFactory();
         return  factory.getValidator();

The root cause of this failure is the NamingException on the .lookup() 
call.  Since this occurs during the building of the federated context, I 
suspect the initial context is not initialized correctly at this phase.  
There's a bit of a chicken-and-egg problem here.  The 
buildDefaultValidatorFactory() call is failing because the incorrect 
thread context classloader is getting used to resolve the provider.

The puzzling piece to me is why this process is making the getContent() 
calls in the first place.  Since this binding will create a new instance 
each time it is requested, either A) an instance is getting created 
needlessly and thrown away or B) this instance is ending up bound to the 
JNDI context as a one-off, which would be an incorrect result.

I think I can fix this by making the DefaultValidatorReference look up 
the ValidatorFactoryGBean to obtain the factory used to create the 
ValidatorInstance rather than doing a jndi lookup, but I want to verify 
that the lookup occurring at this point is the correct behavior and 
there's not a better solution available.


View raw message