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"                                                         
             <[EMAIL PROTECTED]                                          To 
             >                         "Tapestry users"                    
                                       <users@tapestry.apache.org>         
             12/19/2007 09:19                                           cc 
             PM                                                            
                                                                   Subject 
                                       Re: Can't get Tapestry5 to work     
             Please respond to         with Spring                         
             "Tapestry users"                                              
             <[EMAIL PROTECTED]                                             
                pache.org>                                                 
                                                                           
                                                                           
                                                                           




On Dec 19, 2007 10:58 AM, Joel Wiegman <[EMAIL PROTECTED]> 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: [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]
>
>



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

Creator Apache Tapestry and Apache HiveMind

---------------------------------------------------------------------
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