Hibernate 3.5 缺少jpa 包问题
Exception in thread "main" java.lang.NoClassDefFoundError: javax/persistence/Cacheable
?at org.hibernate.cfg.AnnotationBinder.determineCacheSettings(AnnotationBinder.java:946)
?at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:589)
?at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:636)
?at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:359)
?at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1377)
?at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:954)
?at TeacherTest.main(TeacherTest.java:16)
Caused by: java.lang.ClassNotFoundException: javax.persistence.Cacheable
?at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
?at java.security.AccessController.doPrivileged(Native Method)
?at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
?at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
?at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
?at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
?at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
?... 7 more
?
错误原因,javax.persistence.Cacheable 是 JPA 2.0 规范中的东西!
支持 JPA 2 的 Hibernate 实现 3.5 版目前还处于 CR2 版本之中,还没有正式发布。
需要在加入hibernate-distribution-3.5.0-Final\lib\jpa目录下的hibernate-jpa-2.0-api-1.0.0.Final.jar
[14:36:43.159] {http--8080-3$14093817} org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.AbstractMethodError[14:36:43.159] {http--8080-3$14093817} at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:820)[14:36:43.159] {http--8080-3$14093817} at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716)[14:36:43.159] {http--8080-3$14093817} at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:647)[14:36:43.159] {http--8080-3$14093817} at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:563)[14:36:43.159] {http--8080-3$14093817} at javax.servlet.http.HttpServlet.service(HttpServlet.java:153)[14:36:43.159] {http--8080-3$14093817} at javax.servlet.http.HttpServlet.service(HttpServlet.java:91)[14:36:43.159] {http--8080-3$14093817} at com.caucho.server.dispatch.ServletFilterChain.doFilter(ServletFilterChain.java:103)[14:36:43.159] {http--8080-3$14093817} at com.caucho.server.webapp.DispatchFilterChain.doFilter(DispatchFilterChain.java:97)[14:36:43.159] {http--8080-3$14093817} at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:265)[14:36:43.159] {http--8080-3$14093817} at com.caucho.server.webapp.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:293)[14:36:43.159] {http--8080-3$14093817} at com.caucho.server.webapp.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:111)[14:36:43.159] {http--8080-3$14093817} at org.tuckey.web.filters.urlrewrite.NormalRewrittenUrl.doRewrite(NormalRewrittenUrl.java:195)[14:36:43.159] {http--8080-3$14093817} at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:159)[14:36:43.159] {http--8080-3$14093817} at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:141)[14:36:43.159] {http--8080-3$14093817} at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:90)[14:36:43.159] {http--8080-3$14093817} at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:417)[14:36:43.159] {http--8080-3$14093817} at com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:87)[14:36:43.159] {http--8080-3$14093817} at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:83)[14:36:43.159] {http--8080-3$14093817} at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)[14:36:43.159] {http--8080-3$14093817} at com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:87)[14:36:43.159] {http--8080-3$14093817} at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:187)[14:36:43.159] {http--8080-3$14093817} at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:265)[14:36:43.159] {http--8080-3$14093817} at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:273)[14:36:43.159] {http--8080-3$14093817} at com.caucho.server.port.TcpConnection.run(TcpConnection.java:682)[14:36:43.159] {http--8080-3$14093817} at com.caucho.util.ThreadPool$Item.runTasks(ThreadPool.java:743)[14:36:43.159] {http--8080-3$14093817} at com.caucho.util.ThreadPool$Item.run(ThreadPool.java:662)[14:36:43.159] {http--8080-3$14093817} at java.lang.Thread.run(Thread.java:619)[14:36:43.159] {http--8080-3$14093817} Caused by: java.lang.AbstractMethodError[14:36:43.159] {http--8080-3$14093817} at javax.persistence.Persistence$1.isLoaded(Persistence.java:78)[14:36:43.159] {http--8080-3$14093817} at org.hibernate.validator.engine.resolver.JPATraversableResolver.isReachable(JPATraversableResolver.java:33)[14:36:43.159] {http--8080-3$14093817} at org.hibernate.validator.engine.resolver.DefaultTraversableResolver.isReachable(DefaultTraversableResolver.java:112)[14:36:43.159] {http--8080-3$14093817} at org.hibernate.validator.engine.resolver.SingleThreadCachedTraversableResolver.isReachable(SingleThreadCachedTraversableResolver.java:47)[14:36:43.159] {http--8080-3$14093817} at org.hibernate.validator.engine.ValidatorImpl.isValidationRequired(ValidatorImpl.java:764)[14:36:43.159] {http--8080-3$14093817} at org.hibernate.validator.engine.ValidatorImpl.validateConstraint(ValidatorImpl.java:331)[14:36:43.159] {http--8080-3$14093817} at org.hibernate.validator.engine.ValidatorImpl.validateConstraintsForRedefinedDefaultGroup(ValidatorImpl.java:278)[14:36:43.159] {http--8080-3$14093817} at org.hibernate.validator.engine.ValidatorImpl.validateConstraintsForCurrentGroup(ValidatorImpl.java:260)[14:36:43.159] {http--8080-3$14093817} at org.hibernate.validator.engine.ValidatorImpl.validateInContext(ValidatorImpl.java:213)[14:36:43.159] {http--8080-3$14093817} at org.hibernate.validator.engine.ValidatorImpl.validate(ValidatorImpl.java:119)[14:36:43.159] {http--8080-3$14093817} at org.springframework.validation.beanvalidation.SpringValidatorAdapter.validate(SpringValidatorAdapter.java:114)[14:36:43.159] {http--8080-3$14093817} at com.espider.oes.controller.ProfileRestAction.update(ProfileRestAction.java:77)[14:36:43.159] {http--8080-3$14093817} at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[14:36:43.159] {http--8080-3$14093817} at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)[14:36:43.159] {http--8080-3$14093817} at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)[14:36:43.159] {http--8080-3$14093817} at java.lang.reflect.Method.invoke(Method.java:597)[14:36:43.159] {http--8080-3$14093817} at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.doInvokeMethod(HandlerMethodInvoker.java:710)[14:36:43.159] {http--8080-3$14093817} at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:167)[14:36:43.159] {http--8080-3$14093817} at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:414)[14:36:43.159] {http--8080-3$14093817} at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:402)[14:36:43.159] {http--8080-3$14093817} at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:771)[14:36:43.159] {http--8080-3$14093817} ... 26 more 4 楼 eryk 2010-04-30 额,我还没遇到这个情况... 5 楼 xueyunji1989 2010-09-11 太感谢了。解我燃眉之急。。 6 楼 cityjin 2010-12-10 还是这里的资源实用啊,昨晚也遇到了同样的问题,调试了一整晚都没弄好,看错误提示是缺少包,但我以为是其他地方的原因,因为程序是在中途遇到这个问题的,今天来查了一下,果然是hibernate新版本缺包的问题,十分谢谢啊!