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"                                                
             <[EMAIL PROTECTED]                                             
             nc.com>                                                    To 
                                       "Tapestry users"                    
             12/19/2007 01:58          <users@tapestry.apache.org>         
             PM                                                         cc 
                                                                           
                                                                   Subject 
             Please respond to         RE: Can't get Tapestry5 to work     
             "Tapestry users"          with Spring                         
             <[EMAIL PROTECTED]                                             
                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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 19, 2007 1:27 PM
To: users@tapestry.apache.org
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
[EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to