I have a Spring Boot Java application that I have followed the tutorials to set up so that it builds a WAR. I am attempting to deploy this WAR file using Jenkins, to a remote Tomcat 7 server. When I tell Jenkins to build and deploy the app the log in Jenkins shows that everything was successful. If I log into the remote server that is hosting Tomcat, I can see that the WAR was copied to the server. If I look in the log files, it shows this:
INFO: Manager: list: Listing contexts for virtual host 'localhost'
Jun 03, 2016 10:17:10 PM org.apache.catalina.core.ApplicationContext log
INFO: Manager: undeploy: Undeploying web application at '/webapp'
Jun 03, 2016 10:17:11 PM org.apache.catalina.core.ApplicationContext log
INFO: Manager: deploy: Deploying web application '/webapp'
Jun 03, 2016 10:17:11 PM org.apache.catalina.core.ApplicationContext log
INFO: Manager: Uploading WAR file to /var/lib/tomcat7/webapps/webapp.war
Jun 03, 2016 10:17:19 PM org.apache.catalina.core.ApplicationContext log
INFO: 1 Spring WebApplicationInitializers detected on classpath
If I go to the tomcat manager app, it shows that webapp is deployed and running. But if I click the link to the context path, I get a 404. I can't figure out for the life of me why this is not working.
This is my build.gradle file and I am running the bootRepackage command to generate the WAR:
buildscript {
ext {
springBootVersion = '1.3.5.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'spring-boot'
apply plugin: 'war'
war {
baseName = 'web'
version = '1.0.1'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
}
configurations {
providedRuntime
}
dependencies {
compile("org.springframework.boot:spring-boot-starter-web:1.3.3.RELEASE")
compile('com.amazonaws:aws-java-sdk:+')
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile('mysql:mysql-connector-java')
compile('org.springframework.boot:spring-boot-starter-thymeleaf')
providedRuntime('org.springframework.boot:spring-boot-starter-tomcat')
testCompile('org.springframework.boot:spring-boot-starter-test')
}
task wrapper(type: Wrapper) {
gradleVersion = '2.9'
}
So I feel kind of dumb now, but the issue was Jenkins was building in Java 1.8 and Tomcat on my server was running in Java 1.7. I edited the file at /etc/default/tomcat7
and added 'JAVA_HOME='. Restarted Tomcat and voila, it worked like a champ.
Slightly frustrating as nothing in any logs indicated that this was a problem. Everything pretended to work, even though it was returning 404s.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.