I'm tired of investigating this issue, and I can not find a proper answer. Actually, I didn't find anyone using Java 11 and Spring. My JSP are not loading, it is simply as that. Some information about my project:
Spring Boot version: 2.0.5.RELEASE
Java version: 11
Gradle: 4.10.2
These are my application.yml properties:
server:
contextPath: /mypath
port: 9012
display-name: my app
error:
whitelabel:
enabled: true
tomcat:
compression: on
compressableMimeTypes: application/json,application/xml,text/html,text/xml,text/plain
# springboot 1.3+ compression
# compression:
# enabled: true
# mime-types: application/json,application/xml,text/html,text/xml,text/plain
# enable HTTPS when running behind a proxy server
remote_ip_header: x-forwarded-for
protocol_header: x-forwarded-proto
use-forward-headers: true
# session timeout
session:
# spring time out set to 2hrs.
cookie:
max-age: 7200
timeout: 7200
# enabling SSL/HTTPS with spring boot
ssl:
enabled: true
key-store: /mykeystorepath/keystore.ks
key-store-password: password
key-store-type: JKS
key-alias: selfsigned
http:
mappers:
jsonPrettyPrint: true
multipart:
maxFileSize: 500MB
maxRequestSize: 500MB
fileSizeThreshold: 0
spring:
application:
name: appname
jmx:
enabled: true
default-domain: ${spring.application.name}
http:
# enable and force http encoding support.
encoding:
enabled: true
charset: UTF-8
force: true
mvc:
favicon:
enabled: true
view:
prefix: /WEB-INF/jsp/
suffix: .jsp
management:
server:
port: 9512
endpoints:
web:
base-path: /manage
swagger:
enable: false
endpoints:
shutdown:
enabled: true
#logging:
# level:
# org:
# springframework:
# web: DEBUG
My jsp files are in:
/parent-project-folder/my-app/src/main/webapp/WEB-INF/jsp/
My main class:
@SpringBootApplication(exclude = { SecurityAutoConfiguration.class })
public class Application extends SpringBootServletInitializer {
/** The log. */
private static final Logger LOG = LoggerFactory.getLogger(Application.class);
/**
* The main method.
*
* @param args the arguments
*/
public static void main(String[] args) {
SpringApplication springApplication = new SpringApplication(Application.class);
springApplication.addListeners(new ApplicationPidFileWriter(System.getProperty("user.home") + File.separator + "app.pid"));
springApplication.run(args);
LOG.info("--------------------------------------------------------------");
LOG.info("--------- application startup complete --------");
LOG.info("--------------------------------------------------------------");
}
/*
* (non-Javadoc)
*
* @see org.springframework.boot.web.support.SpringBootServletInitializer#configure(org.springframework.boot.builder.SpringApplicationBuilder)
*/
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
}
}
I even tried to put my WEB-INF folder under /src/main/resources.
Next, this is the list of my dependencies (just a draft copy-paste):
apply plugin: 'war'
compile 'javax.servlet:jstl:1.2'
classpath 'gradle.plugin.com.gorylenko.gradle-git-properties:gradle-git-properties:1.4.17'
classpath "org.springframework.boot:spring-boot-gradle-plugin:2.0.5"
classpath "com.netflix.nebula:gradle-ospackage-plugin:4.4.0"
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.5.4"
classpath 'com.github.ben-manes:gradle-versions-plugin:0.17.0'
classpath "gradle.plugin.com.github.spotbugs:spotbugs-gradle-plugin:1.6.4"
classpath 'com.github.samueltbrown:gradle-cucumber-plugin:0.5'
compile 'org.glassfish.corba:glassfish-corba-omgapi:4.2.0-b004'
compile 'org.jboss.spec.javax.xml.soap:jboss-saaj-api_1.3_spec:1.0.6.Final'
runtime 'org.springframework.boot:spring-boot-properties-migrator'
compile 'javax.xml.bind:jaxb-api:2.3.0'
compile 'com.sun.xml.bind:jaxb-core:2.3.0.1'
compile 'com.sun.xml.bind:jaxb-impl:2.3.0.1'
compile 'javax.activation:activation:1.1.1'
runtime 'javax.activation:javax.activation-api:1.2.0'
compile 'javax.inject:javax.inject:1'
compile 'org.apache.commons:commons-lang3:3.7'
compile "org.springframework.boot:spring-boot-starter-actuator"
compile "org.springframework.boot:spring-boot-starter-security"
compile (group: 'org.owasp.esapi', name: 'esapi', version:'2.1.0.1') {
exclude group: 'org.apache.xmlgraphics'
}
compile "com.google.code.gson:gson:${gsonVersion}"
compile 'taglibs:standard:1.1.2'
compile 'org.apache.tomcat.embed:tomcat-embed-jasper'
compile 'org.springframework.boot:spring-boot'
compile "org.springframework.cloud:spring-cloud-starter-config"
compile "org.springframework.boot:spring-boot-starter-web"
compile "org.springframework.boot:spring-boot-starter-tomcat"
compile "org.springframework.boot:spring-boot-starter-logging"
compile 'com.mangofactory:swagger-springmvc:1.0.2'
runtime group: 'ph.samson.logback', name: 'logback-luhn-mask', version:'1.0.1'
compile 'org.apache.xmlgraphics:batik-css:1.10'
compile 'commons-beanutils:commons-beanutils-core:1.8.3'
compile 'commons-fileupload:commons-fileupload:1.3.3'
compile 'xalan:xalan:2.7.2'
compile 'commons-httpclient:commons-httpclient:3.1'
compile 'org.owasp.antisamy:antisamy:1.5.7'
I have a login.jsp at the root, which I should be able like this https://localhost:9012/mypath/login.html, and it doesn't load.
UPDATE on Friday Nov 23
I'm making some progress. I will explain more about my app. Originally this app was written using Java 1.8 and Spring 1.5.9.RELEASE and BOMs for my development. The app used to have a GET controller under this path: "/login". And here comes the tricky part of it: whenever you hit the url "https://www.myapp.com/login.htm", in someway/somehow which I don't understand, Spring managed it to send the request for "login.htm" to the controller "/login". I'm not sure how it realized about the extra ".htm".
Now, as I'm using Java 11 and Spring 2.1.0.RELEASE, this doesn't work anymore. If I hit "/login" it goes to the controller. But I need to make a transparent migration, I can't change logic. This app serves requests, and the client side have been using "/login.htm" since years ago. I need to make "/login.htm" go to "/login".