You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Toby Hobson <to...@btinternet.com> on 2008/04/30 18:59:47 UTC
Question about T5 and OpenSessionInViewFilter
Hi guys,
Anyone know af any "gotchas" re: using this filter in T5? I'm trying to display a collection of objects in my page but i'm getting hibernate LazyInitialization errors. Here's the relevant code:
Start.tml
<t:loop source="newPhotos" value="currentPhoto">
<div class="pic">
<img alt="#" src="${currentPhoto.imageResource}" width="64"
height="64" />
<h2>${photo.name}</h2>
By
<span>${photo.name}</span>
</div>
</t:loop>
Start.java
public class Start
{
@Inject
@Service("imageService")
private ImageService imageService;
private Photo currentPhoto;
public Collection<Photo> getNewPhotos() {
return imageService.getRecentUploads(5);
}
public Photo getCurrentPhoto() {
return currentPhoto;
}
public void setCurrentPhoto(Photo photo) {
this.currentPhoto = photo;
}
}
web.xml
<filter>
<filter-name>app</filter-name>
<!-- Special filter that adds in a T5 IoC module derived from the Spring WebApplicationContext. -->
<filter-class>
org.apache.tapestry.spring.TapestrySpringFilter
</filter-class>
</filter>
<filter>
<filter-name>hibernateFilter</filter-name>
<filter-class>
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>app</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>hibernateFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
And i get:
Render queue error inorg.apache.tapestry.internal.services.PageElementFactoryImpl$1@c74dfb:could not initialize proxy - the owning Session was closed
RE: Question about T5 and OpenSessionInViewFilter
Posted by Jonathan Barker <jo...@gmail.com>.
You might want to try reversing the order of your filter and filter-mapping
declarations in web.xml to put OpenSessionInViewFilter first.
Other than that, I would need to see your applicationContext.xml file.
Jonathan
> -----Original Message-----
> From: Toby Hobson [mailto:toby.hobson@btinternet.com]
> Sent: Wednesday, April 30, 2008 1:00 PM
> To: users@tapestry.apache.org
> Subject: Question about T5 and OpenSessionInViewFilter
>
> Hi guys,
>
> Anyone know af any "gotchas" re: using this filter in T5? I'm trying to
> display a collection of objects in my page but i'm getting hibernate
> LazyInitialization errors. Here's the relevant code:
>
> Start.tml
>
> <t:loop source="newPhotos" value="currentPhoto">
> <div class="pic">
> <img alt="#" src="${currentPhoto.imageResource}"
> width="64"
> height="64" />
> <h2>${photo.name}</h2>
> By
> <span>${photo.name}</span>
> </div>
> </t:loop>
>
> Start.java
>
> public class Start
> {
>
> @Inject
> @Service("imageService")
> private ImageService imageService;
>
> private Photo currentPhoto;
>
> public Collection<Photo> getNewPhotos() {
> return imageService.getRecentUploads(5);
> }
>
> public Photo getCurrentPhoto() {
> return currentPhoto;
> }
>
> public void setCurrentPhoto(Photo photo) {
> this.currentPhoto = photo;
> }
>
> }
>
> web.xml
>
> <filter>
> <filter-name>app</filter-name>
> <!-- Special filter that adds in a T5 IoC module derived from the
> Spring WebApplicationContext. -->
> <filter-class>
> org.apache.tapestry.spring.TapestrySpringFilter
> </filter-class>
> </filter>
>
> <filter>
> <filter-name>hibernateFilter</filter-name>
> <filter-class>
>
> org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
> </filter-class>
> </filter>
>
> <filter-mapping>
> <filter-name>app</filter-name>
> <url-pattern>/*</url-pattern>
> </filter-mapping>
>
> <filter-mapping>
> <filter-name>hibernateFilter</filter-name>
> <url-pattern>/*</url-pattern>
> </filter-mapping>
>
> And i get:
>
> Render queue error
> inorg.apache.tapestry.internal.services.PageElementFactoryImpl$1@c74dfb:co
> uld not initialize proxy - the owning Session was closed
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org