1

I am using Struts 2.2.3.1 and using Struts2-spring plugin 2.2.3.1 with it. The dependency injections are working fine, but my use of ApplicationContext's getBean method is breaking :

WebApplicationContext ac = WebApplicationContextUtils.getWebApplicationContext(context);
AdminService service = ac.getBean(AdminService.class);

This is how I used to inject dependencies into my Struts project using Spring 3.0.6 (AdminService is a bean declared in applicationContext.xml. But now, with the addition of this plugin, it gives the following error :

cannot find symbol symbol : method getBean(java.lang.Class) location: interface org.springframework.web.context.WebApplicationContext

If I remove this plugin, then it works. What's the reason ?

Roman C
  • 49,761
  • 33
  • 66
  • 176
Daud
  • 7,429
  • 18
  • 68
  • 115
  • 2
    Prior to Spring 3, the WebApplicationContext did not have the method you are trying to use, which leads me to believe that this is a classloading issue. So it would appear that either your deployable's WEB-INF contains an older version of Spring, or your server is loading an older version from its own libs or another app. Use something like 7-zip to pop open your WAR file and make sure that it contains the correct Spring jar. Also, what server are you using? – rees May 24 '12 at 17:39
  • Thanks.. Actually, Struts2-spring plugin 2.2.3.1 had some pre-Spring 3 dependencies.. which were being retrieved by Maven..When I upgraded to 2.3.1.2 version of the plugin, (which I assume, has been upgraded for Spring 3).. the code compiled properly – Daud May 25 '12 at 15:17
  • Cool, glad you got it working :D – rees May 25 '12 at 17:33

0 Answers0