HibernateException:无法获取默认Bean验证工厂

nfg76nw0  于 2023-11-21  发布在  其他
关注(0)|答案(7)|浏览(143)

我使用的是hibernate-Version:3.2.5.ga.与此同时,我使用gwt2.3版本。现在,当我试图升级hibernate版本,我得到错误.我已经下载了Hibernate 3.6.7最终版本,并取代它旧的jar文件中.但当我在第一个服务器上运行应用程序击中它给出下面的错误.如果我用旧的jar替换新的jar,那么就没有问题.但对于新的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)

字符串

9rbhqvlz

9rbhqvlz1#

它无法访问Bean验证框架(BeanValidationActivator)请确保以下依赖项位于类路径或pom.xml中

<dependency>
    <groupId>javax.validation</groupId>
    <artifactId>validation-api</artifactId>
    <version>1.0.0.GA</version>
</dependency>
<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-validator</artifactId>
    <version>4.2.0</version>
</dependency>

字符串

eeq64g8w

eeq64g8w2#

默认情况下,Hibernate验证器设置为自动,这意味着如果类路径中有验证器,它将尝试使用它。GWT 2.3和更新版本在gwt-servlet.jar中包含验证API,因此Hibernate最终会使用parcial验证器并失败。如果您不想使用Hibernate验证,只需在属性中关闭它(hibernate.cfg.xml,hibernate.properties或自动)。
只需将javax.persistence.validation.mode设置为none

eni9jsuy

eni9jsuy3#

默认情况下,Hibernate的验证器设置为true,这意味着如果类路径中有验证器,它将尝试使用它。GWT 2.3和更新版本在gwt-servlet.jar中包含验证API,所以Hibernate最终会使用parcial验证器并失败。如果你不想使用Hibernate验证,只需在属性中关闭它(hibernate.cfg.xml,hibernate.properties或martically)。
例如:在hibernate.cfg.xml中,将hibernate验证模式添加到none

<property name="javax.persistence.validation.mode">none</property>

字符串

bttbmeg0

bttbmeg04#

我有同样的问题,但后来我添加了下面的依赖,它工作得很好。

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-validator</artifactId>
    <version>4.2.0.Final</version>
</dependency>

字符串
但是请使用正确的版本。当我使用5.1.3.Final时,它一直失败,但后来我将版本改为4.2.0.Final,它工作了。

lvmkulzt

lvmkulzt5#

尝试删除hibernate-validator-4.0.2.GA.jar和validation-api-1.0.0.GA.jar

wribegjk

wribegjk6#

你有两个选择:
1.-您可以禁用Hibernate验证:

setProperty("javax.persistence.validation.mode", "NONE");

字符串
2.-添加这些依赖项,如果您不使用maven,请下载jar并手动添加到您的工件:

<dependency>
        <groupId>javax.el</groupId>
        <artifactId>javax.el-api</artifactId>
        <version>2.2.4</version>
        <scope>provided</scope> <!-- No required in JBoss but for test -->
    </dependency>
    <dependency>
        <groupId>org.glassfish.web</groupId>
        <artifactId>javax.el</artifactId>
        <version>2.2.4</version>
        <scope>provided</scope> <!-- No required in JBoss but for test -->
    </dependency>

at0kjp5o

at0kjp5o7#

这里的答案对Maven很有帮助。我正在使用Gradle,我发现我需要做的就是添加:

compile group: 'org.hibernate', name: 'hibernate-validator', version: '4.2.0.Final'

字符串
错误消失了,我的应用程序运行正常。我不需要像其他答案提到的那样排除javax验证jar或更改持久性验证模式。

相关问题