Issue
The spring-boot application is working fine with the integrated server but when I try to deploy it on tomcat9 getting the below error in /catalina.out
22-Jun-2021 15:05:38.148 INFO [http-nio-8080-exec-6] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
Could not retrieve system property 'spring.xml.ignore': java.security.AccessControlException: access denied ("java.util.PropertyPermission" "spring.xml.ignore" "read")
Error : Could not retrieve system property 'spring.xml.ignore': java.security.AccessControlException: access denied ("java.util.PropertyPermission" "spring.xml.ignore" "read")
Here is version information of the environment.
JAVA (Version : Open-jdk-16.0.1)
APACHE TOMCAT (Version : 9.x with )
Here is my spring class
package com.testpackage.tomcattest;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
@SpringBootApplication
public class TomcatApiTestRunner extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(TomcatApiTestRunner.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(TomcatApiTestRunner.class);
}
}
Here is the pom.xml
<?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>
<artifactId>tomcattest-api</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.2</version>
</parent>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<finalName>tomcattest-api</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>11</source>
<target>11</target>
<verbose>true</verbose>
</configuration>
</plugin>
</plugins>
</build>
</project>
application.properties
server.contextPath=/tomcattest-api
Solution
The Tomcat 9 installation that you are deploying to has been configured to prohibit the reading of system properties. You’ll need to ask whoever manages the installation to change its configuration. They can do so by modifying the catalina.policy
file to grant the required permissions.
Answered By - Andy Wilkinson