当前位置: 首页 > 知识库问答 >
问题:

HTTP状态500-处理程序处理失败;嵌套异常是java.lang.AbstractMethodError:

袁耀
2023-03-14

请帮助我更好地学习Spring 3 MVC的基础知识,我试图学习Spring JSR303:Bean验证,但根本无法解决以下问题,我已经花了一天多的时间来解决这个问题:(

我想要一个简单的验证在这里工作。jsp中的name、password和email字段不能留空,这是我们的目标。到目前为止,每次尝试将所有字段都为空提交hello.jsp时,都会遇到以下错误

HTTP状态500-处理程序处理失败;嵌套异常是java.lang.AbstractMethoderror:org.hibernate.ejb.hibernatePersistence.getProvideRutil()ljavax/persistence/spi/ProvideRutil;

错误堆栈:

HTTP Status 500 - Handler processing failed; nested exception is java.lang.AbstractMethodError: org.hibernate.ejb.HibernatePersistence.getProviderUtil()Ljavax/persistence/spi/ProviderUtil;


type Exception report

message Handler processing failed; nested exception is java.lang.AbstractMethodError: org.hibernate.ejb.HibernatePersistence.getProviderUtil()Ljavax/persistence/spi/ProviderUtil;

description The server encountered an internal error (Handler processing failed; nested exception is java.lang.AbstractMethodError: org.hibernate.ejb.HibernatePersistence.getProviderUtil()Ljavax/persistence/spi/ProviderUtil;) that prevented it from fulfilling this request.

exception 

org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.AbstractMethodError: org.hibernate.ejb.HibernatePersistence.getProviderUtil()Ljavax/persistence/spi/ProviderUtil;
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:972)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
    org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:722)


root cause 

java.lang.AbstractMethodError: org.hibernate.ejb.HibernatePersistence.getProviderUtil()Ljavax/persistence/spi/ProviderUtil;
    javax.persistence.Persistence$1.isLoaded(Persistence.java:78)
    org.hibernate.validator.engine.resolver.JPATraversableResolver.isReachable(JPATraversableResolver.java:61)
    org.hibernate.validator.engine.resolver.DefaultTraversableResolver.isReachable(DefaultTraversableResolver.java:131)
    org.hibernate.validator.engine.resolver.SingleThreadCachedTraversableResolver.isReachable(SingleThreadCachedTraversableResolver.java:46)
    org.hibernate.validator.engine.ValidatorImpl.isValidationRequired(ValidatorImpl.java:1242)
    org.hibernate.validator.engine.ValidatorImpl.validateConstraint(ValidatorImpl.java:448)
    org.hibernate.validator.engine.ValidatorImpl.validateConstraintsForDefaultGroup(ValidatorImpl.java:397)
    org.hibernate.validator.engine.ValidatorImpl.validateConstraintsForCurrentGroup(ValidatorImpl.java:361)
    org.hibernate.validator.engine.ValidatorImpl.validateInContext(ValidatorImpl.java:313)
    org.hibernate.validator.engine.ValidatorImpl.validate(ValidatorImpl.java:139)
    org.springframework.validation.beanvalidation.SpringValidatorAdapter.validate(SpringValidatorAdapter.java:101)
    org.springframework.validation.DataBinder.validate(DataBinder.java:722)
    org.springframework.web.method.annotation.ModelAttributeMethodProcessor.validateIfApplicable(ModelAttributeMethodProcessor.java:155)
    org.springframework.web.method.annotation.ModelAttributeMethodProcessor.resolveArgument(ModelAttributeMethodProcessor.java:108)
    org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:75)
    org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:156)
    org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:117)
    org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
    org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)
    org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)
    org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
    org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

