On 25. juni 2010, at 17.53, Scott Ferguson wrote: > Do you have any idea why the default would be working differently on > Resin? That library code shouldn't be directly dependent on Resin (we > don't provide anything like a TraversableResolver), but it's possible > that some classloader methods like ClassLoader.getResource are behaving > differently.
Hi! Thanks for asking :) The TraversableResolver.isReachable has the following javadoc: "Determine if the Bean Validation provider is allowed to reach the property state" The default validation.xml which comes with HibernateValidator 4.0.2 contains the following line: <traversable-resolver>org.hibernate.validator.engine.resolver.DefaultTraversableResolver</traversable-resolver> and this class has the following method: public boolean isReachable(Object traversableObject, Path.Node traversableProperty, Class<?> rootBeanType, Path pathToTraversableObject, ElementType elementType) { return jpaTraversableResolver == null || jpaTraversableResolver.isReachable( traversableObject, traversableProperty, rootBeanType, pathToTraversableObject, elementType ); } You can find the full sourcecode of this class at http://bit.ly/bnQId6 and see how it obtains its jpaTraversableResolver. So, when running under jetty jpaTraversableResolver is null and isReachable is returning true and we get all our attributes validated. Good :) But... now I come to the part where I'm mostly guessing, when running under resin we have a jpaTraversableResolver in which isReachable seems to return false which cause our attributes to not get validated. We are not using JPA in the application I'm working on now, but still when running under resin we have a javax.persistence.PersistenceUtil class in the classpath and DefaultTraversableResolver thinks we are running JPA. We have another project which uses JPA and it seems to have the same problem with not getting attributes validated. When DefaultTraversableResolver thinks we are using JPA it delegates to org.hibernate.validator.engine.resolver.JPATraversableResolver to check if an object is reachable. It seems to be something strange in the way JPATraversableResolver figures out if attributes is reachable or not since we don't get our attributes validated even in projects using JPA. JPATraversableResolver uses the following code: public boolean isReachable(Object traversableObject, Path.Node traversableProperty, Class<?> rootBeanType, Path pathToTraversableObject, ElementType elementType) { return traversableObject == null || Persistence.getPersistenceUtil().isLoaded( traversableObject, traversableProperty.getName() ); } (from http://bit.ly/apHvnZ) Since my project does not use JPA and the workaround with adding our own TraversableResolver implementation to our validation.xml files solves this issue for us, I haven't does any more digging into this. I guess there is two possible problems here: 1) DefaultTraversableResolver should have had a better way of detecting if we use JPA or not (other than looking for avax.persistence.PersistenceUtil in the classpath). 2) In our projects using JPA the JPATraversableResolver.isReachable is returning false when it shouldn't. That might be a configuration or other problem on our side since this seems to work ok for others out there. Anyway... both issues are related to HibernateValidator and we have a workaround for our issue. Great! ;-) -Kaj :) _______________________________________________ resin-interest mailing list resin-interest@caucho.com http://maillist.caucho.com/mailman/listinfo/resin-interest