Did you set Spring to be your object factory in your struts.xml.  If you used 
Spring annotations, did you annotate your bean to be injected with @Component 
and designate a base package for Spring to scan for beans?

 
Norris Shelton
Software Engineer
Sun Certified Java 1.1 Programmer
Shelton Consulting, LLC
ICQ# 26487421
AIM NorrisEShelton
YIM norrisshelton




________________________________
From: "e_sli...@yahoo.it" <e_sli...@yahoo.it>
To: user@struts.apache.org
Sent: Monday, April 27, 2009 12:41:01 PM
Subject: Autowired and PostConstruct with Struts + Spring 

Hello everybody!

I'm trying to use my service into a Struts action but with no success.

My struts action contains :

@Autowired
private MyService myService

@PostConstruct
public void init() {
  // use here myService
}

Unfortunately myService is always null and I cannot use myService in the init() 
method...

The bean myService should correctly declared in my application-context.xml:
<bean id="myService" class="com.mypackage.MyServiceImpl">
  <property name="..." ref="..." />
  ...
</bean>

and my struts.xml contains: 
<constant name="struts.objectFactory" value="spring" />

Where I'm wrong?
Many Thanks!

Emanuele


      

Reply via email to