所有使用的罐子是:

  1. antlr-2.7.6.jar
  2. Aopalliance-1.0.jar
  3. asm-attrs-1.5.3.jar
  4. cglib-nodep-2.2.2.jar
  5. cglib-nodep-2.2-sources.jar
  6. Commons-Collections-2.1.jar
  7. commons-dbcp-1.4.jar
  8. commons-logging-1.1.3.jar
  9. dom4j-1.6.1.jar
  10. hibernate-3.2.6.ga.jar
  11. hibernate-annotations-3.3.1.ga.jar
  12. hibernate-commons-annotations-3.0.0.ga.jar
  13. hibernate-entitymanager-3.3.2.ga.jar
  14. hibernate-jpa-2.0-api-1.0.0.final.jar
  15. hibernate-search-3.0.0.ga.jar
  16. hibernate-validator-4.2.0.final.jar
  17. hibernate-validator-cdi-5.1.0.final.jar
  18. hsqldb.jar
  19. java-mail-1.4.4.jar
  20. javax.servlet.jsp.jstl-1.2.1.jar
  21. jsch-0.1.49.jar
  22. jstl-1.2.jar
  23. jta.jar
  24. lucene-core-2.3.2.jar
  25. lucene-highlighter-2.0.0.jar
  26. mysql-connector-java-5.1.21.jar
  27. org.springframework.asm-3.1.2.release.jar
  28. org.springframework.beans-3.1.2.release.jar
  29. org.springframework.context.support_3.0.5.release.jar
  30. org.springframework.context-3.1.2.release.jar
  31. org.springframework.core-3.1.2.release.jar
  32. org.springframework.expression-3.1.2.release.jar
  33. org.springframework.orm-3.1.2.release.jar
  34. org.springframework.transaction-3.1.2.release.jar
  35. org.springframework.web.servlet-3.1.2.release.jar
  36. org.springframework.web-3.1.2.release.jar
  37. persistence-api-1.0.jar
  38. slf4j-api-1.7.5.jar
  39. slf4j-api-1.7.7.jar
  40. spring-aop-3.1.2.release.jar
  41. spring-jdbc-3.1.2.release.jar
  42. spring-tx-3.1.2.release.jar
  43. 验证-API-1.1.0.final.jar

*控制器:MainController.java*

package com.poc.controller;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import com.poc.bean.UserBean;
import com.poc.service.DaoService;
import com.poc.service.MailService;
import com.poc.service.MailServiceImpl;
import javax.validation.Valid;

@Controller
public class MainController {
@Autowired
DaoService d;
UserBean user;
@Autowired
MailService mailService;
     @RequestMapping("/")
      public String hello(Model model) {
        return "hello";
      }


     @ModelAttribute("user")
     public UserBean getUserForm() {
                 return new UserBean();

         }

      @RequestMapping(value = "/hi", method = RequestMethod.POST)
      public String hi(@ModelAttribute("user")@Valid UserBean user,BindingResult result ) {


          if (result.hasErrors()) {
                return "hello";
            } else {


          d.insert(user);
         //Send a composed mail
          mailService.sendMail(user.getEmailid(), "Registration Acknowledgement", "You have successfully registered with us. Your password is "+user.getPasswd());
          String message = "Hi " + user.getName() + "!";
        //model.addAttribute("message", message);
        return "redirect:/index";}
      }

      @RequestMapping("/index")
        public String listContacts(Map<String, Object> map) {

            map.put("user", new UserBean());
            map.put("userList", d.listAll());

            return "hello";
        }



    }

hello.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<html>
<!-- <style>
.error {
    color: #ff0000;
}

.errorblock {
    color: #000;
    background-color: #ffEEEE;
    border: 3px solid #ff0000;
    padding: 8px;
    margin: 16px;
}
</style> -->

<style>
  .error {
      color: #EF1313;
      font-style: italic;
  }
</style>



<head>
<title>Home</title>
</head>
<body>
  <h1>Hello World!</h1>

<hr/>
  <form:form action="hi" commandName="user">
<table>
<tr>
    <td><font face="verdana" size="2px">Name</font></td>
    <td>:</td>
    <td>
    <font face="verdana" size="2">
    <form:input path="name" /> <form:errors path="name"></form:errors>
    </font>
    </td>
