I have an GWt application and I am making a simple crawler to improve my SEO. For that I am using HTMLUnit and a simple code that Google posted using a Filter.
在此过滤器中, 我需要访问数据库, 以装入一些数据, 而这里就是我得到这个例外的地方 。
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.tapeanding.domain.beans.TFichas.tfichasDescripcioneses, no session or session was closed
at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:380)
at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:372)
at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:365)
at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:108)
at org.hibernate.collection.PersistentSet.iterator(PersistentSet.java:186)
at com.tapeanding.server.op.impl.OpFicha.cargarDescripcion(OpFicha.java:223)
at com.tapeanding.server.op.impl.OpFicha.cargarFicha(OpFicha.java:85)
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:309)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
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:89)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at $Proxy38.cargarFicha(Unknown Source)
at com.tapeanding.server.servlets.CrawlServlet.generarFicha(CrawlServlet.java:198)
at com.tapeanding.server.servlets.CrawlServlet.doFilter(CrawlServlet.java:136)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1088)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:324)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:205)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
<!-- Sesion de apertura de Spring -->
<filter>
<filter-name>session-in-view</filter-name>
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
<init-param>
<param-name>singleSession</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<!-- Filtro para convertir el codigo en HTML -->
<filter>
<filter-name>crawler</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
<init-param>
<param-name>targetFilterLifecycle</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>session-in-view</filter-name>
<servlet-name>dispatcher</servlet-name>
</filter-mapping>
<filter-mapping>
<filter-name>crawler</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<强度 > - 应用程序- comtext. xml 强度 >
<!-- ========================= Crawler ========================================= -->
<bean id="crawler" class="com.tapeanding.server.servlets.CrawlServlet">
<property name="opFicha" ref="opFicha" />
</bean>
<bean id="opFicha" class="com.tapeanding.server.op.impl.OpFicha">
<property name="tFichasDAO" ref="tFichasDAO" />
<property name="tFichasComentariosDAO" ref="tFichasComentariosDAO" />
</bean>
<bean id="tFichasDAO" class="com.tapeanding.server.daos.impl.TFichasDAO">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<bean id="tFichasDescripcionesDAO" class="com.tapeanding.server.daos.impl.TFichasDescripcionesDAO">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
我不想使用“lazy=false”标签,
Some ideas? Why is this happening when I try to use a bean in a Filter if I m using the OpenSessionInViewFilter filter?
谢谢