I really appreciate the input - I've been struggling with this for a
while. It's still not quite working though, and I'm sure the problem
is that there's something fundamental about the process that I don't
quite understand yet.

My applicationContext.xml looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd";>
<beans autowire-type="byName">

        <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
                <property name="driverClassName" value="org.postgresql.Driver"/>
                <property name="url" value="jdbc:postgresql:hydra"/>
                <property name="username" value="username"/>
                <property name="password" value="password"/>
        </bean>
        
        <bean id="sqlMapClient"
class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
                <property name="configLocation" 
value="WEB-INF/SqlMapConfig.xml"/>
                <property name="dataSource" ref="dataSource"/>
        </bean>
        
        <bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
                <property name="dataSource" ref="dataSource"/>
        </bean>
        
        <!-- dao implementations -->
        <!-- snip -->
        
        <bean id="pointsDAOImpl" 
class="com.hbms.hydra.data.postgres.PointsDAOImpl">
                <property name="sqlMapClient" ref="sqlMapClient" />
        </bean>
        
       <!-- actions -->
        <bean id="AddStoryCardAction" 
class="com.hbms.hydra.struts.AddStoryCardAction">
                <property name="pointsDAOImpl" ref="pointsDAOImpl" />
        </bean>

</beans>

My action has a getter and setter for the pointsDAOImpl and a prepare
method that's using the DAO implementation:

        public void prepare() throws Exception {
                pointList = HydraService.getAllPoints(getPointsDAOImpl());
        }

I also have the action set up in the struts.xml file.

   <package name="default" extends="struts-default">
       <action name="AddStoryCard"
class="com.hbms.hydra.struts.AddStoryCardAction">
           <result name="success">/storyCards.jsp</result>
       </action>
   </package>

When I start up Tomcat I see this in the logs:

23298 [http-8080-Processor25] DEBUG
org.springframework.beans.CachedIntrospectionResults  - Found bean
property 'pointsDAOImpl' of type
[com.hbms.hydra.data.postgres.PointsDAOImpl]

and then a bit later:

23299 [http-8080-Processor25] DEBUG
org.springframework.beans.factory.support.DefaultListableBeanFactory
- Not autowiring property 'pointsDAOImpl' of bean
'com.hbms.hydra.struts.AddStoryCardAction' by name: no matching bean
found

The front page loads but when I click on the link that calls the
action I get a NPE for the pointsDAOImpl in the prepare method.

Does anyone know what I'm doing wrong? Thank you very much.

On 6/14/07, David Durham, Jr. <[EMAIL PROTECTED]> wrote:
On 6/14/07, Wesslan <[EMAIL PROTECTED]> wrote:
> Maybe http://struts.apache.org/2.x/docs/spring-plugin.html can be of some
> help.

You have to give your spring actions (those you want dependency
injection for) the same value for the "name" attribute as the value
you give for your spring bean's "id" attribute.  This is spelled out
in the referenced document, but I missed that point the first time
through.

HTH,
Dave

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