SSH整合时,关于访问数据库的load的错误
<filter>
<filter-name>openSessionInView</filter-name>
<filter-class>org.springframework.orm.hibernate4.support.OpenSessionInViewFilter</filter-class>
<init-param>
<param-name>sessionFactoryBeanName</param-name>
<param-value>sessionFactory</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>openSessionInView</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
1 HTTP Status 500 - com.bjsxt.registration.model.User_$$_javassist_0 cannot be cast to javassist.util.proxy.Proxy 2 3 type Exception report 4 5 message com.bjsxt.registration.model.User_$$_javassist_0 cannot be cast to javassist.util.proxy.Proxy 6 7 description The server encountered an internal error that prevented it from fulfilling this request. 8 9 exception 10 11 java.lang.ClassCastException: com.bjsxt.registration.model.User_$$_javassist_0 cannot be cast to javassist.util.proxy.Proxy 12 org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.getProxy(JavassistLazyInitializer.java:147) 13 org.hibernate.proxy.pojo.javassist.JavassistProxyFactory.getProxy(JavassistProxyFactory.java:75) 14 org.hibernate.tuple.entity.AbstractEntityTuplizer.createProxy(AbstractEntityTuplizer.java:771) 15 org.hibernate.persister.entity.AbstractEntityPersister.createProxy(AbstractEntityPersister.java:4613) 16 org.hibernate.event.internal.DefaultLoadEventListener.createProxyIfNecessary(DefaultLoadEventListener.java:350) 17 org.hibernate.event.internal.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:271) 18 org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:151) 19 org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:1106) 20 org.hibernate.internal.SessionImpl.access$2000(SessionImpl.java:176) 21 org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.getReference(SessionImpl.java:2564) 22 org.hibernate.internal.SessionImpl.load(SessionImpl.java:981) 23 org.springframework.orm.hibernate4.HibernateTemplate$3.doInHibernate(HibernateTemplate.java:471) 24 org.springframework.orm.hibernate4.HibernateTemplate.doExecute(HibernateTemplate.java:340) 25 org.springframework.orm.hibernate4.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:308) 26 org.springframework.orm.hibernate4.HibernateTemplate.load(HibernateTemplate.java:463) 27 org.springframework.orm.hibernate4.HibernateTemplate.load(HibernateTemplate.java:456) 28 com.bjsxt.registration.dao.impl.UserDaoImpl.loadById(UserDaoImpl.java:54) 29 com.bjsxt.registration.service.impl.UserManagerImpl.loadById(UserManagerImpl.java:51) 30 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 31 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 32 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 33 java.lang.reflect.Method.invoke(Method.java:497) 34 org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317) 35 org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) 36 org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) 37 org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99) 38 org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281) 39 org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) 40 org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) 41 org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) 42 org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) 43 org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207) 44 com.sun.proxy.$Proxy20.loadById(Unknown Source) 45 com.bjsxt.registration.action.UserAction.load(UserAction.java:68) 46 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 47 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 48 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 49 java.lang.reflect.Method.invoke(Method.java:497) 50 com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:450) 51 com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:289) 52 com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:252) 53 org.apache.struts2.interceptor.DeprecationInterceptor.intercept(DeprecationInterceptor.java:41) 54 com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246) 55 org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:256) 56 com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246) 57 com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:167) 58 com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) 59 com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246) 60 com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:265) 61 org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68) 62 com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) 63 com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246) 64 com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138) 65 com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246) 66 com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:249) 67 com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) 68 com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246) 69 com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:249) 70 com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) 71 com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246) 72 com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:191) 73 com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246) 74 org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:73) 75 com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246) 76 org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:91) 77 com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246) 78 org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:252) 79 com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246) 80 com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100) 81 com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246) 82 com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141) 83 com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246) 84 com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145) 85 com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246) 86 com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171) 87 com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) 88 com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246) 89 com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:139) 90 com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246) 91 org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164) 92 com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246) 93 com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:193) 94 com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246) 95 com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:189) 96 com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246) 97 org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54) 98 org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:562) 99 org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77) 100 org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99) 101 org.springframework.orm.hibernate4.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:151) 102 org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 103 note The full stack trace of the root cause is available in the Apache Tomcat/8.0.20 logs. 104 105 Apache Tomcat/8.0.20
所以解决该错误:
1 必须在web.xml配置好,拦截器
2 必须有Hibernate的javassist-3.18.1-GA.jar包,而且不能有Struts2的javassist-3.18.1-GA.jar,因为这两个jar包冲突。
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。