2014-02-19 2 views
0

Hibernate 3을 Hiberante 4.2에서 Spring 2.5.4로 Spring 3.2로 업그레이드 중입니다.Spring OpenSessionInView for Hibernate 4

봄 3.2 OpenSessionInViewFilter이 내 응용 프로그램에서 작동하는지 확인하고 싶습니다. 웹 응용 프로그램은 app1app2 두 가지가 있습니다. 워크 플로우는 app1 웹 페이지에서 "EDIT"버튼을 클릭하고 app1에 온라인 양식을 열고 사용자가 양식의 내용을 편집 한 다음 app1의 "PREVIEW"버튼을 클릭하면 두 번째 app2가 호출되어 PDF 파일이 생성됩니다 app2 웹 페이지에 표시하십시오. app1의 web.xml에

org.hibernate.HibernateException: collection is not associated with any session 
at org.hibernate.collection.internal.AbstractPersistentCollection.forceInitialization(AbstractPersistentCollection.java:676) 
at org.hibernate.engine.internal.StatefulPersistenceContext.initializeNonLazyCollections(StatefulPersistenceContext.java:1030) 
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:346) 
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:311) 
at org.hibernate.loader.Loader.loadEntity(Loader.java:2111) 
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:82) 
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:72) 
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3917) 
at org.hibernate.event.internal.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:460) 
at org.hibernate.event.internal.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:429) 
at org.hibernate.event.internal.DefaultLoadEventListener.load(DefaultLoadEventListener.java:206) 
at org.hibernate.event.internal.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:262) 
at org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:150) 
at org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:1091) 
at org.hibernate.internal.SessionImpl.access$2000(SessionImpl.java:174) 
at org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.load(SessionImpl.java:2473) 
at org.hibernate.internal.SessionImpl.get(SessionImpl.java:987) 
at com.test.ServiceDaoImpl.lookupStatus(ServiceDAOImpl.java:87) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
at java.lang.reflect.Method.invoke(Method.java:597) 
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) 
at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:80) 
at com.test.StatisticsAspect.monitor(StatisticsAspect.java:28) 
at com.test.runtime.aop.StatisticsAspect.repositoryMethod(StatisticsAspect.java:53) 
at sun.reflect.GeneratedMethodAccessor535.invoke(Unknown Source) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
at java.lang.reflect.Method.invoke(Method.java:597) 
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:621) 
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:610) 
at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:65) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) 
at org.springframework.aop.framework.adapter.AfterReturningAdviceInterceptor.invoke(AfterReturningAdviceInterceptor.java:50) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) 
at org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:55) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) 
at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:50) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) 
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) 
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:90) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) 
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) 
at $Proxy240.lookupStatus(Unknown Source) 
at com.test.GenerationServiceImpl.getFailedStatus(GenerationServiceImpl.java:804) 
at com.test.setFailed(GenerationServiceImpl.java:520) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
at java.lang.reflect.Method.invoke(Method.java:597) 
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) 
at org.springframework.aop.framework.adapter.AfterReturningAdviceInterceptor.invoke(AfterReturningAdviceInterceptor.java:50) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) 
at org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:55) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) 
at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:50) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) 
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:90) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) 
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) 
at $Proxy277.markCorrespondenceFailed(Unknown Source) 
at com.test.Failed(GeneratorImpl.java:124) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
at java.lang.reflect.Method.invoke(Method.java:597) 
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) 
at org.springframework.aop.framework.adapter.AfterReturningAdviceInterceptor.invoke(AfterReturningAdviceInterceptor.java:50) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) 
at org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:55) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) 
at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:50) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) 
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:90) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) 
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) 
at $Proxy290.correspondenceFailed(Unknown Source) 
at com.test.controllers.GenerateControllerImpl.checkrrors(GenerateControllerImpl.java:371) 
at com.test.controllers.GenerateControllerImpl.initalRequest(GenerateControllerImpl.java:121) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
at java.lang.reflect.Method.invoke(Method.java:597) 
at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176) 
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:439) 
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:427) 
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925) 
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856) 
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:915) 
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:811) 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) 
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:796) 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) 
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227) 
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125) 
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:301) 
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26) 
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) 
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:265) 
at com.test.servlet.filters.IcefacesSessionFilter.doFilterInternal(IcefacesSessionFilter.java:48) 
at com.test.servlet.filters.AbstractHttpServletFilter.doFilter(AbstractHttpServletFilter.java:31) 
at sun.reflect.GeneratedMethodAccessor530.invoke(Unknown Source) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
at java.lang.reflect.Method.invoke(Method.java:597) 
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) 
at org.springframework.aop.framework.adapter.AfterReturningAdviceInterceptor.invoke(AfterReturningAdviceInterceptor.java:50) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) 
at org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:55) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) 
at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:50) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) 
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:90) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) 
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) 
at $Proxy333.doFilter(Unknown Source) 
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275) 
at com.test.servlet.filters.AppNameFilter.doFilterInternal(AppNameFilter.java:39) 
at com.test.servlet.filters.AbstractHttpServletFilter.doFilter(AbstractHttpServletFilter.java:31) 
at sun.reflect.GeneratedMethodAccessor530.invoke(Unknown Source) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
at java.lang.reflect.Method.invoke(Method.java:597) 
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) 
at org.springframework.aop.framework.adapter.AfterReturningAdviceInterceptor.invoke(AfterReturningAdviceInterceptor.java:50) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) 
at org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:55) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) 
at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:50) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) 
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:90) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) 
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) 
at $Proxy333.doFilter(Unknown Source) 
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275) 
at com.test.servlet.filters.JamonFilter.doFilterInternal(JamonFilter.java:42) 
at com.test.servlet.filters.AbstractHttpServletFilter.doFilter(AbstractHttpServletFilter.java:31) 
at sun.reflect.GeneratedMethodAccessor530.invoke(Unknown Source) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
at java.lang.reflect.Method.invoke(Method.java:597) 
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) 
at org.springframework.aop.framework.adapter.AfterReturningAdviceInterceptor.invoke(AfterReturningAdviceInterceptor.java:50) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) 
at org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:55) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) 
at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:50) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) 
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:90) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) 
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) 
at $Proxy293.doFilter(Unknown Source) 
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275) 
at org.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:149) 
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346) 
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259) 
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) 
at org.springframework.orm.hibernate4.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:152) 
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) 
at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27) 
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) 
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3730) 
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3696) 
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) 
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120) 
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2273) 
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2179) 
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1490) 
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256) 

