java.lang.NoSuchMethodError: org.springframework.web.context.support.ServletContextAwareProcessor: метод ‹init›()V не найден

Я тестирую свой первый проект Spring. Я пытаюсь вызвать веб-сервис. Я следую руководству, указанному здесь: http://spring.io/guides/gs/using-web-service/

Когда я пытаюсь построить свой проект, я получаю следующую ошибку:

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

Чем это вызвано?

Мой ПОМ:

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

Полная трассировка стека ниже:

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

В этой строке в моем основном классе происходит сбой приложения:

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

И моя конфигурация CustomerDaoConfiguration указана ниже:

@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;
    }

}

person Kornelito Benito    schedule 08.09.2014    source источник
comment
Странно, класс ServletContextAwareProcessor имеет конструктор без аргументов, поэтому я не понимаю, что может привести к сбою его инициализации таким образом. Можете ли вы опубликовать полную трассировку стека?   -  person m4rtin    schedule 08.09.2014
comment
Добавлена ​​полная трассировка стека в исходном сообщении   -  person Kornelito Benito    schedule 08.09.2014
comment
Я использую maven для создания своего проекта. Я тоже использую Эклипс. Неправильно ли проверять это с помощью приложения «Запуск от имени Java»?   -  person Kornelito Benito    schedule 08.09.2014
comment
Нет, должно быть хорошо (за исключением того, что вы не будете запускать никакие тесты таким образом, если вы специально не выбрали один из них. В противном случае Eclipse сообщит JVM о запуске с некоторой точки входа, о которой вы можете даже не знать, особенно когда работа с Spring Boot). У кого-то здесь похоже есть похожие проблема с Spring Boot (но он использует gradle вместо maven).   -  person m4rtin    schedule 08.09.2014


Ответы (2)


У меня возникла эта проблема, потому что я включил другую структуру Spring с более старой версией. Чтобы проверить, есть ли у вас такая же проблема, выполните следующую команду для создания дерева зависимостей:

mvn dependency:tree

Затем выполните поиск по выходным данным, чтобы проверить, не включили ли вы другую структуру Spring с более старой версией (обычно 2.xx или 3.xx).

person Searene    schedule 23.10.2018

Вы используете IDE? У меня была точно такая же проблема, когда я использовал IntelliJ, но когда я запустил ее с терминала с помощью

 mvn  spring-boot:run

Он будет работать нормально. Чтобы заставить его работать в IntelliJ, мне пришлось перейти к «структуре проекта» -> «Модули» -> «Зависимости» и переместить ресурсы вокруг или вручную переместить их в файле .iml.

Из документации Spring:

IntelliJ IDEA orders the classpath differently depending on how you run your application. Running your application in the IDE via its main method will result in a different ordering to when you run your application using Maven or Gradle or from its pacakaged jar. This can cause Spring Boot to fail to find the templates on the classpath. If you’re affected by this problem you can reorder the classpath in the IDE to place the module’s classes and resources first. Alternatively, you can configure the template prefix to search every templates directory on the classpath: classpath*:/templates/.

person Denorm    schedule 13.03.2015