0

I am currently working on the deployement of an application but for some reason it seems to not working perfectly.

While coding, I am running/debugging the project with Intellij Spring Boot runner which is easy to configure.

As I need to deploy on a Tomcat server, I tried to set up first in Intellij a Tomcat Server Runner before running my war from my Tomcat server directly.

Problem is: the run seems not to work properly. In fact, the application is not starting completly even if the deployement doesn't return any error.

Here is a Spring Boot runner output:

2020-02-19 11:50:18.373 DEBUG 1192 --- [  restartedMain] com.myapp.Application              : Running with Spring Boot v2.2.4.RELEASE, Spring v5.2.3.RELEASE
2020-02-19 11:50:18.374  INFO 1192 --- [  restartedMain] com.myapp.Application              : No active profile set, falling back to default profiles: default
2020-02-19 11:50:18.421  INFO 1192 --- [  restartedMain] o.s.b.devtools.restart.ChangeableUrls    : The Class-Path manifest attribute in C:\Users\user\.m2\repository\org\glassfish\jaxb\jaxb-runtime\2.3.2\jaxb-runtime-2.3.2.jar referenced one or more files that do not exist: file:/C:/Users/user/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.3.2/jakarta.xml.bind-api-2.3.2.jar,file:/C:/Users/user/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.3.2/txw2-2.3.2.jar,file:/C:/Users/user/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.3.2/istack-commons-runtime-3.0.8.jar,file:/C:/Users/user/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.3.2/stax-ex-1.8.1.jar,file:/C:/Users/user/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.3.2/FastInfoset-1.2.16.jar,file:/C:/Users/user/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.3.2/jakarta.activation-api-1.2.1.jar
2020-02-19 11:50:18.422  INFO 1192 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2020-02-19 11:50:18.422  INFO 1192 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2020-02-19 11:50:19.223  INFO 1192 --- [  restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2020-02-19 11:50:19.288  INFO 1192 --- [  restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 57ms. Found 1 JPA repository interfaces.
2020-02-19 11:50:19.807  INFO 1192 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-02-19 11:50:20.115  INFO 1192 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8081 (http)
2020-02-19 11:50:20.125  INFO 1192 --- [  restartedMain] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2020-02-19 11:50:20.125  INFO 1192 --- [  restartedMain] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.30]
2020-02-19 11:50:20.233  INFO 1192 --- [  restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
etc.
2020-02-19 11:50:24.396  INFO 1192 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2020-02-19 11:50:24.399  INFO 1192 --- [  restartedMain] com.myapp.Application              : Started Application in 6.531 seconds (JVM running for 7.815)

And a Tomcat runner output:

2020-02-19 12:14:15.753  INFO 4436 --- [on(3)-127.0.0.1] com.myapp.Application              : Starting Application on UO with PID 4436 (C:\App\apache-tomcat-8.0.47\webapps\server_war\WEB-INF\classes started by user in C:\App\apache-tomcat-8.0.47\bin)
2020-02-19 12:14:15.757 DEBUG 4436 --- [on(3)-127.0.0.1] com.myapp.Application              : Running with Spring Boot v2.2.4.RELEASE, Spring v5.2.3.RELEASE
2020-02-19 12:14:15.760  INFO 4436 --- [on(3)-127.0.0.1] com.myapp.Application              : No active profile set, falling back to default profiles: default
2020-02-19 12:14:15.937  INFO 4436 --- [on(3)-127.0.0.1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 113 ms
2020-02-19 12:14:15.994  INFO 4436 --- [on(3)-127.0.0.1] com.myapp.Application              : Started Application in 1.045 seconds (JVM running for 7.228)
[2020-02-19 12:14:16,029] Artifact server:war: Artifact is deployed successfully
[2020-02-19 12:14:16,029] Artifact server:war: Deploy took 5,204 milliseconds

As you can see, Spring is launched correclty but seems to not proceed all its starting tasks.

I already have the spring-boot-starter-tomcat provided in my pom and here is my Application.class:

@SpringBootApplication public class Application extends SpringBootServletInitializer {
  public static void main(String[] args) {
    SpringApplication.run(Application.class, args);
  }

  @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
    return builder.sources(Application.class);
  }
}

My questions are: Did I miss something in my configuration? How to run everything properly with Tomcat with multiple profiles (I am currently using VM options in the runner)?

Synops
  • 122
  • 3
  • 11
  • You seem to have only looked at the logging. Did you try creating a simple REST endpoint or something which you can GET from a browser to see if that does anything? – Gimby Feb 24 '20 at 09:01
  • Yes, and I got an Apache 404 returned... – Synops Feb 24 '20 at 09:54

3 Answers3

1

The Spring Boot Framework itself encapsulates an integrated Tomcat to facilitate implementation without the need to generate a .war and implement its own Tomcat in the traditional way, simply using, for example, the Maven plug-in and to execute it, you would have to use mvn spring-boot : run.

However, if that is how you want, you must generate the war from your Spring Boot project with maven and then add the war to the tomcat webapps folder and now you can launch tomcat locally to test. Follow the steps that are incorporated into the documentation and you should not have a problem.

https://www.baeldung.com/spring-boot-war-tomcat-deploy

To configure different profiles for deployment you must configure the Tomcat catalina.properties file, so as not to repeat myself a lot, take a look at the following thread:

How to specify a profile when deploying a Spring boot war file to Tomcat?

I hope it helps you!

  • Thanks for your answer, unfortunatly, I have already done the same settings like in your first link before writting my question. And yes, I have to generate the war for different reasons. – Synops Feb 19 '20 at 12:15
1

Can you show your pom.xml ? Try adding

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-test</artifactId>
    <scope>test</scope>
</dependency>

to get a more verbose output on startup try setting the logging properties https://www.javadevjournal.com/spring-boot/logging-application-properties/

aside from that the Tomcat that runs is a "apache-tomcat-8.0.47" and your servlet engine runs on Apache Tomcat/9.0.30

If your parent-pom is on 2.2.4 RELEASE your pom would depend on Tomcat 9 something. Spring Boot would also set the Tomcat up for you (hence your dependencies) at least if you run it on your local machine as Spring Boot app.

Bender
  • 72
  • 6
0

I found the solution to my problem, somehow (probably copy/pasted from other dependency declaration ahead) I set the spring-boot-autoconfigure depency to provided, but my tomcat don't have this dependency. So I just had to remove the provided scope and everything was fixed.

Synops
  • 122
  • 3
  • 11
  • That should have produced very clear error logging though which apparently you did not see. So that might be an indication of a secondary problem. Not being able to find your error logging is pretty crippling :) – Gimby Feb 28 '20 at 12:27
  • It might be, but how can I guess what kind of secondary problem it is ? And yeah, no error logging doesn't help at all :( – Synops Feb 28 '20 at 13:41