I had a chance to have a look the new features of Spring 3.0 today. The validation and formatting that is implemented as a part of JSR-303 implementation seems to be very exciting and interesting. Of course, it made me feel that we are moving towards codeless web based applications sooner or later!
I was very much curious to do a proof-of-concept application for this implementation. So I downloaded the Spring3.0 jars and made use of Hibernate Validator 4.0.2 GA version and validation-api-1.0.0 GA version.I had been using java 1.5
After removing all the old jars and even after implementing everything whatever was required, I was stuck with the following error
Please find the stack trace below:
It was almost 6-8 hours, I kept trying to do away with this problem since a colleague of mine seemed to get away with it in java 1.5. The following were the pointers that I understood as a result of my research googling the Internet!
I was very much curious to do a proof-of-concept application for this implementation. So I downloaded the Spring3.0 jars and made use of Hibernate Validator 4.0.2 GA version and validation-api-1.0.0 GA version.I had been using java 1.5
After removing all the old jars and even after implementing everything whatever was required, I was stuck with the following error
java.lang.NoSuchMethodError: javax.persistence.Persistence.getPersistenceUtil()Ljavax/persistence/PersistenceUtil
Please find the stack trace below:
<br />SEVERE: Servlet.service() for servlet springapp threw exception<br />java.lang.NoSuchMethodError: javax.persistence.Persistence.getPersistenceUtil()Ljavax/persistence/PersistenceUtil;<br /> at org.hibernate.validator.engine.resolver.JPATraversableResolver.isReachable(JPATraversableResolver.java:33)<br /> at org.hibernate.validator.engine.resolver.DefaultTraversableResolver.isReachable(DefaultTraversableResolver.java:95)<br /> at org.hibernate.validator.engine.resolver.SingleThreadCachedTraversableResolver.isReachable(SingleThreadCachedTraversableResolver.java:47)<br /> at org.hibernate.validator.engine.ValidatorImpl.isValidationRequired(ValidatorImpl.java:761)<br /> at org.hibernate.validator.engine.ValidatorImpl.validateConstraint(ValidatorImpl.java:331)<br /> at org.hibernate.validator.engine.ValidatorImpl.validateConstraintsForRedefinedDefaultGroup(ValidatorImpl.java:278)<br /> at org.hibernate.validator.engine.ValidatorImpl.validateConstraintsForCurrentGroup(ValidatorImpl.java:260)<br /> at org.hibernate.validator.engine.ValidatorImpl.validateInContext(ValidatorImpl.java:213)<br /> at org.hibernate.validator.engine.ValidatorImpl.validate(ValidatorImpl.java:119)<br /> at org.springframework.validation.beanvalidation.SpringValidatorAdapter.validate(SpringValidatorAdapter.java:74)<br /> at org.springframework.validation.DataBinder.validate(DataBinder.java:684)<br /> at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.doBind(HandlerMethodInvoker.java:746)<br /> at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveHandlerArguments(HandlerMethodInvoker.java:296)<br /> at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:163)<br /> at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:414)<br /> at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:402)<br /> at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:771)<br /> at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716)<br /> at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:647)<br /> at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:563)<br /> at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)<br /> at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)<br /> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)<br /> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)<br /> at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)<br /> at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)<br /> at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)<br /> at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)<br /> at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)<br /> at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)<br /> at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)<br /> at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)<br /> at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)<br /> at java.lang.Thread.run(Thread.java:595)<br />
It was almost 6-8 hours, I kept trying to do away with this problem since a colleague of mine seemed to get away with it in java 1.5. The following were the pointers that I understood as a result of my research googling the Internet!
- The org.springframework.validation.beanvalidation.LocalValidatorFactoryBean while calling the SpringValidatorAdapter's validate(), invokes the Hibernate validator's ValidatorImpl.validate() method.
- The hibernate validoator 4.0.2 GA version has a very strong dependency on JDK6 which contains the Persistence class with javax.persistence.Persistence.getPersistenceUtil()
Hi,
ReplyDeleteThank you.
This tip was very helpful!
~rohit.
Thanks for letting me know rohit!
ReplyDeleteRealy thanks!!!
ReplyDeleteDint not work for me.I am using the JDK 1.6 still getting same problem.
ReplyDeleteI am using JBoss 5.1 for jdk1.6 and have the same problem.
ReplyDeleteAny clue ?
This was also helpful
ReplyDeleteExceptions encountered using Hibernate Validator 4.0.0.CR1