-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: ValidatorMessages
PostPosted: Mon Mar 20, 2006 8:16 am 
Newbie

Joined: Mon Mar 20, 2006 8:07 am
Posts: 4
Hibernate version:

JBoss AS 4.0.4RC1

Mapping documents:

N/A

Code between sessionFactory.openSession() and session.close():

N/A

Full stack trace of any exception that occurs:

Code:
2006-03-17 15:26:03,882 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/sms]] Exception sending context initialized event to listener instance of class org
.jboss.seam.servlet.SeamListener
java.lang.IllegalArgumentException: could not instantiate ClassValidator
        at org.hibernate.validator.ClassValidator.createValidator(ClassValidator.java:204)
        at org.hibernate.validator.ClassValidator.createMemberValidator(ClassValidator.java:165)
        at org.hibernate.validator.ClassValidator.initValidator(ClassValidator.java:134)
        at org.hibernate.validator.ClassValidator.<init>(ClassValidator.java:83)
        at org.hibernate.validator.ClassValidator.createChildValidator(ClassValidator.java:156)
        at org.hibernate.validator.ClassValidator.initValidator(ClassValidator.java:136)
        at org.hibernate.validator.ClassValidator.<init>(ClassValidator.java:83)
        at org.hibernate.validator.ClassValidator.createChildValidator(ClassValidator.java:156)
        at org.hibernate.validator.ClassValidator.initValidator(ClassValidator.java:136)
        at org.hibernate.validator.ClassValidator.<init>(ClassValidator.java:83)
        at org.hibernate.validator.ClassValidator.createChildValidator(ClassValidator.java:156)
        at org.hibernate.validator.ClassValidator.initValidator(ClassValidator.java:136)
        at org.hibernate.validator.ClassValidator.<init>(ClassValidator.java:83)
        at org.hibernate.validator.ClassValidator.<init>(ClassValidator.java:72)
        at org.hibernate.validator.ClassValidator.<init>(ClassValidator.java:64)
        at org.jboss.seam.Component.initValidator(Component.java:214)
        at org.jboss.seam.Component.<init>(Component.java:185)
        at org.jboss.seam.Component.<init>(Component.java:142)
        at org.jboss.seam.Component.<init>(Component.java:137)
        at org.jboss.seam.Component.<init>(Component.java:132)
        at org.jboss.seam.init.Initialization.addComponent(Initialization.java:244)
        at org.jboss.seam.init.Initialization.addComponents(Initialization.java:225)
        at org.jboss.seam.init.Initialization.init(Initialization.java:93)
        at org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:30)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3692)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4127)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.apache.commons.modeler.BaseModelMBean.invoke(BaseModelMBean.java:503)
        at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
        at org.apache.catalina.core.StandardContext.init(StandardContext.java:5031)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.apache.commons.modeler.BaseModelMBean.invoke(BaseModelMBean.java:503)
        at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
        at org.jboss.web.tomcat.tc5.TomcatDeployer.performDeployInternal(TomcatDeployer.java:297)
        at org.jboss.web.tomcat.tc5.TomcatDeployer.performDeploy(TomcatDeployer.java:103)
        at org.jboss.web.AbstractWebDeployer.start(AbstractWebDeployer.java:371)
        at org.jboss.web.WebModule.startModule(WebModule.java:83)
        at org.jboss.web.WebModule.startService(WebModule.java:61)
        at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
        at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
        at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:260)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
        at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:974)
        at $Proxy0.start(Unknown Source)
        at org.jboss.system.ServiceController.start(ServiceController.java:417)
        at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:260)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
        at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:190)
        at $Proxy30.start(Unknown Source)
        at org.jboss.web.AbstractWebContainer.start(AbstractWebContainer.java:469)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
        at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
        at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
        at org.jboss.mx.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java:97)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:260)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
        at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:190)
        at $Proxy31.start(Unknown Source)
        at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1007)
        at org.jboss.deployment.MainDeployer.start(MainDeployer.java:997)
        at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:808)
        at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:771)
        at sun.reflect.GeneratedMethodAccessor14.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
        at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
        at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:260)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
        at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:190)
        at $Proxy6.deploy(Unknown Source)
        at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:334)
        at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:504)
        at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:207)
        at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:218)
        at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:197)
Caused by: java.util.MissingResourceException: Can't find resource for bundle java.util.PropertyResourceBundle, key postcode
        at java.util.ResourceBundle.getObject(ResourceBundle.java:325)
        at java.util.ResourceBundle.getString(ResourceBundle.java:285)
        at org.hibernate.validator.ClassValidator.replace(ClassValidator.java:404)
        at org.hibernate.validator.ClassValidator.createValidator(ClassValidator.java:199)
        ... 109 more


Name and version of the database you are using:

MySQL 4.1.14

The generated SQL (show_sql=true):

N/A

I'm trying to get custom validator messages working.

I have

sms.ear
--> sms.jar
--> ValidatorMessages.properties
...
--> sms.war
...

When I deploy the ear to Jboss 4.0.4RC1 an exception is thrown complaining that the key postcode cannot be found however executing

Code:
ResourceBundle rb = ResourceBundle.getBundle("ValidatorMessages");
log.info(rb.getString("postcode"));


retrieves the key fine.

I infer that when the ClassValidator is trying to load the ResourceBundle it cannot find it. Can anyone tell me where I should be placing the ValidatorMessages.properties file?

Cheers

Peter


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 23, 2006 8:50 am 
Beginner
Beginner

Joined: Wed Aug 24, 2005 5:32 am
Posts: 23
Hi Peter,
I believe that the problem is in class loaders hierarchy. When using JBoss Hibernate classes are loaded from JBoss, not from your ear. It means that when Hibernate tries to find the resource bundle (in the ClassValidator class) is starts the search from the class loader which defined the ClassValidator, this class loader can't see your resources, it is too high in the hierarchy.

I took a look atHibernate's code, and it works as I suspect:
Code:
   private ResourceBundle getDefaultResourceBundle() {
      ResourceBundle rb;
      try {
         rb = ResourceBundle.getBundle( "ValidatorMessages" );
      }
      catch( MissingResourceException e) {
         //the user did not override the default ValidatorMessages
         log.debug( "ResourceBundle ValidatorMessages not found. Delegate to " + DEFAULT_VALIDATOR_MESSAGE);
         rb = ResourceBundle.getBundle( DEFAULT_VALIDATOR_MESSAGE );
      }
      defaultResourceBundle = true;
      return rb;
   }


I think that Hibernate should access the ResourceBundle using a specific classloader (maybe the Thread's context class loader).

Eyal Lupu


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 23, 2006 8:59 am 
Newbie

Joined: Mon Mar 20, 2006 8:07 am
Posts: 4
Dear Eyall

Thanks for the help. As a work around I've unpacked and modified the default messages in the hibernate-annotations.jar - very ugly solution!

For the record see also epbernards response in the JBoss Seam forum: http://www.jboss.com/index.html?module=bb&op=viewtopic&t=79422

Best

Peter


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 25, 2006 9:03 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
This is a bug fixed in SVN

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.