springnosuchmethoderror

java.lang.NoSuchMethodError: org.springframework.web.context.support.ServletContextAwareProcessor: method <init>()V not found


I'm testing my first Spring project. I'm trying to call a webservice. I'm following the tutorial as listed here: http://spring.io/guides/gs/consuming-web-service/

When I try to build my project, I get following error:

2014-09-08 15:10:38.924  INFO 4736 --- [           main] b.i.einvoice.webserviceTest.TestMain     : Starting TestMain on W7-010545 with PID 4736 (C:\Users\staelko\git\einvoice-portlets\einvoice\target\classes started by staelko in C:\Users\staelko\git\einvoice-portlets\einvoice)
2014-09-08 15:10:38.978  INFO 4736 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@12d56b37: startup date [Mon Sep 08 15:10:38 CEST 2014]; root of context hierarchy
Exception in thread "main" java.lang.NoSuchMethodError: org.springframework.web.context.support.ServletContextAwareProcessor: method <init>()V not found

What is causing this?

My POM:

<?xml version="1.0"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>be.icredit</groupId>
    <artifactId>einvoice</artifactId>
    <packaging>war</packaging>
    <name>einvoice Portlet</name>
    <version>0.0.1-SNAPSHOT</version>
    <properties>
        <liferay.maven.plugin.version>6.2.10.6</liferay.maven.plugin.version>
        <liferay.version>6.2.1</liferay.version>
        <spring.suite.version>3.2.10.RELEASE</spring.suite.version>
    </properties>
    <build>
        <plugins>
            <plugin>
                <groupId>com.liferay.maven.plugins</groupId>
                <artifactId>liferay-maven-plugin</artifactId>
                <version>${liferay.maven.plugin.version}</version>
                <executions>

                </executions>
                <configuration>
                    <autoDeployDir>${liferay.auto.deploy.dir}</autoDeployDir>
                    <appServerDeployDir>${liferay.app.server.deploy.dir}</appServerDeployDir>
                    <appServerLibGlobalDir>${liferay.app.server.lib.global.dir}</appServerLibGlobalDir>
                    <appServerPortalDir>${liferay.app.server.portal.dir}</appServerPortalDir>
                    <liferayVersion>${liferay.version}</liferayVersion>
                    <pluginType>portlet</pluginType>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.5</version>
                <configuration>
                    <encoding>UTF-8</encoding>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.5</version>
                <configuration>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.jvnet.jaxb2.maven2</groupId>
                <artifactId>maven-jaxb2-plugin</artifactId>
                <version>0.9.0</version>

                <executions>
                    <execution>
                        <id>BatchDaoService-generate</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <schemaLanguage>WSDL</schemaLanguage>
                            <generatePackage>be.icredit.einvoice.proxy.BatchDaoService</generatePackage>
                            <forceRegenerate>true</forceRegenerate>
                            <schemas>
                                <schema>
                                    <fileset>
                                        <!-- Defaults to schemaDirectory -->
                                        <directory>${basedir}/src/main/resources/wsdl/</directory>
                                        <!-- Defaults to schemaIncludes -->
                                        <includes>
                                            <include>BatchDaoService.wsdl</include>
                                        </includes>
                                    </fileset>
                                </schema>
                            </schemas>
                        </configuration>
                    </execution>
                    <execution>
                        <id>CustomerAccountDaoService-generate</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <schemaLanguage>WSDL</schemaLanguage>
                            <generatePackage>be.icredit.einvoice.proxy.CustomerAccountDaoService</generatePackage>
                            <forceRegenerate>true</forceRegenerate>
                            <schemas>
                                <schema>
                                    <fileset>
                                        <!-- Defaults to schemaDirectory -->
                                        <directory>${basedir}/src/main/resources/wsdl/</directory>
                                        <!-- Defaults to schemaIncludes -->
                                        <includes>
                                            <include>CustomerAccountDaoService.wsdl</include>
                                        </includes>
                                    </fileset>
                                </schema>
                            </schemas>
                        </configuration>
                    </execution>
                    <execution>
                        <id>CustomerDaoService-generate</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <schemaLanguage>WSDL</schemaLanguage>
                            <generatePackage>be.icredit.einvoice.proxy.CustomerDaoService</generatePackage>
                            <forceRegenerate>true</forceRegenerate>
                            <schemas>
                                <schema>
                                    <fileset>
                                        <!-- Defaults to schemaDirectory -->
                                        <directory>${basedir}/src/main/resources/wsdl/</directory>
                                        <!-- Defaults to schemaIncludes -->
                                        <includes>
                                            <include>CustomerDaoService.wsdl</include>
                                        </includes>
                                    </fileset>
                                </schema>
                            </schemas>
                        </configuration>
                    </execution>
                    <execution>
                        <id>DocumentDaoService-generate</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <schemaLanguage>WSDL</schemaLanguage>
                            <generatePackage>be.icredit.einvoice.proxy.DocumentDaoService</generatePackage>
                            <forceRegenerate>true</forceRegenerate>
                            <schemas>
                                <schema>
                                    <fileset>
                                        <!-- Defaults to schemaDirectory -->
                                        <directory>${basedir}/src/main/resources/wsdl/</directory>
                                        <!-- Defaults to schemaIncludes -->
                                        <includes>
                                            <include>DocumentDaoService.wsdl</include>
                                        </includes>
                                    </fileset>
                                </schema>
                            </schemas>
                        </configuration>
                    </execution>
                    <execution>
                        <id>DocumentTemplateDaoService-generate</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <schemaLanguage>WSDL</schemaLanguage>
                            <generatePackage>be.icredit.einvoice.proxy.DocumentTemplateDaoService</generatePackage>
                            <forceRegenerate>true</forceRegenerate>
                            <schemas>
                                <schema>
                                    <fileset>
                                        <!-- Defaults to schemaDirectory -->
                                        <directory>${basedir}/src/main/resources/wsdl/</directory>
                                        <!-- Defaults to schemaIncludes -->
                                        <includes>
                                            <include>DocumentTemplateDaoService.wsdl</include>
                                        </includes>
                                    </fileset>
                                </schema>
                            </schemas>
                        </configuration>
                    </execution>
                    <execution>
                        <id>EmailStatusDaoService-generate</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <schemaLanguage>WSDL</schemaLanguage>
                            <generatePackage>be.icredit.einvoice.proxy.EmailStatusDaoService</generatePackage>
                            <forceRegenerate>true</forceRegenerate>
                            <schemas>
                                <schema>
                                    <fileset>
                                        <!-- Defaults to schemaDirectory -->
                                        <directory>${basedir}/src/main/resources/wsdl/</directory>
                                        <!-- Defaults to schemaIncludes -->
                                        <includes>
                                            <include>EmailStatusDaoService.wsdl</include>
                                        </includes>
                                    </fileset>
                                </schema>
                            </schemas>
                        </configuration>
                    </execution>
                    <execution>
                        <id>EmailTemplateDaoService-generate</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <schemaLanguage>WSDL</schemaLanguage>
                            <generatePackage>be.icredit.einvoice.proxy.EmailTemplateDaoService</generatePackage>
                            <forceRegenerate>true</forceRegenerate>
                            <schemas>
                                <schema>
                                    <fileset>
                                        <!-- Defaults to schemaDirectory -->
                                        <directory>${basedir}/src/main/resources/wsdl/</directory>
                                        <!-- Defaults to schemaIncludes -->
                                        <includes>
                                            <include>EmailTemplateDaoService.wsdl</include>
                                        </includes>
                                    </fileset>
                                </schema>
                            </schemas>
                        </configuration>
                    </execution>
                    <execution>
                        <id>FileService-generate</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <schemaLanguage>WSDL</schemaLanguage>
                            <generatePackage>be.icredit.einvoice.proxy.FileService</generatePackage>
                            <forceRegenerate>true</forceRegenerate>
                            <schemas>
                                <schema>
                                    <fileset>
                                        <!-- Defaults to schemaDirectory -->
                                        <directory>${basedir}/src/main/resources/wsdl/</directory>
                                        <!-- Defaults to schemaIncludes -->
                                        <includes>
                                            <include>FileService.wsdl</include>
                                        </includes>
                                    </fileset>
                                </schema>
                            </schemas>
                        </configuration>
                    </execution>
                    <execution>
                        <id>SenderDaoService-generate</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <schemaLanguage>WSDL</schemaLanguage>
                            <generatePackage>be.icredit.einvoice.proxy.SenderDaoService</generatePackage>
                            <forceRegenerate>true</forceRegenerate>
                            <schemas>
                                <schema>
                                    <fileset>
                                        <!-- Defaults to schemaDirectory -->
                                        <directory>${basedir}/src/main/resources/wsdl/</directory>
                                        <!-- Defaults to schemaIncludes -->
                                        <includes>
                                            <include>SenderDaoService.wsdl</include>
                                        </includes>
                                    </fileset>
                                </schema>
                            </schemas>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>com.liferay.portal</groupId>
            <artifactId>portal-service</artifactId>
            <version>${liferay.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.liferay.portal</groupId>
            <artifactId>util-bridges</artifactId>
            <version>${liferay.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.liferay.portal</groupId>
            <artifactId>util-taglib</artifactId>
            <version>${liferay.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.liferay.portal</groupId>
            <artifactId>util-java</artifactId>
            <version>${liferay.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.portlet</groupId>
            <artifactId>portlet-api</artifactId>
            <version>2.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.4</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
            <version>2.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${spring.suite.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${spring.suite.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${spring.suite.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${spring.suite.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc-portlet</artifactId>
            <version>${spring.suite.version}</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
            <version>1.1.6.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.ws</groupId>
            <artifactId>spring-ws-core</artifactId>
            <version>2.2.0.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.2</version>
        </dependency>



    </dependencies>
</project>

Full stack trace below:

 :: Spring Boot ::        (v1.1.6.RELEASE)

2014-09-08 15:26:06.200  INFO 2964 --- [           main] b.i.einvoice.webserviceTest.TestMain     : Starting TestMain on W7-010545 with PID 2964 (C:\Users\staelko\git\einvoice-portlets\einvoice\target\classes started by staelko in C:\Users\staelko\git\einvoice-portlets\einvoice)
2014-09-08 15:26:06.273  INFO 2964 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@326b9c84: startup date [Mon Sep 08 15:26:06 CEST 2014]; root of context hierarchy
Exception in thread "main" java.lang.NoSuchMethodError: org.springframework.web.context.support.ServletContextAwareProcessor: method <init>()V not found
    at org.springframework.boot.context.embedded.WebApplicationContextServletContextAwareProcessor.<init>(WebApplicationContextServletContextAwareProcessor.java:40)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.postProcessBeanFactory(EmbeddedWebApplicationContext.java:100)
    at org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext.postProcessBeanFactory(AnnotationConfigEmbeddedWebApplicationContext.java:180)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:458)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:109)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:691)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:952)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:941)
    at be.icredit.einvoice.webserviceTest.TestMain.main(TestMain.java:13)
2014-09-08 15:26:06.307  INFO 2964 --- [       Thread-1] ationConfigEmbeddedWebApplicationContext : Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@326b9c84: startup date [Mon Sep 08 15:26:06 CEST 2014]; root of context hierarchy
2014-09-08 15:26:06.319  WARN 2964 --- [       Thread-1] ationConfigEmbeddedWebApplicationContext : Exception thrown from ApplicationListener handling ContextClosedEvent

java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@326b9c84: startup date [Mon Sep 08 15:26:06 CEST 2014]; root of context hierarchy
    at org.springframework.context.support.AbstractApplicationContext.getApplicationEventMulticaster(AbstractApplicationContext.java:347)
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:334)
    at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1049)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.doClose(EmbeddedWebApplicationContext.java:141)
    at org.springframework.context.support.AbstractApplicationContext$1.run(AbstractApplicationContext.java:980)

2014-09-08 15:26:06.320  WARN 2964 --- [       Thread-1] ationConfigEmbeddedWebApplicationContext : Exception thrown from LifecycleProcessor on context close

java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@326b9c84: startup date [Mon Sep 08 15:26:06 CEST 2014]; root of context hierarchy
    at org.springframework.context.support.AbstractApplicationContext.getLifecycleProcessor(AbstractApplicationContext.java:360)
    at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1057)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.doClose(EmbeddedWebApplicationContext.java:141)
    at org.springframework.context.support.AbstractApplicationContext$1.run(AbstractApplicationContext.java:980)

2014-09-08 15:26:06.321  INFO 2964 --- [       Thread-1] o.s.b.f.s.DefaultListableBeanFactory     : Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@331c89c: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,customerDaoConfiguration]; root of factory hierarchy

On this line in my main class crashes the app:

ApplicationContext ctx = SpringApplication.run(CustomerDaoConfiguration.class, args);

And my CustomerDaoConfiguration is listed as below:

@Configuration
public class CustomerDaoConfiguration {

    @Bean
    public Jaxb2Marshaller marshaller() {
        Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
        marshaller.setContextPath("be.icredit.einvoice.proxy.CustomerDaoService");
        return marshaller;
    }

    @Bean
    public CustomerClient weatherClient(Jaxb2Marshaller marshaller) {
        CustomerClient client = new CustomerClient();
        client.setDefaultUri("http://ws08-icreditlc.iconos.be:18080/icredit-service-data/CustomerDaoService");
        client.setMarshaller(marshaller);
        client.setUnmarshaller(marshaller);
        return client;
    }

}

Solution

  • I got this problem because I included another spring framework with an older version. To check if you have the same problem, run the following command to generate a dependency tree:

    mvn dependency:tree
    

    Then search through the output to check if you have included another spring framework with an older version(typically 2.xx or 3.xx).