Re: Tapestry Hibernate Sessions

2011-06-10 Thread Tony Nelson

On Jun 10, 2011, at 11:32 AM, Thiago H. de Paula Figueiredo wrote:

> On Fri, 10 Jun 2011 12:12:01 -0300, Tony Nelson  wrote:
> 
>> So maybe I should have sent this question to the Spring list?
> 
> If you're not using Tapestry-Hibernate this question went to the wrong list. 
> :)
> 

Indeed it was a Spring related issue.  Doing some more searching I found that 
Spring requires @Transactional now, and I had only added my data access tier.  
Creating a quick business tier and marking the interface @Transactional solved 
the problem.  For anyone that may find this in [insert favorite search engine] 
later:

My interface for my business class:

package com.starpoint.helpdesk.business;

import com.starpoint.helpdesk.domain.Office;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Transactional(readOnly = true)
public interface OfficeLogic {

List getAllOffices();
}

The page was of course updated to call this method instead of the DAO directly. 
 The updated applicationContext.xml is:


http://www.springframework.org/schema/beans";
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
   xmlns:context="http://www.springframework.org/schema/context";
   xmlns:tx="http://www.springframework.org/schema/tx";
   xsi:schemaLocation="http://www.springframework.org/schema/beans
   http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
   http://www.springframework.org/schema/context
   http://www.springframework.org/schema/context/spring-context.xsd
   http://www.springframework.org/schema/tx 
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd";
default-autowire="byName" >



































Re: Tapestry Hibernate Sessions

2011-06-10 Thread Thiago H. de Paula Figueiredo
On Fri, 10 Jun 2011 11:47:58 -0300, Tony Nelson   
wrote:



Hi all,


Hi!

I fired up Jetty, and opened the page.  I really expected to get an  
exception saying that I don't have a database session because I  
purposely did not include the OpenSessionInView filter that I'm familiar  
with.  In addition I didn't include the tapestry-hibernate jars because  
I'm not sure if it's better to have Tap of Spring handle opening and  
closing the sessions.


You can't use Tapestry-Hibernate and Spring-Hibernate at the same time, as  
both manage Hibernate sessions and instantiates SessionFactory's (through  
the Configuration class, of course). And adding Tapestry-Hibernate to the  
classpath means it's being used.


--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor

Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Tapestry Hibernate Sessions

2011-06-10 Thread Thiago H. de Paula Figueiredo
On Fri, 10 Jun 2011 12:12:01 -0300, Tony Nelson   
wrote:



So maybe I should have sent this question to the Spring list?


If you're not using Tapestry-Hibernate this question went to the wrong  
list. :)


All the same, does anyone have any insight into what I may have done  
wrong?


Is your OpenSessionInViewFilter declared before the TapestryFilter? It  
should.


--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor

Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Tapestry Hibernate Sessions

2011-06-10 Thread Tony Nelson

On Jun 10, 2011, at 10:47 AM, Tony Nelson wrote:

> Hi all,
> 
> I'm in the process of rebuilding an app that was done in Tap3 (indeed!) in 
> Tap5.  It's a small app, maybe a dozen pages used by my internal staff.  This 
> is in preparation for rebuilding the entire front of a much larger app.  But 
> that's a story for another day.
> 
> Because I want to learn all the new Tap5 goodness, I started with an new 
> project built w/ the maven archetype.  I copied over my DB classes and added 
> the Spring dependencies I needed, and wrote a test case to make sure I could 
> read and write from my dev (h2) database.
> 
> Then I created a very small page that displays a few rows from the DB in a 
> table.  The service method is trivial:
> 
>@Log
>public List getOffices() {
>return officeDao.getAllOffices(); 
>}
> 
> I fired up Jetty, and opened the page.  I really expected to get an exception 
> saying that I don't have a database session because I purposely did not 
> include the OpenSessionInView filter that I'm familiar with.  In addition I 
> didn't include the tapestry-hibernate jars because I'm not sure if it's 
> better to have Tap of Spring handle opening and closing the sessions.
> 
> I was very surprised when the page actually rendered a result from the 
> database.  I'm still not clear where the session is coming from, but that is 
> actually my problem.  I can reload my tiny test page 8 times.  On the 9th 
> time, I see:
> 
> [582385532@qtp-918884489-5] DEBUG com.starpoint.helpdesk.pages.Offices  - 
> [ENTER] getOffices()
> 
> And the browser spins.  I can open the H2 DB in the H2 admin console and 
> issue queries against it, so the H2 instance is fine.
> 
> Obviously I'm either out of sessions or connection pool slots.  My goal is to 
> be able to use the Spring @Transactional annotation because in the larger app 
> rewrite I have several dozen business layer Spring managed beans that depend 
> on it.
> 
> I have tried adding Springs OpenSessionInViewFilter, and I've tried adding a 
> dependency on tapestry-hibernate-core.  Neither of these solutions have 
> helped.
> 
> Can anyone offer any suggestions as to where the session is actually coming 
> from so that I can try to figure out how to get the session closed or 
> released?
> 
> I have Spring configured like this:
> 
> 
> http://www.springframework.org/schema/beans";
>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>   xmlns:context="http://www.springframework.org/schema/context";
>   xsi:schemaLocation="http://www.springframework.org/schema/beans
>   http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
>   http://www.springframework.org/schema/context
>   http://www.springframework.org/schema/context/spring-context.xsd";
>default-autowire="byName" >
> 
>
>
>
>
>
>
> 
>
>  
> class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
>
>
>
> 
>
>  
> class="org.springframework.orm.hibernate3.HibernateTransactionManager">
>
>
> 
> 
>
>
> 
> 
> 
> and my web.xml is simply:
> 
> 
> PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
>"http://java.sun.com/dtd/web-app_2_3.dtd";>
> 
>Starpoint Help Desk Tapestry 5 Application
> 
>
>
>tapestry.app-package
>com.starpoint.helpdesk
>
> 
>
>contextConfigLocation
>classpath:/applicationContext.xml
>
> 
>
>app
>
> org.apache.tapestry5.spring.TapestrySpringFilter
>
> 
>
>app
>/*
>
> 
> 
> 

I turned on debug logging and get this when the request hangs:

[1828511825@qtp-68769219-3] DEBUG com.starpoint.helpdesk.pages.Offices  - 
[ENTER] getOffices()
[1828511825@qtp-68769219-3] DEBUG 
org.springframework.orm.hibernate3.SessionFactoryUtils  - Opening Hibernate 
Session
[1828511825@qtp-68769219-3] DEBUG org.hibernate.impl.SessionImpl  - opened 
session at timestamp: 13077185704
[1828511825@qtp-68769219-3] DEBUG org.hibernate.jdbc.AbstractBatcher  - about 
to open PreparedStatement (open PreparedStatements: 0, globally: 0)
[1828511825@qtp-68769219-3] DEBUG org.hibernate.jdbc.ConnectionManager  - 
opening JDBC connection

So maybe I should have sent this question to the Spring list?

All the same, does anyone have any insight into what I may have done wrong?


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org