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<Office> 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:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="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" >
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${dataSource.driverClass}" />
<property name="username" value="${dataSource.user}" />
<property name="password" value="${dataSource.password}" />
<property name="url" value="${dataSource.jdbcURL}" />
</bean>
<!-- Hibernate session factory -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="configLocation" value="classpath:/hibernate.cfg.xml"/>
</bean>
<!-- Hibernate transaction manager -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<context:component-scan base-package="com.starpoint.helpdesk.dao" />
<context:annotation-config/>
</beans>
and my web.xml is simply:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>Starpoint Help Desk Tapestry 5 Application</display-name>
<context-param>
<!--
The only significant configuration for Tapestry 5, this informs
Tapestry
of where to look for pages, components and mixins.
-->
<param-name>tapestry.app-package</param-name>
<param-value>com.starpoint.helpdesk</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:/applicationContext.xml</param-value>
</context-param>
<filter>
<filter-name>app</filter-name>
<filter-class>org.apache.tapestry5.spring.TapestrySpringFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>app</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
Thanks in advance
Tony Nelson
Starpoint Solutions
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]