HTTP status 500 - handler processing failed; the nested exception is java.lang.AbstractMethodError:

Please help me learn the basics of Spring 3 MVC better, I tried to learn about Spring JSR 303: Bean Validation and could not solve the problem below, I spent more than a day on this already: (

I want a simple check here. The username, password and email fields in hello.jsp cannot be empty, which is quite the goal. At the moment, every time hello.jsp tries to be sent with all fields empty, an error appears below

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

Error stack:

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) 

All used banks:

  • ANTLR-2.7.6.jar
  • aopalliance-1.0.jar
  • ASM-ATTRS-1.5.3.jar
  • CGLIB-nodep-2.2.2.jar
  • CGLIB-nodep-2,2-sources.jar
  • General collection-2.1.jar
  • Common-DBHP-1.4.jar
  • General Logging 1.1.3.jar
  • dom4j-1.6.1.jar
  • winter-3.2.6.ga.jar
  • hibernation-annotations-3.3.1.GA.jar
  • sleeping-Wikimedia Commons annotations-3.0.0.ga.jar
  • winter-EntityManager-3.3.2.GA.jar
  • sleep mode JPA-2.0-api-1.0.0.Final.jar-
  • winter-search-3.0.0.GA.jar
  • winter-validator-4.2.0.Final.jar
  • winter-validator-KDI-5.1.0.Final.jar
  • hsqldb.jar
  • Java Mail 1.4.4.jar
  • javax.servlet.jsp.jstl-1.2.1.jar
  • JSch-0.1.49.jar
  • JSTL-1.2.jar
  • jta.jar
  • Lucene-core-2.3.2.jar
  • Lucene felt-tip pen-2.0.0.jar
  • MySQL-socket-Java-5.1.21.jar
  • org.springframework.asm-3.1.2.RELEASE.jar
  • org.springframework.beans-3.1.2.RELEASE.jar
  • org.springframework.context.support_3.0.5.RELEASE.jar
  • org.springframework.context-3.1.2.RELEASE.jar
  • org.springframework.core-3.1.2.RELEASE.jar
  • org.springframework.expression-3.1.2.RELEASE.jar
  • org.springframework.orm-3.1.2.RELEASE.jar
  • org.springframework.transaction-3.1.2.RELEASE.jar
  • org.springframework.web.servlet-3.1.2.RELEASE.jar
  • org.springframework.web-3.1.2.RELEASE.jar
  • save-api-1.0.jar
  • SLF4J-api-1.7.5.jar
  • SLF4J-api-1.7.7.jar
  • spring -aop-3.1.2.RELEASE.jar
  • spring -jdbc-3.1.2.RELEASE.jar
  • spring -TX-3.1.2.RELEASE.jar
  • validation-api-1.1.0.Final.jar

* Controller: 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> 

Please let me know about the place where, of course, I'm missing something. If this is a jar compatibility issue, please provide the jar names that I need to replace.

Thanks in advance.

+1
source share
1 answer

Versions of your libraries do not play together. For instance. you are using Hibernate ORM 3.2 (which implements JPA 1.0), and Hibernate Validator 4.2 by default works with JPA 2 (which implements Hibernate ORM 3.5). Note that some other libraries in your class path do not look like this:

  • Hibernate ORM and JPA API Version Mismatch
  • Hibernate Validator mechanism and CDI portable expansion mismatch
  • Mismatch between Bean Validator API and Hibernate Validator
  • Two different versions of slf4j API

I recommend working with a dependency management tool (Ivy, Maven, Gradle) to sort these things out.

+2
source

Source: https://habr.com/ru/post/1013222/


All Articles