You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Adam Henderson Azudio <az...@hotmail.com> on 2005/02/02 01:44:18 UTC
Newb: Spring & Tapestry - I'm Stuck
Guys,
I'm having a bit of bother in integrating Spring into my Tapestry app
for its Hibernate features. I'm just trying to create a really light
app with little clutter just so I can learn the basics. So in my app
all I have is one persistent class, a DAO (Interace & Imp) and a
Manager (Interface & Imp)
I've followed the "Tapestry Spring" article on the Spring web site
(sort of) and have subclassed BasePage and overridden the
setForRequest() method, which should see if the Spring
applicationContext is in the global and if not create one with the
following line:
MyEngine.java
..
ac = WebApplicationContextUtils.getWebApplicationContext(sc);
..
however this is all executing without any exceptions/errors but all
that gets returned from the above call is null, ie: ac == null so
diddly is put in the global.
So as I'm not getting any errors, is this a configuation problem?
The applicationContext.xml file is at WEB-INF/applicationContext.xml
My Web.xml file:
<web-app>
<display-name>myapp</display-name>
<filter>
<filter-name>redirect</filter-name>
<filter-class>org.apache.tapestry.RedirectFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>redirect</filter-name>
<url-pattern>/</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>myapp</servlet-name>
<servlet-class>org.apache.tapestry.ApplicationServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>myapp</servlet-name>
<url-pattern>/app</url-pattern>
</servlet-mapping>
</web-app>
My applicationContext.xml file:
<beans>
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property
name="driverClassName"><value>com.mysql.jdbc.Driver</value></property>
<property
name="url"><value>jdbc:mysql://localhost/usemydrive</value></property>
<property name="username"><value>root</value></property>
<property name="password"><value></value></property>
</bean>
<!-- Hibernate SessionFactory -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
<property name="dataSource"><ref bean="dataSource"/></property>
<property name="mappingResources">
<list>
<value>com/azudio/umd/Booking.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop
key="hibernate.dialect">net.sf.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
</props>
</property>
</bean>
<!-- Transaction manager for a single Hibernate SessionFactory
(alternative to JTA) -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate.HibernateTransactionManager">
<property name="sessionFactory"><ref
local="sessionFactory"/></property>
</bean>
<!-- BookingDAO: Hibernate implementation -->
<bean id="bookingDAO" class="com.azudio.umd.dao.BookingDAOHibernate">
<property name="sessionFactory"><ref
local="sessionFactory"/></property>
</bean>
<bean id="BookingManager" parent="txProxyTemplate">
<property name="target">
<bean class="com.azudio.umd.service.BookingManager"
autowire="byName"/>
</property>
</bean>
<beans>
All I need is a really clear, simple example of a
Tapestry/Spring/Hibernate app with a simple bare bones config.
Cheers, sorry for the long post,
Adam Henderson
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Newb: Spring & Tapestry - I'm Stuck
Posted by Matt Raible <li...@raibledesigns.com>.
Add the following to your web.xml file:
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</
listener-class>
</listener>
For a simple Tapestry+Spring+Hibernate app, you might checkout Equinox
- http://equinox.dev.java.net.
HTH,
Matt
On Feb 1, 2005, at 5:44 PM, Adam Henderson Azudio wrote:
> Guys,
>
> I'm having a bit of bother in integrating Spring into my Tapestry app
> for its Hibernate features. I'm just trying to create a really light
> app with little clutter just so I can learn the basics. So in my app
> all I have is one persistent class, a DAO (Interace & Imp) and a
> Manager (Interface & Imp)
>
> I've followed the "Tapestry Spring" article on the Spring web site
> (sort of) and have subclassed BasePage and overridden the
> setForRequest() method, which should see if the Spring
> applicationContext is in the global and if not create one with the
> following line:
>
> MyEngine.java
> ..
> ac = WebApplicationContextUtils.getWebApplicationContext(sc);
> ..
>
> however this is all executing without any exceptions/errors but all
> that gets returned from the above call is null, ie: ac == null so
> diddly is put in the global.
>
> So as I'm not getting any errors, is this a configuation problem?
>
> The applicationContext.xml file is at WEB-INF/applicationContext.xml
>
> My Web.xml file:
> <web-app>
> <display-name>myapp</display-name>
>
> <filter>
> <filter-name>redirect</filter-name>
> <filter-class>org.apache.tapestry.RedirectFilter</filter-class>
> </filter>
>
> <filter-mapping>
> <filter-name>redirect</filter-name>
> <url-pattern>/</url-pattern>
> </filter-mapping>
>
> <servlet>
> <servlet-name>myapp</servlet-name>
> <servlet-class>org.apache.tapestry.ApplicationServlet</servlet-class>
> <load-on-startup>1</load-on-startup>
> </servlet>
>
> <servlet-mapping>
> <servlet-name>myapp</servlet-name>
> <url-pattern>/app</url-pattern>
> </servlet-mapping>
>
> </web-app>
>
> My applicationContext.xml file:
> <beans>
>
> <bean id="dataSource"
> class="org.springframework.jdbc.datasource.DriverManagerDataSource">
> <property
> name="driverClassName"><value>com.mysql.jdbc.Driver</value></property>
> <property
> name="url"><value>jdbc:mysql://localhost/usemydrive</value></property>
> <property name="username"><value>root</value></property>
> <property name="password"><value></value></property>
> </bean>
>
>
> <!-- Hibernate SessionFactory -->
> <bean id="sessionFactory"
> class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
> <property name="dataSource"><ref bean="dataSource"/></property>
> <property name="mappingResources">
> <list>
> <value>com/azudio/umd/Booking.hbm.xml</value>
> </list>
> </property>
>
> <property name="hibernateProperties">
> <props>
> <prop
> key="hibernate.dialect">net.sf.hibernate.dialect.MySQLDialect</prop>
> <prop key="hibernate.show_sql">true</prop>
> <prop key="hibernate.hbm2ddl.auto">update</prop>
> </props>
> </property>
> </bean>
>
> <!-- Transaction manager for a single Hibernate SessionFactory
> (alternative to JTA) -->
> <bean id="transactionManager"
> class="org.springframework.orm.hibernate.HibernateTransactionManager">
> <property name="sessionFactory"><ref
> local="sessionFactory"/></property>
> </bean>
>
> <!-- BookingDAO: Hibernate implementation -->
> <bean id="bookingDAO" class="com.azudio.umd.dao.BookingDAOHibernate">
> <property name="sessionFactory"><ref
> local="sessionFactory"/></property>
> </bean>
>
>
> <bean id="BookingManager" parent="txProxyTemplate">
> <property name="target">
> <bean class="com.azudio.umd.service.BookingManager"
> autowire="byName"/>
> </property>
> </bean>
>
> <beans>
>
>
> All I need is a really clear, simple example of a
> Tapestry/Spring/Hibernate app with a simple bare bones config.
>
> Cheers, sorry for the long post,
>
> Adam Henderson
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org