将项目转换为spring5并将hibernate 5.2.17转换为在jboss 7.1 AP中运行时异常

内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用

  • 回答 (1)
  • 关注 (0)
  • 查看 (41)

我正在将spring-web-mvc项目升级到spring5,JDK1.8和hibernate5.2.17。该项目编译并部署到Jboss 7.1.AP,但当我尝试登录该应用程序时,它给出以下错误:

ERROR [default task-2] aspect.ICAMExceptionHandler  - A NestedServletException has occured in the application
org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.NoSuchMethodError: org.hibernate.Session.createSQLQuery(Ljava/lang/String;)Lorg/hibernate/query/NativeQuery;
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1006)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:978)
    at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:881)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:855)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
    at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
    at io.undertow.servlet.handlers.security.ServletSecurityRo

pom.xml

</dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
             <version>5.2.17.Final</version>
            <!-- <version>3.3.2.GA</version>  -->

        </dependency>
        <dependency>
            <groupId>org.hibernate.common</groupId>
            <artifactId>hibernate-commons-annotations</artifactId>
            <version>5.0.1.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>5.2.17.Final</version>

一旦我将休眠降级到5.0.12.Final,我得到一个不同的错误

Apr 23 14:45:29 ERROR [default task-2] stderr  - java.lang.NullPointerException
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at org.hibernate.internal.util.collections.BoundedConcurrentHashMap.get(BoundedConcurrentHashMap.java:1851)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at org.hibernate.engine.query.spi.QueryPlanCache.getSQLParameterMetadata(QueryPlanCache.java:123)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at org.hibernate.internal.AbstractSessionImpl.createSQLQuery(AbstractSessionImpl.java:252)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at org.hibernate.internal.SessionImpl.createSQLQuery(SessionImpl.java:1914)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at com.gee.gecs.cosmos.dao.BaseDao.loadTransformedObjectWithNativeSQL(BaseDao.java:350)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at com.gee.gecs.cosmos.dao.ServiceDaoImpl.getUserValidation(ServiceDaoImpl.java:448)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at java.lang.reflect.Method.invoke(Method.java:498)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:338)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:197)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:294)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at com.sun.proxy.$Proxy116.getUserValidation(Unknown Source)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at com.gee.gecs.cosmos.services.ServiceLayerImpl.getUserValidation(ServiceLayerImpl.java:1800)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at com.gee.gecs.cosmos.services.security.SecuritySvcImpl.getUserValidation(SecuritySvcImpl.java:85)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at com.gee.gecs.cosmos.cmd.security.GetUserDetailsCmd.perform(GetUserDetailsCmd.java:77)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at com.gee.gecs.cosmos.cmd.security.GetUserDetailsCmd$$FastClassBySpringCGLIB$$4403c7d7.invoke(<generated>)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:747)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:136)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:124)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:689)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at com.gee.gecs.cosmos.cmd.security.GetUserDetailsCmd$$EnhancerBySpringCGLIB$$8d294553.perform(<generated>)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at com.gee.gecs.cosmos.controller.LegalController.printWelcome(LegalController.java:45)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at com.gee.gecs.cosmos.controller.LegalController$$FastClassBySpringCGLIB$$a04eb3fb.invoke(<generated>)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:747)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:89)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at com.gee.gecs.cosmos.aspect.ExceptionAspectHandler.handleControllerExceptionsWithAroundReturnString(ExceptionAspectHandler.java:45)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at java.lang.reflect.Method.invoke(Method.java:498)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:643)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:632)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:689)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at com.gee.gecs.cosmos.controller.LegalController$$EnhancerBySpringCGLIB$$ec0a9239.printWelcome(<generated>)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at java.lang.reflect.Method.invoke(Method.java:498)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:209)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:871)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:777)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:991)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:978)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:881)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
Apr 23 14:45:29 ERROR [default task-2] stderr  -    at org.springframework.web.servlet.FrameworkS
提问于
用户回答回答于

https://docs.oracle.com/javase/7/docs/api/java/lang/NoSuchMethodError.html

NoSuchMethodError is caused when the called method does not exists. In your case: org.hibernate.Session.createSQLQuery(String)

请检查Hibernate的版本是否有效用于其他库。

听起来像兼容性问题。

扫码关注云+社区

领取腾讯云代金券