SSH整合时,关于访问数据库的load的错误

1 当web.xml中没有配置以下拦截时,会出现

<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>

当没有在web.xml中配置处理session的拦截filter时,会出现的错误

  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

当hibernate的javassist-GA.jar和Struts2的javassist-.GA.jar包冲突时,出现的错误,解决该错误方法:删除Struts2的javassist-3.11.0.GA.jar包,保留hibernate的javassist-3.11.0.GA.jar包

所以解决该错误:

1 必须在web.xml配置好,拦截器

2 必须有Hibernate的javassist-3.18.1-GA.jar包,而且不能有Struts2的javassist-3.18.1-GA.jar,因为这两个jar包冲突。

时间: 2024-10-30 09:30:04

SSH整合时,关于访问数据库的load的错误的相关文章

用ssh整合时,用sessionfactory的getCurrentSession()获取不到session

在用ssh整合时,一开始用的是getCurrentSession(),获取当前线程上的session,但是总是抛异常,不能获取. 后来用sessionfactory的openSession(),但是,会发现一旦程序多次运行就会报错,提示没得session可获取. 那么怎么解决呢. 在beans.xml里面的hibernateProperties配置hibernate.current_session_context_class=org.springframework.orm.hibernate3.

启动ssh服务时,提示Could not load host key: /etc/ssh/ssh_host_rsa_key

在启用 ssh 服务时,有时会看到如下提示: [email protected]:~# /etc/init.d/ssh start* Starting OpenBSD Secure Shell server sshd                                   Could not load host key: /etc/ssh/ssh_host_rsa_keyCould not load host key: /etc/ssh/ssh_host_dsa_key 有两个提示

SSH整合时jar包冲突解决的注意事项

在SSH项目整合的时候,要注意jar包冲突. 这里的原则是: 1,无依赖关系的舍低取高. 2.有依赖关系的取高. 怎么排查是否有冲突,在服务器项目的lib下查看是否有重名的. 注意:每次重新导入包以后要把服务器中的项目删掉再发布.

在myeclipse中maven项目关于ssh整合时通过pom.xml导入依赖是pom.xml头部会报错

错误如下 ArtifactTransferException: Failure to transfer org.springframework:spring-jdbc:jar:3.0.5.RELEASE from http:// repo1.maven.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of  central has

C# 免安装ORACLE客户端访问数据库

c#开发程序时,在没有安装oracle客户端时,访问数据库报 “System.Data.OracleClient 需要 Oracle 客户端软件 8.1.7 或更高版本.” 在没有安装oracle客户端的情况下,可连接oracle数据库执行各种操作 使用方法: 将oci.dll.ociw32.dll.Oracle.DataAccess.dll.orannzsbb11.dll.oraocci11.dll.oraociicus11.dll.OraOps11w.dll拷到程序bin目录下 C# 免安装

SSH整合开发时Scope为默认时现象与原理

1.前提知识 1)scope默认值 进行SSH整合开发时,Struts2的action需要用spring容器进行管理,只要涉及到类以bean的形式入到spring容器中,不管是xml配置还是使用注解方式进行配置,都会涉及到spring管理bean的scope,其一共有五种取值,而其默认值为singleton,也就是单例模型,所有对此bean引用为同一个对象. 2)action应为多例 struts2作为MVC中视图(View)层框架,其最主要任务就是接收用户请求,然后调用业务逻辑层进行处理,这种

Spring Boot整合JdbcTemplate访问数据库

这篇文章是介绍 Spring Boot整合JdbcTemplate,配置数据源来访问数据库. 在pom文件里添加 spring-boot-starter-jdbc 和mysql依赖. <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jdbc</artifactId></dependency> <dep

使用tp访问数据库时提示错误: &#39;PDO&#39; not found, 和not defined constant mysql_attr_init_command

第一个问题: PDO not found 是因为 php没有安装pdo扩展, 无法提供给 php 以 数据库访问功能, 所以 报错是在文件: Think/Db.class.php的里面. 解决方法是: 给 php安装 PDO 扩展: dnf install php-pdo 这时 再看 就可以 在 默认 自动 加载的modules目录 中 看到: /usr/lib/php/modules pdo.so这个共享库 安装好 pdo后, 又出现了 没有定义 mysql_attr_init_command

ssh整合常见的后台错误

ssh整合以及常见的后台错误 摘自网络 jsp和Servlet之间传值出现乱码的解决方案 采用设置字符集的方式 request.setCharacterEncoding("utf-8"); 在web.xml文件里定义编码,同时在CoreFilter类里定义编码为utf-8 <filter> <filter-name>encodingFilter</filter-name> <filter-class>fengke.filter.CoreF