Spring Filter中的AbstractMethodError org.hibernate.ejb.HibernatePersistence.getProviderUtil()LjavaxpersistencespiProviderUtil;

Spring Filter中的AbstractMethodError org.hibernate.ejb.HibernatePersistence.getProviderUtil()LjavaxpersistencespiProviderUtil;,第1张

概述我有一个基于Spring Web模型 - 视图 - 控制器(MVC)框架的项目. Spring Web模型 - 视图 - 控制器(MVC)框架的版本是3.2.8.我用这个方法实现了一个过滤器:public void doFilter(ServletRequest request, ServletRespons

我有一个基于Spring Web模型 – 视图 – 控制器(MVC)框架的项目. Spring Web模型 – 视图 – 控制器(MVC)框架的版本是3.2.8.

我用这个方法实现了一个过滤器:

public voID doFilter(ServletRequest request,ServletResponse response,FilterChain filterChain) throws servletexception,IOException {        httpServletRequest httpServletRequest;        threadcontext threadcontext;        //String path = ((httpServletRequest) request).getRequestURI();        if (request instanceof httpServletRequest) {            httpServletRequest = (httpServletRequest) request;            threadcontext = threadcontext.getInstance();            try {                DetailedUser ecasUser = (DetailedUser) httpServletRequest.getUserPrincipal();                if (ecasUser != null) {                    threadcontext.setDomainUsername(ecasUser.getDomainUsername());                }            } catch (Exception e) {                e.printstacktrace();            }            if (httpServletRequest.getRemoteUser()!=null) {                         threadcontext.setUserID(httpServletRequest.getRemoteUser());            }        }        try {            if (filterChain != null) {                filterChain.doFilter(request,response);                            }        } catch (IOException e) {            LOGGER.equals(e.getMessage());        }        }

在这行filterChain.doFilter(request,response);我有这个奇怪的错误:

] Root cause of servletexception.ava.lang.AbstractMethodError: org.hibernate.ejb.HibernatePersistence.getProvIDerUtil()Ljavax/persistence/spi/ProvIDerUtil;       at javax.persistence.Persistence$PersistenceUtilimpl.isLoaded(Persistence.java:110)       at org.hibernate.valIDator.engine.resolver.JPATraversableResolver.isReachable(JPATraversableResolver.java:62)       at org.hibernate.valIDator.engine.resolver.DefaultTraversableResolver.isReachable(DefaultTraversableResolver.java:94)       at org.hibernate.valIDator.engine.resolver.SingleThreadCachedTraversableResolver.isReachable(SingleThreadCachedTraversableResolver.java:47)       at org.hibernate.valIDator.engine.ValIDatorImpl.isCascaderequired(ValIDatorImpl.java:783)       at org.hibernate.valIDator.engine.ValIDatorImpl.valIDateCascadedConstraints(ValIDatorImpl.java:360)       at org.hibernate.valIDator.engine.ValIDatorImpl.valIDateInContext(ValIDatorImpl.java:216)       at org.hibernate.valIDator.engine.ValIDatorImpl.valIDate(ValIDatorImpl.java:119)       at org.springframework.valIDation.beanvalIDation.SpringValIDatorAdapter.valIDate(SpringValIDatorAdapter.java:102)       at org.springframework.valIDation.DataBinder.valIDate(DataBinder.java:772)       at org.springframework.web.method.annotation.modelattributeMethodProcessor.valIDateIfApplicable(modelattributeMethodProcessor.java:159)       at org.springframework.web.method.annotation.modelattributeMethodProcessor.resolveArgument(modelattributeMethodProcessor.java:107)       at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:77)       at org.springframework.web.method.support.invocableHandlerMethod.getmethodArgumentValues(invocableHandlerMethod.java:157)       at org.springframework.web.method.support.invocableHandlerMethod.invokeForRequest(invocableHandlerMethod.java:124)       at org.springframework.web.servlet.mvc.method.annotation.ServletinvocableHandlerMethod.invokeAndHandle(ServletinvocableHandlerMethod.java:104)       at org.springframework.web.servlet.mvc.method.annotation.RequestMapPingHandlerAdapter.invokeHandleMethod(RequestMapPingHandlerAdapter.java:745)       at org.springframework.web.servlet.mvc.method.annotation.RequestMapPingHandlerAdapter.handleInternal(RequestMapPingHandlerAdapter.java:686)       at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)       at org.springframework.web.servlet.dispatcherServlet.dodispatch(dispatcherServlet.java:925)       at org.springframework.web.servlet.dispatcherServlet.doService(dispatcherServlet.java:856)       at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:953)       at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:844)       at javax.servlet.http.httpServlet.service(httpServlet.java:731)       at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:829)       at javax.servlet.http.httpServlet.service(httpServlet.java:844)       at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:280)       at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:254)       at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:136)       at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:341)       at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:25)       at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)       at com.tdk.devices.support.context.DevicesSecurityFilter.doFilter(DevicesSecurityFilter.java:82)

这是导入的库:

   

它似乎与pom.xml文件的hibernate依赖关系有关最佳答案这个错误背后的原因是,Hibernate在构建PersistenceProvIDerResolver中返回类路径上所有PersistenceProvIDers的列表.由于Weblogic lib包含JPA 1.0,因此它返回JPA2.0以及JPA 1.0持久性提供程序.

要修复此错误,您可以使用以下方法.

创建一个HibernatePersistenceProvIDerResolver类作为

 public class HibernatePersistenceProvIDerResolver implements PersistenceProvIDerResolver {private volatile PersistenceProvIDer persistenceProvIDer = new HibernatePersistence();public List getPersistenceProvIDers() {return Collections.singletonList(persistenceProvIDer);}public voID clearCachedProvIDers() {persistenceProvIDer = new HibernatePersistence();}public static voID register() {PersistenceProvIDerResolverHolder.setPersistenceProvIDerResolver(new HibernatePersistenceProvIDerResolver());}}

添加一个监听器类来调用寄存器方法

public class HibernateContextListener implements servletcontextlistener{@OverrIDepublic voID contextinitialized(ServletContextEvent sce) {HibernatePersistenceProvIDerResolver.register();}@OverrIDepublic voID contextDestroyed(ServletContextEvent sce) {// Todo auto-generated method stub}}

在web.xml中添加侦听器条目 总结

以上是内存溢出为你收集整理的Spring Filter中的AbstractMethodError org.hibernate.ejb.HibernatePersistence.getProviderUtil()Ljavax / persistence / spi / ProviderUtil;全部内容,希望文章能够帮你解决Spring Filter中的AbstractMethodError org.hibernate.ejb.HibernatePersistence.getProviderUtil()Ljavax / persistence / spi / ProviderUtil;所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1248457.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-07
下一篇 2022-06-07

发表评论

登录后才能评论

评论列表(0条)