GWT 找不到我的 persistence.xml
我正在尝试在我的 jpa hibernate 数据库中保存一个简单的用户。 所以我有一个 persistence.xml,我知道它可以工作(如果我在不部署 gwt 应用程序的情况下执行一个简单的测试)。
问题是,当我用用户界面测试它时,持久方法会抛出下一个错误:(我认为这是因为找不到 persistence.xml)
[错误] javax.persistence.PersistenceException:[PersistenceUnit:isw2.tasks] 无法>配置 EntityManagerFactory
...啦啦啦
[错误]引起:org.hibernate.HibernateException:无法获取默认 Bean >验证工厂
...更多啦啦啦..
[错误]引起的:java.lang.reflect.InitationTargetException
... [错误]引起:org.hibernate.HibernateException:无法构建默认的ValidatorFactory
在 org.hibernate.cfg.beanvalidation.TypeSafeActivator.getValidatorFactory(TypeSafeActivator.java:383)
[错误] 处 构建默认的 ValidatorFactory [错误] org.hibernate.cfg.beanvalidation.TypeSafeActivator.applyDDL(TypeSafeActivator.java:109)
.....
[错误] 引起:javax.validation.ValidationException:无法
在 javax.validation.Validation 找到默认提供程序 [错误] $GenericBootstrapImpl.configure(Validation.java:264)
[错误] 位于javax.validation.Validation.buildDefaultValidatorFactory(Validation.java:111)
[错误] 在 org.hibernate.cfg.beanvalidation.TypeSafeActivator.getValidatorFactory(TypeSafeActivator.ja
这是我知道有效的方法:
`EntityManagerFactory emf = Persistence .createEntityManagerFactory("isw2.tasks"); em = emf.createEntityManager();
em.getTransaction().begin();
em.persist(u);
em.getTransaction().commit();
em.clear();
em.close();
`
对我们来说最有用的是我的项目框架:(看到 persistence.xml 文件就在那里!)
我正在使用 Maven 并使用 codehaus 插件部署 Web 应用程序。
预先感谢专家;)
I´m trying to save a simple user in my jpa hibernate db.
So I have a persistence.xml that I know that works (If I execute a simple test without deploying the gwt app).
The problem is that when I test it with my user interface, the persist method throw me the next error: (I think this is cause Doesn´t find the persistence.xml)
[ERROR] javax.persistence.PersistenceException: [PersistenceUnit: isw2.tasks] Unable to >configure EntityManagerFactory
... bla bla bla
[ERROR] Caused by: org.hibernate.HibernateException: Unable to get the default Bean >Validation factory
... more bla bla bla..
[ERROR] Caused by: java.lang.reflect.InvocationTargetException
...
[ERROR] Caused by: org.hibernate.HibernateException: Unable to build the default ValidatorFactory
[ERROR] at org.hibernate.cfg.beanvalidation.TypeSafeActivator.getValidatorFactory(TypeSafeActivator.java:383)
[ERROR] at org.hibernate.cfg.beanvalidation.TypeSafeActivator.applyDDL(TypeSafeActivator.java:109)
.....
[ERROR] Caused by: javax.validation.ValidationException: Unable to find a default provider
[ERROR] at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:264)
[ERROR] at javax.validation.Validation.buildDefaultValidatorFactory(Validation.java:111)
[ERROR] at org.hibernate.cfg.beanvalidation.TypeSafeActivator.getValidatorFactory(TypeSafeActivator.ja
This is the method I know that works:
`EntityManagerFactory emf = Persistence
.createEntityManagerFactory("isw2.tasks");
em = emf.createEntityManager();
em.getTransaction().begin();
em.persist(u);
em.getTransaction().commit();
em.clear();
em.close();
`
And the most usefull for us, my proyect skeleton: (See that the persistence.xml file is there!)
I´m using maven and deploying the web app with the codehaus plugin.
Thanks in advance experts ;)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
异常消息
无法找到默认提供程序
表明hibernate无法找到验证提供程序。您的 Hibernate Validator jar 是否位于运行时类路径中?另请注意,您需要使用 Hibernate Validator 4 或更高版本。
The exception message
Unable to find a default provider
suggests that hibernate cannot find a validation provider.Is your Hibernate Validator jar on your runtime classpath? Also do note that you need to use Hibernate Validator 4 or later.