1

I am migrating working springBoot 1.5 app that runs fine on tomcat 9 to SpringBoot 2. When i tried to migrate it adding to pom

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-properties-migrator</artifactId>
    </dependency>

and changing a few needed naming stuff i get this output when starting on tomcat9 or tomcat 8.5:

   17:39:39.590 [RMI TCP Connection(3)-127.0.0.1] ERROR org.springframework.boot.SpringApplication - Application run failed
java.lang.NoSuchMethodError: org.springframework.boot.builder.SpringApplicationBuilder.<init>([Ljava/lang/Object;)V
(...)
17-Oct-2018 17:39:39.591 SEVERE [RMI TCP Connection(3)-127.0.0.1] org.apache.catalina.core.ContainerBase.addChildInternal ContainerBase.addChild: start: 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/policyManagement]]

(...)
Caused by: java.lang.NoSuchMethodError: org.springframework.boot.builder.SpringApplicationBuilder.<init>([Ljava/lang/Object;)V
(...)

17-Oct-2018 17:39:39.597 SEVERE [RMI TCP Connection(3)-127.0.0.1] org.apache.tomcat.util.modeler.BaseModelMBean.invoke Exception invoking method manageApp
 java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/policyManagement]]
(...)
[2018-10-17 05:39:39,612] Artifact policyManagement-web:war exploded: Error during artifact deployment. See server log for details.
(...)

17-Oct-2018 17:39:39.598 SEVERE [RMI TCP Connection(3)-127.0.0.1] org.apache.tomcat.util.modeler.BaseModelMBean.invoke Exception invoking method createStandardContext
 javax.management.RuntimeOperationsException: Exception invoking method manageApp
(...)
Caused by: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/policyManagement]]
(...)

I tried adding -Xms256m -Xmx2048m to Tomcat VM Options or tried on SpringBoot <version>2.1.0.M4</version> or <version>2.0.5</version>

EDIT: I have this code in class anotated @SpringBootApplication:

@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
    return application.sources(Z.class);
}

How can i change it?

Pom from this app:

<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>Z</groupId>
        <artifactId>X</artifactId>
        <version>4.6.0-SNAPSHOT</version>
    </parent>

    <artifactId>X</artifactId>
    <packaging>war</packaging>

    <dependencies>
        <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>
    (and some standard-dependencies)

    <profiles>
        <profile>
            <id>default</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-war-plugin</artifactId>
                        <configuration>
                            <failOnMissingWebXml>false</failOnMissingWebXml>
                            <archive>
                                <manifestEntries>
                                    <Sys-Version>${project.version}</Sys-Version>
                                    <!-- Variables set by Hudson -->
                                    <Build-Number>${BUILD_NUMBER}</Build-Number>
                                    <Build-Date>${BUILD_TIMESTAMP}</Build-Date>
                                    <!-- Next two for potential usage in the next AppInfo versions -->
                                    <Job-Name>${JOB_NAME}</Job-Name>
                                    <Git-Branch>${GIT_BRANCH}</Git-Branch>
                                    <Git-Commit>${GIT_COMMIT}</Git-Commit>
                                </manifestEntries>
                            </archive>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-maven-plugin</artifactId>
                        <version>2.0.5.RELEASE</version>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>repackage</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>


        <profile>
            <!-- Enable this profile to run in IntelliJ. IntelliJ excludes provided dependencies from compile by default. -->
            <id>intellij</id>
            <dependencies>
                <dependency>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-tomcat</artifactId>
                    <scope>compile</scope>
                </dependency>
            </dependencies>
        </profile>
    </profiles>
</project>

Pom from its parent:

<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>A</groupId>
        <artifactId>parent</artifactId>
        <version>4.6.0-SNAPSHOT</version>
    </parent>

    <artifactId>A</artifactId>
    <packaging>pom</packaging>

    <modules>
        <module>X</module>
    </modules>

    <dependencyManagement>
        <dependencies>

            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-properties-migrator</artifactId>
            </dependency>

         <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-parent</artifactId>
            <version>Edgware.SR4</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>


            <dependency>
                <!-- Import dependency management from Spring Boot -->
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>2.0.5.RELEASE</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

        </dependencies>
    </dependencyManagement>
</project>

Changed some names to X,Y,A etc. Here i tried running this on tomcat on default profile.

Edit: I think that i need to change <version>Edgware.SR4</version> to Finchley.RELEASE

tryingHard
  • 1,794
  • 4
  • 35
  • 74
  • 2
    You have some code that's calling the constructor of `SpringApplicationBuilder` that isn't compatible with Spring Boot 2.0. In 1.5 its signature was `public SpringApplicationBuilder(Object... sources)`, in 2.0 its signature is `public SpringApplicationBuilder(Class>... sources)`. I can't tell what that code is as you haven't included the stack trace of the `NoSuchMethodError` in your question. – Andy Wilkinson Oct 17 '18 at 16:42
  • @AndyWilkinson I could not enter full stack trace cause of StackOverflow warning that the question was mostle code. I will try and check (find this SpringApplicationBuilder in code) and add more stack trace tomorow. Thanks. – tryingHard Oct 17 '18 at 17:51
  • @AndyWilkinson i edited the question adding the code about `SpringApplicationBuilder ` how can i change it to make it work? This part does not fail at compilation – tryingHard Oct 18 '18 at 07:39
  • Why are you running it under tomcat? Why not just build a self-contained (fat) jar with jetty as the container and leave tomcat by the wayside (which I have done for the last 5 years). You just run the jar and voila, no more tomcat config BS. – Bohemian Oct 18 '18 at 07:42
  • @Bohemian cause this project currently does not work under standard springBoot run. It works only from tomcat. I don't know why yet technically. The client uses still tomcat - not jars - this is why - if we speak about business. – tryingHard Oct 18 '18 at 07:43
  • @Bohemian added pom of this app and it's parent. – tryingHard Oct 18 '18 at 08:03
  • Assuming that the code that's calling `application.sources(Z.class);` has been recompiled following the upgrade to Spring Boot 2, that's not what's causing the problem. Can you please share the complete stack trace? It'll show exactly what code is causing the problem. – Andy Wilkinson Oct 18 '18 at 09:24
  • @AndyWilkinson As i read spring-cloud `Edgware.SR4` is not compatible with SpringBoot 2.x - i changed it to `Finchley.RELEASE` and try again. Here i found the same issue: https://github.com/spring-cloud/spring-cloud-commons/issues/279 – tryingHard Oct 18 '18 at 09:44
  • I’ll ask one more time, can you please share the full stack trace of the exception? The output of `mvn dependency:tree` would also be useful. – Andy Wilkinson Oct 18 '18 at 11:28
  • @AndyWilkinson I don't have this issue anymore - i would apreciate if you could check this issue: https://stackoverflow.com/questions/52873037/spring-boot-2-migration-from-spring-boot-1-5-issue-with-entitymanagerpackages – tryingHard Oct 18 '18 at 11:35
  • @AndyWilkinson thanks for the tips in comments – tryingHard Oct 18 '18 at 11:37

1 Answers1

0

As i read spring-cloud <version>Edgware.SR4</version> is not compatible with SpringBoot 2.x - i changed it's version to Finchley.RELEASE.

Here i found the same issue: github.com/spring-cloud/spring-cloud-commons/issues/279

Now i get another tomcat output.

tryingHard
  • 1,794
  • 4
  • 35
  • 74