Hi folks,
I'm currently experiencing some problems when I try to use my custom propertie file, respectively resource bundle for the Hibernate validators. The problems that occur concern the Hibernate Tool:
First on the <annotationconfiguration> the full qualified filename must be set for the propertie file/resource bundle, like "myproperties_en.properties". So here it is not really possible to specifiy a real resource bundle where I just can pass the base file name (here: "myproperties.properties").
Second is, when I add an Hibernate validator for a property like this:
Code:
@Length(min = 2, max = 30, message = "{err.msg.length}")
private String name;
And then try to generate the database schema using the Hibernate Tool ant task <hbm2ddl> following error occurs:
Code:
java.lang.IllegalArgumentException: could not instantiate ClassValidator
at org.apache.tools.ant.Task.perform(Task.java:373)
at org.apache.commons.jelly.tags.ant.AntTag.doTag(AntTag.java:195)
at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:247)
at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
at org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:186)
at org.apache.commons.jelly.tags.util.AvailableTag.doTag(AvailableTag.java:68)
at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:247)
at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
at org.apache.maven.jelly.tags.werkz.MavenGoalTag.runBodyTag(MavenGoalTag.java:78)
at org.apache.maven.jelly.tags.werkz.MavenGoalTag$MavenGoalAction.performAction(MavenGoalTag.java:109)
at org.apache.maven.werkz.Goal.fire(Goal.java:656)
at org.apache.maven.werkz.Goal.attain(Goal.java:592)
at org.apache.maven.werkz.WerkzProject.attainGoal(WerkzProject.java:210)
at org.apache.maven.jelly.tags.werkz.MavenAttainGoalTag.doTag(MavenAttainGoalTag.java:114)
at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:247)
at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
at org.apache.maven.jelly.tags.werkz.MavenGoalTag.runBodyTag(MavenGoalTag.java:78)
at org.apache.maven.jelly.tags.werkz.MavenGoalTag$MavenGoalAction.performAction(MavenGoalTag.java:109)
at org.apache.maven.werkz.Goal.fire(Goal.java:656)
at org.apache.maven.werkz.Goal.attain(Goal.java:592)
at org.apache.maven.plugin.PluginManager.attainGoals(PluginManager.java:693)
at org.apache.maven.MavenSession.attainGoals(MavenSession.java:263)
at org.apache.maven.cli.App.doMain(App.java:511)
at org.apache.maven.cli.App.main(App.java:1258)
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 com.werken.forehead.Forehead.run(Forehead.java:551)
at com.werken.forehead.Forehead.main(Forehead.java:581)
Caused by: 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.<init>(ClassValidator.java:72)
at org.hibernate.validator.ClassValidator.<init>(ClassValidator.java:64)
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:669)
at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:276)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:210)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:996)
at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:56)
at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:179)
at org.hibernate.tool.ant.Hbm2DDLExporterTask.execute(Hbm2DDLExporterTask.java:43)
at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:143)
at org.apache.tools.ant.Task.perform(Task.java:364)
... 29 more
Caused by: java.util.MissingResourceException: Can't find resource for bundle java.util.PropertyResourceBundle, key err.msg.length
at java.util.ResourceBundle.getObject(ResourceBundle.java:325)
at java.util.ResourceBundle.getObject(ResourceBundle.java:322)
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)
... 46 more
The key definitely is set in the property file. So any suggestions how I could get <hbm2ddl> to work? Or is this some kind of bug?
Regards,
bitbyter
PS: Hope this is the right place for the posting.