0

I'm trying to deploy my web app within Spring Tool Suite (STS) using vFabric tc Server but I get exceptions. It's worth noting it runs fine if I compile and run in a standalone Tomcat 6. I've tried vFabric tc versions tomcat-7.0.35.B.RELEASE and tomcat-6.0.36.B.RELEASE.

The error is:

java.lang.IllegalArgumentException: class [springapp.web.spring.MyInitializer] must implement ApplicationContextInitializerclass springapp.web.spring.MyInitializer is not assignable to interface org.springframework.context.ApplicationContextInitializer

I can't decipher why this error is occurring as the initializer does implement ApplicationContextInitializer:

public class MyInitializer implements ApplicationContextInitializer {
  public void initialize(ConfigurableApplicationContext ctx) {
    try {
        PropertySource ps = new ResourcePropertySource("file:///home/jim/development/act/impact/webapp.properties");
        ctx.getEnvironment().getPropertySources().addFirst(ps);
        // perform any other initialization of the context ...
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
  }
}

Does anyone have any suggestions on what I could try to get this running?

informatik01
  • 16,038
  • 10
  • 74
  • 104
James
  • 1,720
  • 5
  • 29
  • 50

2 Answers2

2

You have different versions of the org.springframework.context.ApplicationContextInitializer class (in the spring-context jar) on your application server. This is typically caused by putting the jar in both a fat war and on the application server's own classpath. Generally, you should avoid having anything but the system APIs (like Servlet) on the system classpath and include the necessary jars in each application.

chrylis -cautiouslyoptimistic-
  • 75,269
  • 21
  • 115
  • 152
  • I've grep'd the filesystem for spring-context there's no sign of one in a vfabric lib directory. A couple of other projects have been deployed within sts in the past ussing 3.2.3 rather than 3.2.2 so I've deleted them but still no joy. Do you have any suggestions on how I could debug further? – James Nov 15 '13 at 12:59
0

I don't understand why this was happening but the problem turned out to be that in my pom file I had spring-context-support as:

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context-suppoer</artifactId>
    <version>3.2.2.RELEASE</version>
    <type>pom</type>
</dependency>

Removing the type element fixed the issue.

James
  • 1,720
  • 5
  • 29
  • 50