'Error when launching a web application on Spring-Boot
I'm trying to create a web application. JDK 11 Server Payara 5.2020 (GlassFish). The app is almost empty. Only interfaces are described. And configuration files. An error occurs at startup:
[2020-11-17T19:21:17.468+0300] [Payara 5.2020] [SEVERE] [AS-WEB-CORE-00108] [javax.enterprise.web.core] [tid: _ThreadID=117 _ThreadName=admin-thread-pool::admin-listener(1)] [timeMillis: 1605630077468] [levelValue: 1000] [[
ContainerBase.addChild: start:
at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:283)
at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:362)
at com.sun.enterprise.v3.server.ApplicationLifecycle.initialize(ApplicationLifecycle.java:621)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:565)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:556)
19:21:17.452 [admin-thread-pool::admin-listener(1)] ERROR org.springframework.boot.SpringApplication - Application run failed
java.lang.NoSuchMethodError: 'void org.yaml.snakeyaml.LoaderOptions.setMaxAliasesForCollections(int)'
at org.springframework.boot.env.OriginTrackedYamlLoader.createYaml(OriginTrackedYamlLoader.java:67)
what does org.yaml.snakeyaml.LoaderOptions.setMaxAliasesForCollections? file application.yml:
spring:
datasource:
default-catalog: library
jndi-name: jdbc/Library
jpa:
database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
properties:
hibernate:
current_session_context_class: org.springframework.orm.hibernate5.SpringSessionContext
dialect: org.hibernate.dialect.MySQL5Dialect
format_sql: true
show-sql: true
logging:
file:
name: c:\logs\app.log
pattern:
file: "%d{HH:mm:ss} %-5p [%c] - %m%n"
level:
ROOT: error
org.springframework: warn
javax.faces: warn
org.omnifaces: warn
org.springframework.security: warn
org.hibernate: trace
org.hibernate.type.descriptor.sql: trace
file pom.xml Where there may be a version conflict. Maybe something related to JFS?
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>ru.javabegin.library</groupId>
<artifactId>my-library</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>my-library</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
<slf4j-api.version>1.7.30</slf4j-api.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
<version>2.3.5.RELEASE</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.4.22.Final</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j-api.version}</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>30.0-jre</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>8.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>6.2</version>
</dependency>
<dependency>
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>org.omnifaces</groupId>
<artifactId>omnifaces</artifactId>
<version>2.5.1</version>
</dependency>
<dependency>
<groupId>net.bootsfaces</groupId>
<artifactId>bootsfaces</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-
fileupload/commons-fileupload -->
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.3</version>
</dependency>
</project>
Solution 1:[1]
You have the wrong snake-yaml library on your classpath. Use mvn dependency:tree to analyze your project and exclude the wrong library after you found the problem.
Solution 2:[2]
It might be happening because of snakeYml version conflict between JDK and Spring in the build path
Solution 3:[3]
For me, version of snakeyaml had conflict so it was using 1.24 version of snakeyaml instead of 1.28. Version 1.24 does not have setMaxAliasesForCollections() method.
So I added its dependency explicitly in POM so that right version of it get picked up.
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.28</version>
</dependency>
Now it works because snakeyaml:1.28 has setMaxAliasesForCollections() method
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Balázs Németh |
| Solution 2 | Deepak Jain |
| Solution 3 | Sunil Kumar Singh |
