2

I am moving from Maven to Gradle and a Spring boot service fails to come up when run via the Gradle generated jar file. The app runs fine as a Spring app or when run as a jar generated through maven. I have a feeling we are missing some dependency in Gradle but not able to place a finger on it. Appreciate if someone can point out what I am missing.

Error:

{"timestamp":"2021-09-15 03:37:23 UTC","message":"Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tomcatServletWebServerFactory'
defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryConfiguration$EmbeddedTomcat.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'servletWebServerFactoryCustomizer' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryAutoConfiguration.class]: Unsatisfied dependency expressed through method 'servletWebServerFactoryCustomizer' parameter 0; nested exception is org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'server-org.springframework.boot.autoconfigure.web.ServerProperties': Could not bind properties to 'ServerProperties' : prefix=server, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'server.error.include-stacktrace' to org.springframework.boot.autoconfigure.web.ErrorProperties$IncludeAttribute","thread":"main","logLevel":"WARN","fileName":"AbstractApplicationContext.java","line":591,"serviceCode":"SMPL-JAVA-MS"}
{"timestamp":"2021-09-15 03:37:23 UTC","message":"\n\nError starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.","thread":"main","logLevel":"INFO","fileName":"ConditionEvaluationReportLoggingListener.java","line":136,"serviceCode":"SMPL-JAVA-MS"}

Gradle dependencies

  implementation 'org.modelmapper:modelmapper:2.4.2'
  implementation 'org.springframework.boot:spring-boot-starter-web:+'
  implementation 'org.springframework.boot:spring-boot-starter-validation:+'
  implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:+'
  implementation 'io.springfox:springfox-swagger2:3.0.0'
  implementation 'io.springfox:springfox-swagger-ui:3.0.0'
  implementation 'io.springfox:springfox-boot-starter:3.0.0'
  implementation 'org.springframework.boot:spring-boot-starter-webflux:+'
  implementation 'org.opensaml:opensaml:2.5.1-1'
  implementation 'org.springframework.boot:spring-boot-starter-data-jpa:+'
  implementation 'org.springframework.boot:spring-boot-starter-test:+'
  implementation 'com.google.guava:guava:30.1.1-jre'
  runtimeOnly 'org.projectlombok:lombok:1.18.20'
  runtimeOnly 'org.postgresql:postgresql:+'
  runtimeOnly 'org.springframework.boot:spring-boot-devtools:+'
  testImplementation 'org.springframework.boot:spring-boot-starter-test:+'

pox.xml

    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.4.3</version>
    <relativePath />
  </parent>

  <groupId>***</groupId>
  <artifactId>***</artifactId>
  <version>1.0.0</version>
  <name>***</name>
  <description>***</description>

  <properties>
    <java.version>16</java.version>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.projectlombok</groupId>
      <artifactId>lombok</artifactId>
      <version>1.18.20</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.modelmapper</groupId>
      <artifactId>modelmapper</artifactId>
      <version>2.4.2</version>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-test</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-validation</artifactId>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.dataformat</groupId>
      <artifactId>jackson-dataformat-xml</artifactId>
    </dependency>

    <!-- swagger UI at http://localhost:8080/swagger-ui/index.html -->
    <dependency>
      <groupId>io.springfox</groupId>
      <artifactId>springfox-swagger2</artifactId>
      <version>3.0.0</version>
    </dependency>
    <dependency>
      <groupId>io.springfox</groupId>
      <artifactId>springfox-swagger-ui</artifactId>
      <version>3.0.0</version>
    </dependency>
    <dependency>
      <groupId>io.springfox</groupId>
      <artifactId>springfox-boot-starter</artifactId>
      <version>3.0.0</version>
    </dependency>

    <!-- Web Client for accessing external requests -->
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-webflux</artifactId>
    </dependency>
    <dependency>
      <groupId>org.opensaml</groupId>
      <artifactId>opensaml</artifactId>
      <version>2.5.1-1</version>
    </dependency>

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
      <groupId>org.postgresql</groupId>
      <artifactId>postgresql</artifactId>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-test</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-test</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
      <version>30.1.1-jre</version>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-devtools</artifactId>
      <scope>runtime</scope>
      <optional>true</optional>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
      </plugin>
    </plugins>
  </build>
3
  • 1
    Can you please provide the maven dependencies so that we can try with the same? Commented Sep 16, 2021 at 5:37
  • Without the pom.xml and the full build.gradle this will be impossible to answer. One thing I notice is the + for the version, those shouldn't be there and that you have spring-boot-starter-test both as a test and implementation dependency (that should be only for test). Commented Sep 16, 2021 at 6:00
  • @Supritam I have updated my Q with pom.xml contents. And removing the spring-boot-starter-test duplicate entry did not help. Commented Sep 16, 2021 at 7:06

2 Answers 2

2

Found the issue. Turned out to be a deprecated property in my application.properties file. This needed to go:

server.error.include-stacktrace=ON_TRACE_PARAM
Sign up to request clarification or add additional context in comments.

Comments

1

The enum values for ErrorProperties.IncludeAttribute due to Reason:

failed to convert java.lang.String to org.springframework.boot.autoconfigure.web.ErrorProperties$IncludeAttribute (caused by java.lang.IllegalArgumentException: No enum constant org.springframework.boot.autoconfigure.web.ErrorProperties.IncludeAttribute.on-trace-param)

We may need to change the application.yml if using spring boot 3.x

servlet:
  error:
    include-stacktrace: ON_PARAM // Replace "on-trace-param" with "ON_PARAM"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.