Frank, 

Check two things:

1) You have included the struts2-spring-pliugin.jar in your classpath
2) Your applicationContext.xml file is getting loaded on startup.  If
you haven't already done so, check your web.xml for a context parameter
like this:
        <context-param>
                <param-name>contextConfigLocation</param-name>
        
<param-value>classpath*:applicationContext*.xml</param-value>
        </context-param>

HTH, 
MG
-----Original Message-----
From: Frank Fischer [mailto:[EMAIL PROTECTED] 
Sent: Monday, March 17, 2008 11:09 AM
To: 'Struts Users Mailing List'
Subject: RE: How to initialize business service objects?


Hi all 

first i'd like to thank all of you that have given me valuable feedback
to
my question. 

Following the answers from Dave and Jeromy i decided to go the "hard"
way
with Spring and DI. After reading some manuals (thanks to GF, good
reading)
i managed to load the Spring ContextLoaderListener and even define an
POJO
bean that serves as my BusinessLogicService. From the Tomcat logs i can
see
that an instance of that Service is created. 

As far as i read/unterstood, i now would only have to create a setter
method
on my Action class and Spring then would automatically inject the
related
dependcy to my Action class. So far, this doesn't seem to work, so i
guess,
i must be missing something.

My applicationContext.xml looks quite simple (and seems to work, since
the
DispatcherService is created on startup):

-----------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd";>
<beans default-autowire="autodetect">
    <bean id="DispatcherService"
class="com.demo.businesslogic.DispatcherService"/>
</beans>
-----------

The Struts config looks like:

-----------
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts
Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd";>

<struts>
    
    <package name="customerAgent" extends="struts-default">

        <action name="login" method="login"
class="com.demo.CustomerAction">
            <result name="input">/CustomerLogin.jsp</result>
            <result name="success">/CustomerChat.jsp</result>
        </action>
        
        <action name="logout" method="logout"
class="com.demo.CustomerAction">
            <result name="success">/CustomerLogin.jsp</result>
            <result name="input">/CustomerLogin.jsp</result>
        </action>
        
        <action name="chat" method="chat"
class="com.demo.CustomerAction">
            <result name="success">/CustomerChat.jsp</result>
        </action>

        
    </package>
    
</struts>
-----------

So i guess, i must be missing something. Is there a way i would have to
tell
Spring which Action classes to inject?

Thanks a lot for your help
Frank





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