HibernateException:无法获取默认的 Bean 验证工厂
我正在使用 hibernate Hibernate-Version: 3.2.5.ga。除此之外我正在使用 gwt2.3 版本。 现在,当我尝试升级 hibernate 版本时,出现错误。我已经下载了 hibernate 3.6.7 最终版本并替换了旧的 jar 文件。但是当我在第一台服务器上运行应用程序时,它给出了以下错误。如果我替换新的与旧罐子一起使用则没有问题...但对于新罐子则出现错误。 帮助我。提前致谢。
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.nextenders.facadeimplementation.hibernate.util.HibernateFactory.configureSessionFactory(HibernateFactory.java:107)
at com.nextenders.facadeimplementation.hibernate.util.HibernateFactory.buildIfNeeded(HibernateFactory.java:42)
at com.nextenders.facadeimplementation.model.dao.AbstractDao.<init>(AbstractDao.java:20)
at com.nextenders.facadeimplementation.model.dao.UserDetailsDao.<init>(UserDetailsDao.java:24)
at com.nextenders.facadeimplementation.facade.UserFacade.doLogin(UserFacade.java:753)
at com.nextenders.facadeimplementation.facade.UserFacade.workflowMethodCaller(UserFacade.java:822)
at com.nextenders.server.guice.actions.handlers.LoginCallerActionHandler.execute(LoginCallerActionHandler.java:61)
at com.nextenders.server.guice.actions.handlers.LoginCallerActionHandler.execute(LoginCallerActionHandler.java:1)
at com.gwtplatform.dispatch.server.AbstractDispatchImpl.doExecute(AbstractDispatchImpl.java:153)
at com.gwtplatform.dispatch.server.AbstractDispatchImpl.execute(AbstractDispatchImpl.java:111)
at com.gwtplatform.dispatch.server.AbstractDispatchServiceImpl.execute(AbstractDispatchServiceImpl.java:80)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:569)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:208)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:248)
at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at com.google.inject.servlet.ServletDefinition.doService(ServletDefinition.java:263)
at com.google.inject.servlet.ServletDefinition.service(ServletDefinition.java:178)
at com.google.inject.servlet.ManagedServletPipeline.service(ManagedServletPipeline.java:91)
at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:62)
at com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:118)
at com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:113)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1088)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:324)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
I am using hibernate Hibernate-Version: 3.2.5.ga.Along with this I am using gwt2.3 version.
Now when I tried to upgrade hibernate version, I am getting error.I have downloaded hibernate 3.6.7 final version and replaced it old jar file in.but when I run application on first server hit it is giving below error.If I replace new jar with old jar then there is no issue...but for new jar it is giving error.
help me out.Thanks in advance.
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.nextenders.facadeimplementation.hibernate.util.HibernateFactory.configureSessionFactory(HibernateFactory.java:107)
at com.nextenders.facadeimplementation.hibernate.util.HibernateFactory.buildIfNeeded(HibernateFactory.java:42)
at com.nextenders.facadeimplementation.model.dao.AbstractDao.<init>(AbstractDao.java:20)
at com.nextenders.facadeimplementation.model.dao.UserDetailsDao.<init>(UserDetailsDao.java:24)
at com.nextenders.facadeimplementation.facade.UserFacade.doLogin(UserFacade.java:753)
at com.nextenders.facadeimplementation.facade.UserFacade.workflowMethodCaller(UserFacade.java:822)
at com.nextenders.server.guice.actions.handlers.LoginCallerActionHandler.execute(LoginCallerActionHandler.java:61)
at com.nextenders.server.guice.actions.handlers.LoginCallerActionHandler.execute(LoginCallerActionHandler.java:1)
at com.gwtplatform.dispatch.server.AbstractDispatchImpl.doExecute(AbstractDispatchImpl.java:153)
at com.gwtplatform.dispatch.server.AbstractDispatchImpl.execute(AbstractDispatchImpl.java:111)
at com.gwtplatform.dispatch.server.AbstractDispatchServiceImpl.execute(AbstractDispatchServiceImpl.java:80)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:569)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:208)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:248)
at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at com.google.inject.servlet.ServletDefinition.doService(ServletDefinition.java:263)
at com.google.inject.servlet.ServletDefinition.service(ServletDefinition.java:178)
at com.google.inject.servlet.ManagedServletPipeline.service(ManagedServletPipeline.java:91)
at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:62)
at com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:118)
at com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:113)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1088)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:324)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
它无法访问 Bean 验证框架 (BeanValidationActivator) 请确保以下依赖项位于类路径或 pom.xml 中
It can't acceess Bean Validation Framework (BeanValidationActivator) Please make sure that the following dependency are in class path or in pom.xml
默认情况下,Hibernate 验证器设置为 auto,这意味着如果类路径中有验证器,它将尝试使用它。 GWT 2.3 和更新版本在 gwt-servlet.jar 中包含验证 api,因此 Hibernate 最终会使用部分验证器并失败。如果您不想使用 Hibernate 验证,只需在属性中将其关闭(hibernate.cfg.xml、hibernate.properties 或以编程方式)。
只需将
javax.persistence.validation.mode
设置为none
By default Hibernate validator is set to auto, meaning if there is a validator in the classpath it will try to use it. GWT 2.3 and newer versions include the validation api inside the gwt-servlet.jar, so Hibernate ends up with a parcial validator and fails. If you don't want to use Hibernate Validation just turn it off in your properties (hibernate.cfg.xml, hibernate.properties or programatically).
Simply set
javax.persistence.validation.mode
tonone
默认情况下,Hibernate 的验证器设置为 true,这意味着如果类路径中存在验证器,它将尝试使用它。 GWT 2.3 和更新版本在 gwt-servlet.jar 中包含验证 api,因此 Hibernate 最终会使用部分验证器并失败。如果您不想使用 Hibernate 验证,只需在属性中将其关闭(hibernate.cfg.xml、hibernate.properties 或以编程方式)。
例如:在 hibernate.cfg.xml 中将 hibernate 验证模式添加为 none
By default Hibernate's validator is set to true, meaning if there is a validator in the classpath it will try to use it. GWT 2.3 and newer versions include the validation api inside the gwt-servlet.jar, so Hibernate ends up with a parcial validator and fails. If you don't want to use Hibernate Validation just turn it off in your properties (hibernate.cfg.xml, hibernate.properties or programatically).
for example: in hibernate.cfg.xml add the hibernate validation mode to none
我遇到了同样的问题,但后来我添加了以下依赖项并且工作正常。
但请使用正确的版本。当我使用 5.1.3.Final 时,它一直失败,但后来我将版本更改为 4.2.0.Final 并且它有效。
I was having the same problem but then I added the below dependency and it worked fine.
But use the correct version. When I used 5.1.3.Final, it kept on failing but then I changed the version to 4.2.0.Final and it worked.
尝试删除 hibernate-validator-4.0.2.GA.jar 和 hibernate-validator-4.0.2.GA.jar验证-api-1.0.0.GA.jar
Try removing both the hibernate-validator-4.0.2.GA.jar & validation-api-1.0.0.GA.jar
您有 2 个选项:
1.- 您可以禁用 Hibernate 验证:
2.- 添加这些依赖项,如果您不使用 maven,则下载 jar 并手动添加到您的工件中:
You have 2 options:
1.- You could disable the Hibernate Validation:
2.- Add these dependencies, if you don't use maven then download the jars and add to your artifact manually:
这里的答案对 Maven 有帮助。我正在使用 Gradle,我发现我需要做的就是添加:
错误消失了,我的应用程序运行正常。
我不需要像其他答案提到的那样排除 javax 验证 jar 或更改持久性验证模式。
The answers here are helpful for Maven. I'm using Gradle and I found that all I needed to do was add:
And the error disappeared and my app functioned properly.
I did not need to exclude the javax validation jar or change the persistence validation mode as the other answers mentioned.