</tr>
<tr>
    <td><font face="verdana" size="2px">Password</font></td>
    <td>:</td>
    <td>
    <font face="verdana" size="2">
    <form:input path="passwd" /> <form:errors path="passwd"></form:errors>
    </font>
    </td>
</tr>
<tr>
    <td><font face="verdana" size="2px">Email</font></td>
    <td>:</td>
    <td>
    <font face="verdana" size="2">
    <form:input path="emailid" /> <form:errors path="emailid"></form:errors>
    </font>
    </td>
</tr>
<tr>
    <td>
    <input type="submit" value="Submit" />
    </td>
</tr>
</table>
</form:form>



  <h3>Users</h3>
  <c:if  test="${!empty userList}">
  <table class = "data"><tr>
  <th>Name</th>
  <th>Email</th>
  </tr>
  <c:forEach items= "${userList}" var = "user">
  <tr>
  <td>
  ${user.name}
  </td>
  <td>${user.emailid}</td>
  </tr>
  </c:forEach>
  </table>
  </c:if>
</body>
</html>

请让我知道我确实遗漏了什么地方。如果是jar兼容性问题,那么请提到我需要替换的jar的名称。

提前谢了。

共有1个答案

柳德义
2023-03-14

您的库的版本并不能真正地一起运行。例如。您使用Hibernate ORM3.2(它实现了JPA1.0),而Hibernate Validator4.2默认情况下与JPA2(它由Hibernate ORM3.5实现)一起工作。请注意,类路径上的其他一些lib看起来并不正确:

  • Hibernate ORM和JPA API版本不匹配
  • Hibernate验证器引擎与CDI便携扩展之间不匹配
  • Bean验证API与Hibernate验证器引擎不匹配
  • slf4j API的两个不同版本

我建议使用依赖管理工具(Ivy、Maven、Gradle)来解决这些问题。

 类似资料:
  • 我有jsp和html页面的应用程序 说明服务器遇到一个内部错误,使其无法满足此请求。 例外 NestedServletException:处理程序处理失败;嵌套异常是java.lang.NosuchMethoderror:javax.servlet.http.HttpServletResponse.getHeader(ljava/lang/string;)ljava/lang/string;rig

  • 我现在正在使用JPA eclipselink,我想用Eclipselink连接到我的数据库 我有一些类de表在我的数据库和查询来获取我的条目: 我为我的桌子做了一些课程: FDC_DBCHANGE 已执行FDC_ 和FDC_系统 当我在Tomcat上运行它时,有一个例外: 组织。springframework。网状物util。NestedServletException:请求处理失败;嵌套异常是异

  • 例外 NestedServletException:处理程序处理失败;嵌套异常是java.lang.UnsatifiedLinkError:找不到指定的模块。 rig.springframework.web.servlet.dispatcherservlet.triggeraftercompletionwitherror(dispatcherservlet.java:1303)org.spring

  • 这是我的同意模式 这是同意控制器获取声明 这是声明后的同意 同意html thymeleaf表单是 提交表格后。我得到这个错误 HTTP状态500-请求处理失败;嵌套异常是org.thymeleaf.exceptions.TemplateProcessing异常:异常评估SpringEL表达式:"user.providers"(提供者/createOrUpdateConentForm 组织。spr

  • 异常严重:Servlet。路径为[z2]的上下文中servlet[dispatcher]的service()引发异常[请求处理失败;嵌套异常为org.springframework.dao.DataIntegrityViolationException:not null属性引用null或瞬时值:com.spring.entity.Product.cd;嵌套异常为org.hibernate.Prop

  • 我得到的。 这是我的密码: 我得到错误作为 2014年10月16日下午4:31:47 严重:Servlet。路径为[/CustomerPortal]的上下文中servlet[dispatcherServlet]的服务()引发了异常[Request processing failed;嵌套异常为java.lang.NumberFormatException:null],其根本原因为 当我运行这个项目