我是Hibernate和Restful的新手。
我的RAD中有示例java项目(Hibernate java项目)。它能够运行我的Hibernate查询
我有另一个网络项目(Restful示例网站项目),它能够运行我的示例应用程序get和post。
我想在我的Web项目中集成Hibernate Java项目。我的想法是我想在Restful服务中发布我的样本hibernate。我的restful get服务调用我的hibernate模块并运行查询并将结果提供给最终用户。
我已经将Hibernate java项目作为web项目的参考,包括所有jar文件作为用户库,添加了部署程序集Hibernate项目和用户库。我尝试调用我的getSession方法来创建我的HibernateUtlity类对象。 IT给出了奇怪的例外。
Mar 11, 2015 6:11:17 AM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: /hibernate.cfg.xml
Mar 11, 2015 6:11:17 AM org.hibernate.cfg.Configuration doConfigure
INFO: Configured SessionFactory: null
Mar 11, 2015 6:11:17 AM org.hibernate.cfg.AnnotationBinder bindClass
INFO: Binding entity from annotated class: com.googlesvn.practice.examples.hibernate.ramaschi.sample.inheritance.curd.Account
Mar 11, 2015 6:11:18 AM org.hibernate.cfg.annotations.EntityBinder bindTable
INFO: Bind entity com.googlesvn.practice.examples.hibernate.ramaschi.sample.inheritance.curd.Account on table ACCOUNT
Mar 11, 2015 6:11:18 AM org.hibernate.cfg.Configuration applyHibernateValidatorLegacyConstraintsOnDDL
INFO: Hibernate Validator not found: ignoring
org.hibernate.HibernateException: Unable to get the default Bean Validation factory
at org.hibernate.cfg.beanvalidation.BeanValidationActivator.applyDDL(BeanValidationActivator.java:127)
at org.hibernate.cfg.Configuration.applyBeanValidationConstraintsOnDDL(Configuration.java:1704)
at org.hibernate.cfg.Configuration.applyConstraintsToDDL(Configuration.java:1654)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1445)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1856)
at com.googlesvn.practice.examples.hibernate.runner.HibernateUtilty.getHibernateSession(HibernateUtilty.java:17)
at com.googlesvn.practice.dao.interfaces.impl.DaoInterfaceImpl.getAccountDetails(DaoInterfaceImpl.java:17)
at com.googlesvn.practice.zdao.zhibernate.runner.HibernateRunner.main(HibernateRunner.java:14)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:611)
at org.hibernate.cfg.beanvalidation.BeanValidationActivator.applyDDL(BeanValidationActivator.java:118)
... 7 more
Caused by: org.hibernate.HibernateException: Unable to build the default ValidatorFactory
at org.hibernate.cfg.beanvalidation.TypeSafeActivator.getValidatorFactory(TypeSafeActivator.java:383)
at org.hibernate.cfg.beanvalidation.TypeSafeActivator.applyDDL(TypeSafeActivator.java:109)
... 12 more
Caused by: javax.validation.ValidationException: Could not create Configuration.
at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:175)
at javax.validation.Validation.buildDefaultValidatorFactory(Validation.java:50)
at org.hibernate.cfg.beanvalidation.TypeSafeActivator.getValidatorFactory(TypeSafeActivator.java:380)
... 13 more
Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.get(ArrayList.java:347)
at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:173)
... 15 more
java.lang.NullPointerException
at com.googlesvn.practice.dao.interfaces.impl.DaoInterfaceImpl.getAccountDetails(DaoInterfaceImpl.java:18)
at com.googlesvn.practice.zdao.zhibernate.runner.HibernateRunner.main(HibernateRunner.java:14)
仅供参考: - 我没有使用Springs,我使用Web sphere 8来运行我的Rest Web项目。
你能帮我解决这个问题。
提前致谢。
答案 0 :(得分:1)
谢谢你们的帮助。我找到了解决这个问题的方法。问题是我的Hibernate项目没有添加到我的Web项目maven构建中。一旦我将Hibernate项目作为依赖项添加到我的Web项目中。部署成功后。它的工作。我仍然不知道为什么它抛出Bean Validation异常。