struts2的no session 问题

开发环境是struts2+hibernate+spring,entity使用annotation注解,而且测试的是[b]单表结[/b]构client表,但是总出下面的问题,提示找不到property。代码如下:

2009-03-07 11:15:23,593 [http-8080-1] ERROR org.hibernate.LazyInitializationException - could not initialize proxy - no Session
org.hibernate.LazyInitializationException: could not initialize proxy - no Session
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:86) [hibernate-core-3.3.1.GA.jar:3.3.1.GA]
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:140) [hibernate-core-3.3.1.GA.jar:3.3.1.GA]
at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:190) [hibernate-core-3.3.1.GA.jar:3.3.1.GA]
at org.testWeb.entity.Client_$$_javassist_0.getTelphone(Client_$$_javassist_0.java) [Client.class:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [na:1.5.0_11]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) [na:1.5.0_11]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) [na:1.5.0_11]
at java.lang.reflect.Method.invoke(Unknown Source) [na:1.5.0_11]
at ognl.OgnlRuntime.invokeMethod(OgnlRuntime.java:517) [ognl-2.6.11.jar:na]
at ognl.OgnlRuntime.getMethodValue(OgnlRuntime.java:931) [ognl-2.6.11.jar:na]
at ognl.ObjectPropertyAccessor.getPossibleProperty(ObjectPropertyAccessor.java:53) [ognl-2.6.11.jar:na]
at ognl.ObjectPropertyAccessor.getProperty(ObjectPropertyAccessor.java:121) [ognl-2.6.11.jar:na]
at com.opensymphony.xwork2.ognl.accessor.ObjectAccessor.getProperty(ObjectAccessor.java:17) [xwork-2.1.2.jar:na]
at ognl.OgnlRuntime.getProperty(OgnlRuntime.java:1643) [ognl-2.6.11.jar:na]
at com.opensymphony.xwork2.ognl.accessor.CompoundRootAccessor.getProperty(CompoundRootAccessor.java:106) [xwork-2.1.2.jar:na]
at ognl.OgnlRuntime.getProperty(OgnlRuntime.java:1643) [ognl-2.6.11.jar:na]
at ognl.ASTProperty.getValueBody(ASTProperty.java:92) [ognl-2.6.11.jar:na]
at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170) [ognl-2.6.11.jar:na]
at ognl.SimpleNode.getValue(SimpleNode.java:210) [ognl-2.6.11.jar:na]
at ognl.Ognl.getValue(Ognl.java:333) [ognl-2.6.11.jar:na]
at ognl.Ognl.getValue(Ognl.java:310) [ognl-2.6.11.jar:na]
at com.opensymphony.xwork2.ognl.OgnlUtil.getValue(OgnlUtil.java:196) [xwork-2.1.2.jar:na]
at com.opensymphony.xwork2.ognl.OgnlValueStack.findValue(OgnlValueStack.java:229) [xwork-2.1.2.jar:na]
at org.apache.struts2.dispatcher.StrutsRequestWrapper.getAttribute(StrutsRequestWrapper.java:82) [struts2-core-2.1.6.jar:na]
at org.apache.jasper.runtime.PageContextImpl.doFindAttribute(PageContextImpl.java:462) [jasper.jar:na]
at org.apache.jasper.runtime.PageContextImpl.findAttribute(PageContextImpl.java:452) [jasper.jar:na]
at javax.servlet.jsp.el.ScopedAttributeELResolver.getValue(ScopedAttributeELResolver.java:53) [jsp-api.jar:na]
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53) [el-api.jar:na]
at org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:61) [jasper-el.jar:na]
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186) [jasper-el.jar:na]
at org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:925) [jasper.jar:na]
at org.apache.jsp.WEB_002dINF.jsp.client_002dinput_jsp._jspService(client_002dinput_jsp.java:172) [testWeb/:na]
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) [jasper.jar:na]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) [servlet-api.jar:na]
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374) [jasper.jar:na]
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342) [jasper.jar:na]
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267) [jasper.jar:na]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) [servlet-api.jar:na]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) [catalina.jar:na]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [catalina.jar:na]
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:630) [catalina.jar:na]
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436) [catalina.jar:na]
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374) [catalina.jar:na]
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302) [catalina.jar:na]
at org.apache.struts2.dispatcher.ServletDispatcherResult.doExecute(ServletDispatcherResult.java:154) [struts2-core-2.1.6.jar:na]
at org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:186) [struts2-core-2.1.6.jar:na]
at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:361) [xwork-2.1.2.jar:na]
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:265) [xwork-2.1.2.jar:na]
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:89) [xwork-2.1.2.jar:na]
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236) [xwork-2.1.2.jar:na]
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:89) [xwork-2.1.2.jar:na]
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236) [xwork-2.1.2.jar:na]
at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122) [xwork-2.1.2.jar:na]
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236) [xwork-2.1.2.jar:na]
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195) [xwork-2.1.2.jar:na]
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) [xwork-2.1.2.jar:na]
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236) [xwork-2.1.2.jar:na]
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195) [xwork-2.1.2.jar:na]
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) [xwork-2.1.2.jar:na]
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236) [xwork-2.1.2.jar:na]
at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:148) [xwork-2.1.2.jar:na]
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236) [xwork-2.1.2.jar:na]
at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:93) [struts2-core-2.1.6.jar:na]
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236) [xwork-2.1.2.jar:na]
at org.apache.struts2.interceptor.FileUploadInterceptor.intercep

哪位高手朋友可以帮忙看下,我已经试过好多次了,还是这样,感激。。

1个回答

org.hibernate.LazyInitializationException: could not initialize proxy - no Session
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:86) [hibernate-core-3.3.1.GA.jar:3.3.1.GA

这是hibernate中的懒加载问题,你可以在web.xml中配置一下代码

opensession

org.springframework.orm.hibernate3.support.OpenSessionInViewFilter



opensession
*.do

这是spring自带的管理Hibernate中的懒加载问题

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