Can't get Tapestry5 to work with Spring

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Can't get Tapestry5 to work with Spring

dderry

I'm new to Tapestry. I've been wanting to take a look at it for some time,
and have a bit of time here at the end of the year. I've started with
Howard's tutorial for Tap5 and got the first stage of that working easily.
So then I created another simple page, and linked to that. Still working
fine, so time to start getting into something 'real'. Since we use Spring
for all our projects here I figured that should be my next step. I created
an iBatis DAO that accesses one of our existing JNDI datasources, with the
intent of having my page retrieve data from it for displaying.

I followed the steps described here:
http://tapestry.apache.org/tapestry5/tapestry-spring/, but the dao is not
getting injected; I get a NPE when it comes time to access it. My logs show
the initialization completing correctly, with the Spring beans being
created. Is there anything missing fom this description to complete the
wiring?

I'm using Tapestry5.0.6, Spring2.0.1 (though I also tried 1.2.8),
iBatis2.3.0.677, running in Sun Appserver8.2

Here's my web.xml:

<web-app>
          <display-name>tapestry-tutorial1 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>org.apache.tapestry.tutorial</param-value>
          </context-param>

                  <context-param>
                        <param-name>contextConfigLocation</param-name>
                        <param-value>

classpath:org/apache/tapestry/tutorial/applicationContext.xml
                        </param-value>
                  </context-param>

          <filter>
              <filter-name>app</filter-name>
              <!--

<filter-class>org.apache.tapestry.TapestryFilter</filter-class>
               -->
               <filter-class>