OpenSessionInViewFilter을 구현 : 사용자가 "PREVIEW"버튼을 클릭 한 후

나는 예외를 얻었다.

<filter> 
<filter-name>hibernateFilter</filter-name> 
<filter-class>org.springframework.orm.hibernate4.support.OpenSessionInViewFilter</filter- 
    class> 
<init-param>  
<param-name>sessionFactoryBeanName</param-name> 
<param-value>session.factory</param-value> 
</init-param> 
</filter> 

"미리보기"버튼 worked before upgrading Hibernate 3 and Spring 2.5.4. OpenSessionInViewFilter가 app1과 app2의 요청 중에 최대 절전 모드 세션 open을 유지할 수 있는지 궁금합니다. 업그레이드 후 왜 작동하지 않던 지 또는 이전에 효과가 있었던 이유는 무엇입니까?

감사합니다.

+0

'PREVIEW' 버튼 이후 정확히 무슨 일이 발생합니까?'HttpSession'에 저장된 액세스 콜렉션을 요청합니까? – Yogesh

+0

Hibernate 영역에서 특히 Spring 2.5.x와 Spring 3.2.x간에 많은 변화가있었습니다. 'OpenSessionInViewFilter'는 두 개의 다른 응용 프로그램에서 세션을 열어 놓을 것입니다. 귀하의 오류가 최대 절전 모드에 액세스하는 방법 및/또는 귀하의 거래를 구성하는 방법에 있기를 기대합니다. –

답변

0

두 명의 주석가, 특히 @M에게 감사드립니다. Deinum.

테이블 필드의 최대 절전 모드 매핑 중 하나를 type = "org.springframework.orm.hibernate3.support.BlobByteArrayType"에서 "materialized_blob"으로 변경하면 오류가 해결됩니다. 그러나 예외는 오해의 소지가 조금 있습니다.

+0

OpenSessionInViewFilter가 필요한 이유를 생각해보십시오.이 패턴을 사용하면 종종 도메인 객체가 클라이언트에 직접 보내지는 것을 의미합니다. 이는 종종 UI 관련 문제와 도메인 문제를 높은 수준으로 연결시킵니다. – Sudarshan

관련 문제