org.apache.tapestry.spring.TapestrySpringFilter</filter-class>
          </filter>
          <filter-mapping>
              <filter-name>app</filter-name>
              <url-pattern>/*</url-pattern>
          </filter-mapping>

                  <listener>
                    <listener-class>
org.springframework.web.context.ContextLoaderListener</listener-class>
                  </listener>
</web-app>


org/apache/tapestry/tutorial/applicationContext.xml:

<beans xmlns="http://www.springframework.org/schema/beans"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

      <import resource=
"classpath:org/apache/tapestry/tutorial/dao/applicationContext-jndi.xml"/>
      <import resource=
"classpath:org/apache/tapestry/tutorial/dao/ibatis/applicationContext.xml"
/>
</beans>


org/apache/tapestry/tutorial/dao/applicationContext-jndi.xml:

<beans xmlns="http://www.springframework.org/schema/beans"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

      <bean id="serviceDataSource" class=
"org.springframework.jndi.JndiObjectFactoryBean">
            <property name="jndiName" value="srServiceDataSource"/>
      </bean>
</beans>


org/apache/tapestry/tutorial/dao/ibatis/applicationContext.xml:

<beans xmlns="http://www.springframework.org/schema/beans"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

      <bean id="sqlMapClient" class=
"org.springframework.orm.ibatis.SqlMapClientFactoryBean">
            <property name="configLocation" value=
"classpath:org/apache/tapestry/tutorial/dao/ibatis/sql-map-config.xml" />
            <property name="dataSource" ref="serviceDataSource" />
      </bean>

      <bean name="serviceDao" class=
"org.apache.tapestry.tutorial.dao.ibatis.ServiceDaoImpl">
            <property name="sqlMapClient" ref="sqlMapClient" />
      </bean>
</beans>


And in my page class:

public class Target
{
    @Inject
    @Service("serviceDao")
    private ServiceDao dao;

    public List<String> getOptions()
    {
        return dao.getOptions();               ///  NPE here!! getOptions()
in the dao returns a hard-coded list at this time
    }

    public void setDao(final ServiceDao _dao)
    {
        this.dao = _dao;
    }
    public ServiceDao getDao()
    {
        return dao;
    }
}

I haven't tried the alternate methods presented, but just by looking at
them I know that I will not be able to convince the other developers to
give Tapestry a try if it's necessary to go through that in order to use
Spring. Hopefully I'm just missing something simple and I'll be able to get
this method working. But I've been struggling with it for the better part
of 2 days now.

Dave

We must begin not just to act, but to think, for there is no better slave
than the one who believes his slavery to be freedom, and we are in
no greater peril than when we cannot see the chains on our minds
because there are yet no chains on our feet.
-- Michael Reid


This message contains information from Equifax Inc. which may be
confidential and privileged.  If you are not an intended recipient, please
refrain from any disclosure, copying, distribution or use of this
information and note that such actions are prohibited.  If you have
received this transmission in error, please notify by e-mail
[hidden email].



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Can't get Tapestry5 to work with Spring

Emmanuel Sowah
I also have many problems trying to integrate T5 with spring. Scary!!!

On Dec 19, 2007 7:26 PM, <[hidden email]> wrote:

>
> I'm new to Tapestry. I've been wanting to take a look at it for some time,
> and have a bit of time here at the end of the year. I've started with
> Howard's tutorial for Tap5 and got the first stage of that working easily.
> So then I created another simple page, and linked to that. Still working
> fine, so time to start getting into something 'real'. Since we use Spring
> for all our projects here I figured that should be my next step. I created
> an iBatis DAO that accesses one of our existing JNDI datasources, with the
> intent of having my page retrieve data from it for displaying.
>
> I followed the steps described here:
> http://tapestry.apache.org/tapestry5/tapestry-spring/, but the dao is not
> getting injected; I get a NPE when it comes time to access it. My logs
> show
> the initialization completing correctly, with the Spring beans being
> created. Is there anything missing fom this description to complete the
> wiring?
>
> I'm using Tapestry5.0.6, Spring2.0.1 (though I also tried 1.2.8),
> iBatis2.3.0.677, running in Sun Appserver8.2
>
> Here's my web.xml:
>
> <web-app>
>          <display-name>tapestry-tutorial1 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>org.apache.tapestry.tutorial</param-value>
>          </context-param>
>
>                  <context-param>
>                        <param-name>contextConfigLocation</param-name>
>                        <param-value>
>
> classpath:org/apache/tapestry/tutorial/applicationContext.xml
>                        </param-value>
>                  </context-param>
>
>          <filter>
>              <filter-name>app</filter-name>
>              <!--
>
> <filter-class>org.apache.tapestry.TapestryFilter</filter-class>
>               -->
>               <filter-class>
> org.apache.tapestry.spring.TapestrySpringFilter</filter-class>
>          </filter>
>          <filter-mapping>
>              <filter-name>app</filter-name>
>              <url-pattern>/*</url-pattern>
>          </filter-mapping>
>
>                  <listener>
>                    <listener-class>
> org.springframework.web.context.ContextLoaderListener</listener-class>
>                  </listener>
> </web-app>
>
>
> org/apache/tapestry/tutorial/applicationContext.xml:
>
> <beans xmlns="http://www.springframework.org/schema/beans"
>            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>            xsi:schemaLocation="http://www.springframework.org/schema/beans
>
> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
>
>      <import resource=
> "classpath:org/apache/tapestry/tutorial/dao/applicationContext-jndi.xml"/>
>      <import resource=
> "classpath:org/apache/tapestry/tutorial/dao/ibatis/applicationContext.xml"
> />
> </beans>
>
>
> org/apache/tapestry/tutorial/dao/applicationContext-jndi.xml:
>
> <beans xmlns="http://www.springframework.org/schema/beans"
>            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>            xsi:schemaLocation="http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
>
>      <bean id="serviceDataSource" class=
> "org.springframework.jndi.JndiObjectFactoryBean">
>            <property name="jndiName" value="srServiceDataSource"/>
>      </bean>
> </beans>
>
>
> org/apache/tapestry/tutorial/dao/ibatis/applicationContext.xml:
>
> <beans xmlns="http://www.springframework.org/schema/beans"
>            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>            xsi:schemaLocation="http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
>
>      <bean id="sqlMapClient" class=
> "org.springframework.orm.ibatis.SqlMapClientFactoryBean">
>            <property name="configLocation" value=
> "classpath:org/apache/tapestry/tutorial/dao/ibatis/sql-map-config.xml" />
>            <property name="dataSource" ref="serviceDataSource" />
>      </bean>
>
>      <bean name="serviceDao" class=
> "org.apache.tapestry.tutorial.dao.ibatis.ServiceDaoImpl">
>            <property name="sqlMapClient" ref="sqlMapClient" />
>      </bean>
> </beans>
>
>
> And in my page class:
>
> public class Target
> {
>    @Inject
>    @Service("serviceDao")
>    private ServiceDao dao;
>
>    public List<String> getOptions()
>    {
>        return dao.getOptions();               ///  NPE here!! getOptions()
> in the dao returns a hard-coded list at this time
>    }
>
>    public void setDao(final ServiceDao _dao)
>    {
>        this.dao = _dao;
>    }
>    public ServiceDao getDao()
>    {
>        return dao;
>    }
> }
>
> I haven't tried the alternate methods presented, but just by looking at
> them I know that I will not be able to convince the other developers to
> give Tapestry a try if it's necessary to go through that in order to use
> Spring. Hopefully I'm just missing something simple and I'll be able to
> get
> this method working. But I've been struggling with it for the better part
> of 2 days now.
>
> Dave
>
> We must begin not just to act, but to think, for there is no better slave
> than the one who believes his slavery to be freedom, and we are in
> no greater peril than when we cannot see the chains on our minds
> because there are yet no chains on our feet.
> -- Michael Reid
>
>
> This message contains information from Equifax Inc. which may be
> confidential and privileged.  If you are not an intended recipient, please
> refrain from any disclosure, copying, distribution or use of this
> information and note that such actions are prohibited.  If you have
> received this transmission in error, please notify by e-mail
> [hidden email].
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

RE: Can't get Tapestry5 to work with Spring

JWiegman
In reply to this post by dderry
Dave,

I have Tapestry 5.0.5, Spring 2.0.4, and Sun Appserver 9 all working in
harmony.  Haven't really had any problems at all.

Based on your post, it sounds like Tapestry is finding and initializing
the beans.  That's the toughest part, so if that's true, I might suggest
to just simplify things a little:

* Put one simple named bean in your applicationContext.xml
* Then instead of using the @Service annotation, just name your member
variable the same as the bean name
* Make sure your @Inject annotations are in a page or component class
(NOTE: this is important, because Tapestry doesn't just scan your entire
classpath and look for these annotations, it only looks in the
"Component Packages" (see here:
http://tapestry.formos.com/nightly/tapestry5/tapestry-core/guide/compone
nt-classes.html )).

Hope that helps.  Here's some sample source:

<beans xmlns="http://www.springframework.org/schema/beans"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 
xsi:schemaLocation="http://www.springframework.org/schema/beans 
 
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
      <bean name="serviceDao" class="com.foo.ServiceDaoImpl"/>
</beans>

public class Target
{
    @Inject
    private ServiceDao serviceDao;  // <-- NOTE CHANGE

    public List<String> getOptions()
    {
        return dao.getOptions();               ///  NPE here!!
getOptions()
in the dao returns a hard-coded list at this time
    }

    public void setDao(final ServiceDao _dao)
    {
        this.dao = _dao;
    }
    public ServiceDao getDao()
    {
        return dao;
    }
}


-----Original Message-----
From: [hidden email] [mailto:[hidden email]]
Sent: Wednesday, December 19, 2007 1:27 PM
To: [hidden email]
Subject: Can't get Tapestry5 to work with Spring


I'm new to Tapestry. I've been wanting to take a look at it for some
time, and have a bit of time here at the end of the year. I've started
with Howard's tutorial for Tap5 and got the first stage of that working
easily.
So then I created another simple page, and linked to that. Still working
fine, so time to start getting into something 'real'. Since we use
Spring for all our projects here I figured that should be my next step.
I created an iBatis DAO that accesses one of our existing JNDI
datasources, with the intent of having my page retrieve data from it for
displaying.

I followed the steps described here:
http://tapestry.apache.org/tapestry5/tapestry-spring/, but the dao is
not getting injected; I get a NPE when it comes time to access it. My
logs show the initialization completing correctly, with the Spring beans
being created. Is there anything missing fom this description to
complete the wiring?

I'm using Tapestry5.0.6, Spring2.0.1 (though I also tried 1.2.8),
iBatis2.3.0.677, running in Sun Appserver8.2

Here's my web.xml:

<web-app>
          <display-name>tapestry-tutorial1 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>org.apache.tapestry.tutorial</param-value>
          </context-param>

                  <context-param>
                        <param-name>contextConfigLocation</param-name>
                        <param-value>

classpath:org/apache/tapestry/tutorial/applicationContext.xml
                        </param-value>
                  </context-param>

          <filter>
              <filter-name>app</filter-name>
              <!--

<filter-class>org.apache.tapestry.TapestryFilter</filter-class>
               -->
               <filter-class>
org.apache.tapestry.spring.TapestrySpringFilter</filter-class>
          </filter>
          <filter-mapping>
              <filter-name>app</filter-name>
              <url-pattern>/*</url-pattern>
          </filter-mapping>

                  <listener>
                    <listener-class>
org.springframework.web.context.ContextLoaderListener</listener-class>
                  </listener>
</web-app>


org/apache/tapestry/tutorial/applicationContext.xml:

<beans xmlns="http://www.springframework.org/schema/beans"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 
xsi:schemaLocation="http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

      <import resource=
"classpath:org/apache/tapestry/tutorial/dao/applicationContext-jndi.xml"
/>
      <import resource=
"classpath:org/apache/tapestry/tutorial/dao/ibatis/applicationContext.xm
l"
/>
</beans>


org/apache/tapestry/tutorial/dao/applicationContext-jndi.xml:

<beans xmlns="http://www.springframework.org/schema/beans"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

      <bean id="serviceDataSource" class=
"org.springframework.jndi.JndiObjectFactoryBean">
            <property name="jndiName" value="srServiceDataSource"/>
      </bean>
</beans>


org/apache/tapestry/tutorial/dao/ibatis/applicationContext.xml:

<beans xmlns="http://www.springframework.org/schema/beans"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

      <bean id="sqlMapClient" class=
"org.springframework.orm.ibatis.SqlMapClientFactoryBean">
            <property name="configLocation" value=
"classpath:org/apache/tapestry/tutorial/dao/ibatis/sql-map-config.xml"
/>
            <property name="dataSource" ref="serviceDataSource" />
      </bean>

      <bean name="serviceDao" class=
"org.apache.tapestry.tutorial.dao.ibatis.ServiceDaoImpl">
            <property name="sqlMapClient" ref="sqlMapClient" />
      </bean>
</beans>


And in my page class:

public class Target
{
    @Inject
    @Service("serviceDao")
    private ServiceDao dao;

    public List<String> getOptions()
    {
        return dao.getOptions();               ///  NPE here!!
getOptions()
in the dao returns a hard-coded list at this time
    }

    public void setDao(final ServiceDao _dao)
    {
        this.dao = _dao;
    }
    public ServiceDao getDao()
    {
        return dao;
    }
}

I haven't tried the alternate methods presented, but just by looking at
them I know that I will not be able to convince the other developers to
give Tapestry a try if it's necessary to go through that in order to use
Spring. Hopefully I'm just missing something simple and I'll be able to
get this method working. But I've been struggling with it for the better
part of 2 days now.

Dave

We must begin not just to act, but to think, for there is no better
slave than the one who believes his slavery to be freedom, and we are in
no greater peril than when we cannot see the chains on our minds because
there are yet no chains on our feet.
-- Michael Reid


This message contains information from Equifax Inc. which may be
confidential and privileged.  If you are not an intended recipient,
please refrain from any disclosure, copying, distribution or use of this
information and note that such actions are prohibited.  If you have
received this transmission in error, please notify by e-mail
[hidden email].



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Can't get Tapestry5 to work with Spring

Howard Lewis Ship
On Dec 19, 2007 10:58 AM, Joel Wiegman <[hidden email]> wrote:

> Dave,
>
> I have Tapestry 5.0.5, Spring 2.0.4, and Sun Appserver 9 all working in
> harmony.  Haven't really had any problems at all.
>
> Based on your post, it sounds like Tapestry is finding and initializing
> the beans.  That's the toughest part, so if that's true, I might suggest
> to just simplify things a little:
>
> * Put one simple named bean in your applicationContext.xml
> * Then instead of using the @Service annotation, just name your member
> variable the same as the bean name
> * Make sure your @Inject annotations are in a page or component class
> (NOTE: this is important, because Tapestry doesn't just scan your entire
> classpath and look for these annotations, it only looks in the
> "Component Packages" (see here:
> http://tapestry.formos.com/nightly/tapestry5/tapestry-core/guide/compone
> nt-classes.html )).
>
> Hope that helps.  Here's some sample source:
>
> <beans xmlns="http://www.springframework.org/schema/beans"
>             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>
> xsi:schemaLocation="http://www.springframework.org/schema/beans
>
> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
>       <bean name="serviceDao" class="com.foo.ServiceDaoImpl"/>
> </beans>
>
> public class Target
> {
>     @Inject
>     private ServiceDao serviceDao;  // <-- NOTE CHANGE

For this kind of service injection, Tapestry does not care about the
field name.  That is used in certain other types of specialized
injection.

I agree that the first step is to create a simple Spring bean and
inject that, then work up to more complex cases.

The fact thaqt you can get an NPE is suprising.  Is your field
private?  It must be (5.0.7 will enforce this more strictly).  Are you
using the special filter provided by tapestry-spring?  Also check you
console and log output carefully.


>
>     public List<String> getOptions()
>     {
>         return dao.getOptions();               ///  NPE here!!
> getOptions()
> in the dao returns a hard-coded list at this time
>     }
>
>     public void setDao(final ServiceDao _dao)
>     {
>         this.dao = _dao;
>     }
>     public ServiceDao getDao()
>     {
>         return dao;
>     }
> }
>
>
>
> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]]
> Sent: Wednesday, December 19, 2007 1:27 PM
> To: [hidden email]
> Subject: Can't get Tapestry5 to work with Spring
>
>
> I'm new to Tapestry. I've been wanting to take a look at it for some
> time, and have a bit of time here at the end of the year. I've started
> with Howard's tutorial for Tap5 and got the first stage of that working
> easily.
> So then I created another simple page, and linked to that. Still working
> fine, so time to start getting into something 'real'. Since we use
> Spring for all our projects here I figured that should be my next step.
> I created an iBatis DAO that accesses one of our existing JNDI
> datasources, with the intent of having my page retrieve data from it for
> displaying.
>
> I followed the steps described here:
> http://tapestry.apache.org/tapestry5/tapestry-spring/, but the dao is
> not getting injected; I get a NPE when it comes time to access it. My
> logs show the initialization completing correctly, with the Spring beans
> being created. Is there anything missing fom this description to
> complete the wiring?
>
> I'm using Tapestry5.0.6, Spring2.0.1 (though I also tried 1.2.8),
> iBatis2.3.0.677, running in Sun Appserver8.2
>
> Here's my web.xml:
>
> <web-app>
>           <display-name>tapestry-tutorial1 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>org.apache.tapestry.tutorial</param-value>
>           </context-param>
>
>                   <context-param>
>                         <param-name>contextConfigLocation</param-name>
>                         <param-value>
>
> classpath:org/apache/tapestry/tutorial/applicationContext.xml
>                         </param-value>
>                   </context-param>
>
>           <filter>
>               <filter-name>app</filter-name>
>               <!--
>
> <filter-class>org.apache.tapestry.TapestryFilter</filter-class>
>                -->
>                <filter-class>
> org.apache.tapestry.spring.TapestrySpringFilter</filter-class>
>           </filter>
>           <filter-mapping>
>               <filter-name>app</filter-name>
>               <url-pattern>/*</url-pattern>
>           </filter-mapping>
>
>                   <listener>
>                     <listener-class>
> org.springframework.web.context.ContextLoaderListener</listener-class>
>                   </listener>
> </web-app>
>
>
> org/apache/tapestry/tutorial/applicationContext.xml:
>
> <beans xmlns="http://www.springframework.org/schema/beans"
>             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>
> xsi:schemaLocation="http://www.springframework.org/schema/beans
>
> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
>
>       <import resource=
> "classpath:org/apache/tapestry/tutorial/dao/applicationContext-jndi.xml"
> />
>       <import resource=
> "classpath:org/apache/tapestry/tutorial/dao/ibatis/applicationContext.xm
> l"
> />
> </beans>
>
>
> org/apache/tapestry/tutorial/dao/applicationContext-jndi.xml:
>
> <beans xmlns="http://www.springframework.org/schema/beans"
>             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>
> xsi:schemaLocation="http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
>
>       <bean id="serviceDataSource" class=
> "org.springframework.jndi.JndiObjectFactoryBean">
>             <property name="jndiName" value="srServiceDataSource"/>
>       </bean>
> </beans>
>
>
> org/apache/tapestry/tutorial/dao/ibatis/applicationContext.xml:
>
> <beans xmlns="http://www.springframework.org/schema/beans"
>             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>
> xsi:schemaLocation="http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
>
>       <bean id="sqlMapClient" class=
> "org.springframework.orm.ibatis.SqlMapClientFactoryBean">
>             <property name="configLocation" value=
> "classpath:org/apache/tapestry/tutorial/dao/ibatis/sql-map-config.xml"
> />
>             <property name="dataSource" ref="serviceDataSource" />
>       </bean>
>
>       <bean name="serviceDao" class=
> "org.apache.tapestry.tutorial.dao.ibatis.ServiceDaoImpl">
>             <property name="sqlMapClient" ref="sqlMapClient" />
>       </bean>
> </beans>
>
>
> And in my page class:
>
> public class Target
> {
>     @Inject
>     @Service("serviceDao")
>     private ServiceDao dao;
>
>     public List<String> getOptions()
>     {
>         return dao.getOptions();               ///  NPE here!!
> getOptions()
> in the dao returns a hard-coded list at this time
>     }
>
>     public void setDao(final ServiceDao _dao)
>     {
>         this.dao = _dao;
>     }
>     public ServiceDao getDao()
>     {
>         return dao;
>     }
> }
>
> I haven't tried the alternate methods presented, but just by looking at
> them I know that I will not be able to convince the other developers to
> give Tapestry a try if it's necessary to go through that in order to use
> Spring. Hopefully I'm just missing something simple and I'll be able to
> get this method working. But I've been struggling with it for the better
> part of 2 days now.
>
> Dave
>
> We must begin not just to act, but to think, for there is no better
> slave than the one who believes his slavery to be freedom, and we are in
> no greater peril than when we cannot see the chains on our minds because
> there are yet no chains on our feet.
> -- Michael Reid
>
>
> This message contains information from Equifax Inc. which may be
> confidential and privileged.  If you are not an intended recipient,
> please refrain from any disclosure, copying, distribution or use of this
> information and note that such actions are prohibited.  If you have
> received this transmission in error, please notify by e-mail
> [hidden email].
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>



--
Howard M. Lewis Ship
TWD Consulting, Inc.

Creator Apache Tapestry and Apache HiveMind

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: Can't get Tapestry5 to work with Spring

dderry
In reply to this post by JWiegman
Joel,

Simplifying is, of course, a good suggestion. So I reduced my DAO to a
plain POJO (no longer extends SqlMapClientDaoSupport, or has any
dependencies). Now I'm getting a different error.

When I attempt to retrieve the 'safe' page; the original start page from
the tutorial, to which I added a link to my new test page I get this error:

2007-12-21 10:36:28,362 5ERROR [httpWorkerThread-9090-1]
(DefaultRequestExceptionHandler.java:50) - Processing of request failed
with uncaught exception: Exception constructing service 'TimingFilter':
Error invoking service builder method
org.apache.tapestry.tutorial.services.AppModule.buildTimingFilter(Log) (at
AppModule.java:65) (for service 'TimingFilter'): No service implements the
interface org.apache.commons.logging.Log.
java.lang.RuntimeException: Exception constructing service 'TimingFilter':
Error invoking service builder method
org.apache.tapestry.tutorial.services.AppModule.buildTimingFilter(Log) (at
AppModule.java:65) (for service 'TimingFilter'): No service implements the
interface org.apache.commons.logging.Log.

Any hints on how to get around this?

Dave

We must begin not just to act, but to think, for there is no better slave
than the one who believes his slavery to be freedom, and we are in
no greater peril than when we cannot see the chains on our minds
because there are yet no chains on our feet.
-- Michael Reid




                                                                           
             "Joel Wiegman"                                                
             <JoelWiegman@dswi                                            
             nc.com>                                                    To
                                       "Tapestry users"                    
             12/19/2007 01:58          <[hidden email]>        
             PM                                                         cc
                                                                           
                                                                   Subject
             Please respond to         RE: Can't get Tapestry5 to work    
             "Tapestry users"          with Spring                        
             <[hidden email]                                            
                pache.org>                                                
                                                                           
                                                                           
                                                                           
                                                                           




Dave,

I have Tapestry 5.0.5, Spring 2.0.4, and Sun Appserver 9 all working in
harmony.  Haven't really had any problems at all.

Based on your post, it sounds like Tapestry is finding and initializing
the beans.  That's the toughest part, so if that's true, I might suggest
to just simplify things a little:

* Put one simple named bean in your applicationContext.xml
* Then instead of using the @Service annotation, just name your member
variable the same as the bean name
* Make sure your @Inject annotations are in a page or component class
(NOTE: this is important, because Tapestry doesn't just scan your entire
classpath and look for these annotations, it only looks in the
"Component Packages" (see here:
http://tapestry.formos.com/nightly/tapestry5/tapestry-core/guide/compone
nt-classes.html )).

Hope that helps.  Here's some sample source:

<beans xmlns="http://www.springframework.org/schema/beans"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
      <bean name="serviceDao" class="com.foo.ServiceDaoImpl"/>
</beans>

public class Target
{
    @Inject
    private ServiceDao serviceDao;  // <-- NOTE CHANGE

    public List<String> getOptions()
    {
        return dao.getOptions();               ///  NPE here!!
getOptions()
in the dao returns a hard-coded list at this time
    }

    public void setDao(final ServiceDao _dao)
    {
        this.dao = _dao;
    }
    public ServiceDao getDao()
    {
        return dao;
    }
}


-----Original Message-----
From: [hidden email] [mailto:[hidden email]]
Sent: Wednesday, December 19, 2007 1:27 PM
To: [hidden email]
Subject: Can't get Tapestry5 to work with Spring


I'm new to Tapestry. I've been wanting to take a look at it for some
time, and have a bit of time here at the end of the year. I've started
with Howard's tutorial for Tap5 and got the first stage of that working
easily.
So then I created another simple page, and linked to that. Still working
fine, so time to start getting into something 'real'. Since we use
Spring for all our projects here I figured that should be my next step.
I created an iBatis DAO that accesses one of our existing JNDI
datasources, with the intent of having my page retrieve data from it for
displaying.

I followed the steps described here:
http://tapestry.apache.org/tapestry5/tapestry-spring/, but the dao is
not getting injected; I get a NPE when it comes time to access it. My
logs show the initialization completing correctly, with the Spring beans
being created. Is there anything missing fom this description to
complete the wiring?

I'm using Tapestry5.0.6, Spring2.0.1 (though I also tried 1.2.8),
iBatis2.3.0.677, running in Sun Appserver8.2

Here's my web.xml:

<web-app>
          <display-name>tapestry-tutorial1 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>org.apache.tapestry.tutorial</param-value>
          </context-param>

                  <context-param>
                        <param-name>contextConfigLocation</param-name>
                        <param-value>

classpath:org/apache/tapestry/tutorial/applicationContext.xml
                        </param-value>
                  </context-param>

          <filter>
              <filter-name>app</filter-name>
              <!--
<filter-class>org.apache.tapestry.TapestryFilter</filter-class>
-->
               <filter-class>
org.apache.tapestry.spring.TapestrySpringFilter</filter-class>
          </filter>
          <filter-mapping>
              <filter-name>app</filter-name>
              <url-pattern>/*</url-pattern>
          </filter-mapping>

                  <listener>
                    <listener-class>
org.springframework.web.context.ContextLoaderListener</listener-class>
                  </listener>
</web-app>


org/apache/tapestry/tutorial/applicationContext.xml:

<beans xmlns="http://www.springframework.org/schema/beans"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

      <import resource=
"classpath:org/apache/tapestry/tutorial/dao/applicationContext-jndi.xml"
/>
      <import resource=
"classpath:org/apache/tapestry/tutorial/dao/ibatis/applicationContext.xm
l"
/>
</beans>


org/apache/tapestry/tutorial/dao/applicationContext-jndi.xml:

<beans xmlns="http://www.springframework.org/schema/beans"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

      <bean id="serviceDataSource" class=
"org.springframework.jndi.JndiObjectFactoryBean">
            <property name="jndiName" value="srServiceDataSource"/>
      </bean>
</beans>


org/apache/tapestry/tutorial/dao/ibatis/applicationContext.xml:

<beans xmlns="http://www.springframework.org/schema/beans"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

      <bean id="sqlMapClient" class=
"org.springframework.orm.ibatis.SqlMapClientFactoryBean">
            <property name="configLocation" value=
"classpath:org/apache/tapestry/tutorial/dao/ibatis/sql-map-config.xml"
/>
            <property name="dataSource" ref="serviceDataSource" />
      </bean>

      <bean name="serviceDao" class=
"org.apache.tapestry.tutorial.dao.ibatis.ServiceDaoImpl">
            <property name="sqlMapClient" ref="sqlMapClient" />
      </bean>
</beans>


And in my page class:

public class Target
{
    @Inject
    @Service("serviceDao")
    private ServiceDao dao;

    public List<String> getOptions()
    {
        return dao.getOptions();               ///  NPE here!!
getOptions()
in the dao returns a hard-coded list at this time
    }

    public void setDao(final ServiceDao _dao)
    {
        this.dao = _dao;
    }
    public ServiceDao getDao()
    {
        return dao;
    }
}

I haven't tried the alternate methods presented, but just by looking at
them I know that I will not be able to convince the other developers to
give Tapestry a try if it's necessary to go through that in order to use
Spring. Hopefully I'm just missing something simple and I'll be able to
get this method working. But I've been struggling with it for the better
part of 2 days now.

Dave

We must begin not just to act, but to think, for there is no better
slave than the one who believes his slavery to be freedom, and we are in
no greater peril than when we cannot see the chains on our minds because
there are yet no chains on our feet.
-- Michael Reid


This message contains information from Equifax Inc. which may be
confidential and privileged.  If you are not an intended recipient,
please refrain from any disclosure, copying, distribution or use of this
information and note that such actions are prohibited.  If you have
received this transmission in error, please notify by e-mail
[hidden email].



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]





---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Can't get Tapestry5 to work with Spring

Howard Lewis Ship
Between release 5.0.5 and 5.0.6 Tapestry switched from commons-logging
to SLF4J.  You want to be injecting an org.slf4j.Logger instead.

On Dec 21, 2007 7:44 AM,  <[hidden email]> wrote:

> Joel,
>
> Simplifying is, of course, a good suggestion. So I reduced my DAO to a
> plain POJO (no longer extends SqlMapClientDaoSupport, or has any
> dependencies). Now I'm getting a different error.
>
> When I attempt to retrieve the 'safe' page; the original start page from
> the tutorial, to which I added a link to my new test page I get this error:
>
> 2007-12-21 10:36:28,362 5ERROR [httpWorkerThread-9090-1]
> (DefaultRequestExceptionHandler.java:50) - Processing of request failed
> with uncaught exception: Exception constructing service 'TimingFilter':
> Error invoking service builder method
> org.apache.tapestry.tutorial.services.AppModule.buildTimingFilter(Log) (at
> AppModule.java:65) (for service 'TimingFilter'): No service implements the
> interface org.apache.commons.logging.Log.
> java.lang.RuntimeException: Exception constructing service 'TimingFilter':
> Error invoking service builder method
> org.apache.tapestry.tutorial.services.AppModule.buildTimingFilter(Log) (at
> AppModule.java:65) (for service 'TimingFilter'): No service implements the
> interface org.apache.commons.logging.Log.
>
> Any hints on how to get around this?
>
> Dave
>
> We must begin not just to act, but to think, for there is no better slave
> than the one who believes his slavery to be freedom, and we are in
> no greater peril than when we cannot see the chains on our minds
> because there are yet no chains on our feet.
> -- Michael Reid
>
>
>
>
>
>              "Joel Wiegman"
>              <JoelWiegman@dswi
>              nc.com>                                                    To
>                                        "Tapestry users"
>              12/19/2007 01:58          <[hidden email]>
>              PM                                                         cc
>
>                                                                    Subject
>              Please respond to         RE: Can't get Tapestry5 to work
>              "Tapestry users"          with Spring
>              <[hidden email]
>                 pache.org>
>
>
>
>
>
>
>
>
>
> Dave,
>
> I have Tapestry 5.0.5, Spring 2.0.4, and Sun Appserver 9 all working in
> harmony.  Haven't really had any problems at all.
>
> Based on your post, it sounds like Tapestry is finding and initializing
> the beans.  That's the toughest part, so if that's true, I might suggest
> to just simplify things a little:
>
> * Put one simple named bean in your applicationContext.xml
> * Then instead of using the @Service annotation, just name your member
> variable the same as the bean name
> * Make sure your @Inject annotations are in a page or component class
> (NOTE: this is important, because Tapestry doesn't just scan your entire
> classpath and look for these annotations, it only looks in the
> "Component Packages" (see here:
> http://tapestry.formos.com/nightly/tapestry5/tapestry-core/guide/compone
> nt-classes.html )).
>
> Hope that helps.  Here's some sample source:
>
> <beans xmlns="http://www.springframework.org/schema/beans"
>             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>
> xsi:schemaLocation="http://www.springframework.org/schema/beans
>
> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
>       <bean name="serviceDao" class="com.foo.ServiceDaoImpl"/>
> </beans>
>
> public class Target
> {
>     @Inject
>     private ServiceDao serviceDao;  // <-- NOTE CHANGE
>
>     public List<String> getOptions()
>     {
>         return dao.getOptions();               ///  NPE here!!
> getOptions()
> in the dao returns a hard-coded list at this time
>     }
>
>     public void setDao(final ServiceDao _dao)
>     {
>         this.dao = _dao;
>     }
>     public ServiceDao getDao()
>     {
>         return dao;
>     }
> }
>
>
> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]]
> Sent: Wednesday, December 19, 2007 1:27 PM
> To: [hidden email]
> Subject: Can't get Tapestry5 to work with Spring
>
>
> I'm new to Tapestry. I've been wanting to take a look at it for some
> time, and have a bit of time here at the end of the year. I've started
> with Howard's tutorial for Tap5 and got the first stage of that working
> easily.
> So then I created another simple page, and linked to that. Still working
> fine, so time to start getting into something 'real'. Since we use
> Spring for all our projects here I figured that should be my next step.
> I created an iBatis DAO that accesses one of our existing JNDI
> datasources, with the intent of having my page retrieve data from it for
> displaying.
>
> I followed the steps described here:
> http://tapestry.apache.org/tapestry5/tapestry-spring/, but the dao is
> not getting injected; I get a NPE when it comes time to access it. My
> logs show the initialization completing correctly, with the Spring beans
> being created. Is there anything missing fom this description to
> complete the wiring?
>
> I'm using Tapestry5.0.6, Spring2.0.1 (though I also tried 1.2.8),
> iBatis2.3.0.677, running in Sun Appserver8.2
>
> Here's my web.xml:
>
> <web-app>
>           <display-name>tapestry-tutorial1 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>org.apache.tapestry.tutorial</param-value>
>           </context-param>
>
>                   <context-param>
>                         <param-name>contextConfigLocation</param-name>
>                         <param-value>
>
> classpath:org/apache/tapestry/tutorial/applicationContext.xml
>                         </param-value>
>                   </context-param>
>
>           <filter>
>               <filter-name>app</filter-name>
>               <!--
> <filter-class>org.apache.tapestry.TapestryFilter</filter-class>
> -->
>                <filter-class>
> org.apache.tapestry.spring.TapestrySpringFilter</filter-class>
>           </filter>
>           <filter-mapping>
>               <filter-name>app</filter-name>
>               <url-pattern>/*</url-pattern>
>           </filter-mapping>
>
>                   <listener>
>                     <listener-class>
> org.springframework.web.context.ContextLoaderListener</listener-class>
>                   </listener>
> </web-app>
>
>
> org/apache/tapestry/tutorial/applicationContext.xml:
>
> <beans xmlns="http://www.springframework.org/schema/beans"
>             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>
> xsi:schemaLocation="http://www.springframework.org/schema/beans
>
> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
>
>       <import resource=
> "classpath:org/apache/tapestry/tutorial/dao/applicationContext-jndi.xml"
> />
>       <import resource=
> "classpath:org/apache/tapestry/tutorial/dao/ibatis/applicationContext.xm
> l"
> />
> </beans>
>
>
> org/apache/tapestry/tutorial/dao/applicationContext-jndi.xml:
>
> <beans xmlns="http://www.springframework.org/schema/beans"
>             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>
> xsi:schemaLocation="http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
>
>       <bean id="serviceDataSource" class=
> "org.springframework.jndi.JndiObjectFactoryBean">
>             <property name="jndiName" value="srServiceDataSource"/>
>       </bean>
> </beans>
>
>
> org/apache/tapestry/tutorial/dao/ibatis/applicationContext.xml:
>
> <beans xmlns="http://www.springframework.org/schema/beans"
>             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>
> xsi:schemaLocation="http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
>
>       <bean id="sqlMapClient" class=
> "org.springframework.orm.ibatis.SqlMapClientFactoryBean">
>             <property name="configLocation" value=
> "classpath:org/apache/tapestry/tutorial/dao/ibatis/sql-map-config.xml"
> />
>             <property name="dataSource" ref="serviceDataSource" />
>       </bean>
>
>       <bean name="serviceDao" class=
> "org.apache.tapestry.tutorial.dao.ibatis.ServiceDaoImpl">
>             <property name="sqlMapClient" ref="sqlMapClient" />
>       </bean>
> </beans>
>
>
> And in my page class:
>
> public class Target
> {
>     @Inject
>     @Service("serviceDao")
>     private ServiceDao dao;
>
>     public List<String> getOptions()
>     {
>         return dao.getOptions();               ///  NPE here!!
> getOptions()
> in the dao returns a hard-coded list at this time
>     }
>
>     public void setDao(final ServiceDao _dao)
>     {
>         this.dao = _dao;
>     }
>     public ServiceDao getDao()
>     {
>         return dao;
>     }
> }
>
> I haven't tried the alternate methods presented, but just by looking at
> them I know that I will not be able to convince the other developers to
> give Tapestry a try if it's necessary to go through that in order to use
> Spring. Hopefully I'm just missing something simple and I'll be able to
> get this method working. But I've been struggling with it for the better
> part of 2 days now.
>
> Dave
>
> We must begin not just to act, but to think, for there is no better
> slave than the one who believes his slavery to be freedom, and we are in
> no greater peril than when we cannot see the chains on our minds because
> there are yet no chains on our feet.
> -- Michael Reid
>
>
> This message contains information from Equifax Inc. which may be
> confidential and privileged.  If you are not an intended recipient,
> please refrain from any disclosure, copying, distribution or use of this
> information and note that such actions are prohibited.  If you have
> received this transmission in error, please notify by e-mail
> [hidden email].
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>



--
Howard M. Lewis Ship
TWD Consulting, Inc.

Creator Apache Tapestry and Apache HiveMind

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Can't get Tapestry5 to work with Spring

dderry
In reply to this post by Howard Lewis Ship
Yes the field is private; with a public get and setter.  I am using the
org.apache.tapestry.spring.TapestrySpringFilter filter.

I did simplify by making my DAO a plain POJO with no dependencies, but am
now getting a dirrerent error. When trying to retrieve the start page (this
app is based on your tutorial) I'm getting: Exception constructing service
'TimingFilter': Error invoking service builder method
org.apache.tapestry.tutorial.services.AppModule.buildTimingFilter(Log) (at
AppModule.java:65) (for service 'TimingFilter'): No service implements the
interface org.apache.commons.logging.Log

Thanks,
Dave

We must begin not just to act, but to think, for there is no better slave
than the one who believes his slavery to be freedom, and we are in
no greater peril than when we cannot see the chains on our minds
because there are yet no chains on our feet.
-- Michael Reid




                                                                           
             "Howard Lewis                                                
             Ship"                                                        
             <[hidden email]                                          To
             >                         "Tapestry users"                    
                                       <[hidden email]>        
             12/19/2007 09:19                                           cc
             PM                                                            
                                                                   Subject
                                       Re: Can't get Tapestry5 to work    
             Please respond to         with Spring                        
             "Tapestry users"                                              
             <[hidden email]                                            
                pache.org>                                                
                                                                           
                                                                           
                                                                           




On Dec 19, 2007 10:58 AM, Joel Wiegman <[hidden email]> wrote:

> Dave,
>
> I have Tapestry 5.0.5, Spring 2.0.4, and Sun Appserver 9 all working in
> harmony.  Haven't really had any problems at all.
>
> Based on your post, it sounds like Tapestry is finding and initializing
> the beans.  That's the toughest part, so if that's true, I might suggest
> to just simplify things a little:
>
> * Put one simple named bean in your applicationContext.xml
> * Then instead of using the @Service annotation, just name your member
> variable the same as the bean name
> * Make sure your @Inject annotations are in a page or component class
> (NOTE: this is important, because Tapestry doesn't just scan your entire
> classpath and look for these annotations, it only looks in the
> "Component Packages" (see here:
> http://tapestry.formos.com/nightly/tapestry5/tapestry-core/guide/compone
> nt-classes.html )).
>
> Hope that helps.  Here's some sample source:
>
> <beans xmlns="http://www.springframework.org/schema/beans"
>             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>
> xsi:schemaLocation="http://www.springframework.org/schema/beans
>
> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
>       <bean name="serviceDao" class="com.foo.ServiceDaoImpl"/>
> </beans>
>
> public class Target
> {
>     @Inject
>     private ServiceDao serviceDao;  // <-- NOTE CHANGE

For this kind of service injection, Tapestry does not care about the
field name.  That is used in certain other types of specialized
injection.

I agree that the first step is to create a simple Spring bean and
inject that, then work up to more complex cases.

The fact thaqt you can get an NPE is suprising.  Is your field
private?  It must be (5.0.7 will enforce this more strictly).  Are you
using the special filter provided by tapestry-spring?  Also check you
console and log output carefully.


>
>     public List<String> getOptions()
>     {
>         return dao.getOptions();               ///  NPE here!!
> getOptions()
> in the dao returns a hard-coded list at this time
>     }
>
>     public void setDao(final ServiceDao _dao)
>     {
>         this.dao = _dao;
>     }
>     public ServiceDao getDao()
>     {
>         return dao;
>     }
> }
>
>
>
> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]]
> Sent: Wednesday, December 19, 2007 1:27 PM
> To: [hidden email]
> Subject: Can't get Tapestry5 to work with Spring
>
>
> I'm new to Tapestry. I've been wanting to take a look at it for some
> time, and have a bit of time here at the end of the year. I've started
> with Howard's tutorial for Tap5 and got the first stage of that working
> easily.
> So then I created another simple page, and linked to that. Still working
> fine, so time to start getting into something 'real'. Since we use
> Spring for all our projects here I figured that should be my next step.
> I created an iBatis DAO that accesses one of our existing JNDI
> datasources, with the intent of having my page retrieve data from it for
> displaying.
>
> I followed the steps described here:
> http://tapestry.apache.org/tapestry5/tapestry-spring/, but the dao is
> not getting injected; I get a NPE when it comes time to access it. My
> logs show the initialization completing correctly, with the Spring beans
> being created. Is there anything missing fom this description to
> complete the wiring?
>
> I'm using Tapestry5.0.6, Spring2.0.1 (though I also tried 1.2.8),
> iBatis2.3.0.677, running in Sun Appserver8.2
>
> Here's my web.xml:
>
> <web-app>
>           <display-name>tapestry-tutorial1 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>org.apache.tapestry.tutorial</param-value>
>           </context-param>
>
>                   <context-param>
>                         <param-name>contextConfigLocation</param-name>
>                         <param-value>
>
> classpath:org/apache/tapestry/tutorial/applicationContext.xml
>                         </param-value>
>                   </context-param>
>
>           <filter>
>               <filter-name>app</filter-name>
>               <!-- >
> <filter-class>org.apache.tapestry.TapestryFilter</filter-class>
>                -->
>                <filter-class>
> org.apache.tapestry.spring.TapestrySpringFilter</filter-class>
>           </filter>
>           <filter-mapping>
>               <filter-name>app</filter-name>
>               <url-pattern>/*</url-pattern>
>           </filter-mapping>
>
>                   <listener>
>                     <listener-class>
> org.springframework.web.context.ContextLoaderListener</listener-class>
>                   </listener>
> </web-app>
>
>
> org/apache/tapestry/tutorial/applicationContext.xml:
>
> <beans xmlns="http://www.springframework.org/schema/beans"
>             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>
> xsi:schemaLocation="http://www.springframework.org/schema/beans
>
> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
>
>       <import resource=
> "classpath:org/apache/tapestry/tutorial/dao/applicationContext-jndi.xml"
> />
>       <import resource=
> "classpath:org/apache/tapestry/tutorial/dao/ibatis/applicationContext.xm
> l"
> />
> </beans>
>
>
> org/apache/tapestry/tutorial/dao/applicationContext-jndi.xml:
>
> <beans xmlns="http://www.springframework.org/schema/beans"
>             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>
> xsi:schemaLocation="http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
>
>       <bean id="serviceDataSource" class=
> "org.springframework.jndi.JndiObjectFactoryBean">
>             <property name="jndiName" value="srServiceDataSource"/>
>       </bean>
> </beans>
>
>
> org/apache/tapestry/tutorial/dao/ibatis/applicationContext.xml:
>
> <beans xmlns="http://www.springframework.org/schema/beans"
>             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>
> xsi:schemaLocation="http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
>
>       <bean id="sqlMapClient" class=
> "org.springframework.orm.ibatis.SqlMapClientFactoryBean">
>             <property name="configLocation" value=
> "classpath:org/apache/tapestry/tutorial/dao/ibatis/sql-map-config.xml"
> />
>             <property name="dataSource" ref="serviceDataSource" />
>       </bean>
>
>       <bean name="serviceDao" class=
> "org.apache.tapestry.tutorial.dao.ibatis.ServiceDaoImpl">
>             <property name="sqlMapClient" ref="sqlMapClient" />
>       </bean>
> </beans>
>
>
> And in my page class:
>
> public class Target
> {
>     @Inject
>     @Service("serviceDao")
>     private ServiceDao dao;
>
>     public List<String> getOptions()
>     {
>         return dao.getOptions();               ///  NPE here!!
> getOptions()
> in the dao returns a hard-coded list at this time
>     }
>
>     public void setDao(final ServiceDao _dao)
>     {
>         this.dao = _dao;
>     }
>     public ServiceDao getDao()
>     {
>         return dao;
>     }
> }
>
> I haven't tried the alternate methods presented, but just by looking at
> them I know that I will not be able to convince the other developers to
> give Tapestry a try if it's necessary to go through that in order to use
> Spring. Hopefully I'm just missing something simple and I'll be able to
> get this method working. But I've been struggling with it for the better
> part of 2 days now.
>
> Dave
>
> We must begin not just to act, but to think, for there is no better
> slave than the one who believes his slavery to be freedom, and we are in
> no greater peril than when we cannot see the chains on our minds because
> there are yet no chains on our feet.
> -- Michael Reid
>
>
> This message contains information from Equifax Inc. which may be
> confidential and privileged.  If you are not an intended recipient,
> please refrain from any disclosure, copying, distribution or use of this
> information and note that such actions are prohibited.  If you have
> received this transmission in error, please notify by e-mail
> [hidden email].
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>



--
Howard M. Lewis Ship
TWD Consulting, Inc.

Creator Apache Tapestry and Apache HiveMind

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]





---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Can't get Tapestry5 to work with Spring

Francois Armand
In reply to this post by dderry
[hidden email] wrote:

> Joel,
>
> When I attempt to retrieve the 'safe' page; the original start page from
> the tutorial, to which I added a link to my new test page I get this error:
>
> 2007-12-21 10:36:28,362 5ERROR [httpWorkerThread-9090-1]
> (DefaultRequestExceptionHandler.java:50) - Processing of request failed
> with uncaught exception: Exception constructing service 'TimingFilter':
> Error invoking service builder method
> org.apache.tapestry.tutorial.services.AppModule.buildTimingFilter(Log) (at
> AppModule.java:65) (for service 'TimingFilter'): No service implements the
> interface org.apache.commons.logging.Log.
> java.lang.RuntimeException: Exception constructing service 'TimingFilter':
> Error invoking service builder method
> org.apache.tapestry.tutorial.services.AppModule.buildTimingFilter(Log) (at
> AppModule.java:65) (for service 'TimingFilter'): No service implements the
> interface org.apache.commons.logging.Log.
>
> Any hints on how to get around this?
>  
It looks like there's a problem with your Logger. Since Tapestry 5.0.6,
Tapestry uses Slf4j in place of commons-logging.
I think  the  AppModule class may not be up to date : replace all
occurence of org.apache.commons.logging.Log by org.slf4j.Logger.

Hope it would help,

--
Francois Armand
Etudes & Développements J2EE
Groupe Linagora - http://www.linagora.com
Tél.: +33 (0)1 58 18 68 28
-----------
InterLDAP - http://interldap.org 
FederID - http://www.federid.org/
Open Source identities management and federation


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Can't get Tapestry5 to work with Spring

Francois Armand
In reply to this post by Howard Lewis Ship
Howard Lewis Ship wrote:
> Between release 5.0.5 and 5.0.6 Tapestry switched from commons-logging
> to SLF4J.  You want to be injecting an org.slf4j.Logger instead.
>  
Arf, too quick for me :)

--
Francois Armand
Etudes & Développements J2EE
Groupe Linagora - http://www.linagora.com
Tél.: +33 (0)1 58 18 68 28
-----------
InterLDAP - http://interldap.org 
FederID - http://www.federid.org/
Open Source identities management and federation


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]