tomcat - Spring Boot War file gets 404 on ec2 -
i put simple eclipse spring boot rest program. couple of endpoints return strings. building eclipse gradle plug-in. no problems, runs fine in eclipse provided tomcat instance. ran on native windows tomcat. deployed .war file using tomcat web application manager using deploy feature. runs fine. deployed ec2 ubuntu instance , again used tomcat web application manager , upload .war file. rest program correctly displayed in applications window not run. used following url,
http://ec2-ip-address/demo-0.0.1-snapshot/hello
i keep getting 404's. pretty sure tomcat deployment , ec2 environment appears correct because can run tomcat7-examples in ec2 instance no issues. appreciated.
awselbrestserveraapplication.java file:
package demo; import org.springframework.boot.springapplication; import org.springframework.boot.autoconfigure.springbootapplication; import org.springframework.context.annotation.componentscan; import org.springframework.context.annotation.configuration; @springbootapplication public class awselbrestserveraapplication { public static void main(string[] args) { springapplication.run(awselbrestserveraapplication.class, args); } }
servletinitializer.java file:
package demo import org.springframework.boot.builder.springapplicationbuilder; import org.springframework.boot.context.web.springbootservletinitializer; public class servletinitializer extends springbootservletinitializer { @override protected springapplicationbuilder configure(springapplicationbuilder application) { return application.sources(awselbrestserveraapplication.class); } }
restcontroller.java file:
package demo import org.springframework.stereotype.controller; import org.springframework.web.bind.annotation.requestmapping; import org.springframework.web.bind.annotation.responsebody; @controller public class restcontroller { @requestmapping("/hello") public @responsebody string hello() { return "greetings server a"; } @requestmapping("/heartbeat") public @responsebody string heartbeat() { return "server still running"; } }
build.gradle file:
buildscript { ext { springbootversion = '1.2.4.release' } repositories { mavencentral() } dependencies { classpath("org.springframework.boot:spring-boot-gradle plugin:${springbootversion}") classpath("io.spring.gradle:dependency-management plugin:0.5.1.release") } } apply plugin: 'java' apply plugin: 'eclipse-wtp' apply plugin: 'idea' apply plugin: 'spring-boot' apply plugin: 'io.spring.dependency-management' apply plugin: 'war' war { basename = 'demo' version = '0.0.1-snapshot' } sourcecompatibility = 1.8 targetcompatibility = 1.8 repositories { jcenter() maven { url "http://repo.spring.io/libs-snapshot" } } configurations { providedruntime } dependencies { compile("org.springframework.boot:spring-boot-starter-actuator") compile("org.springframework.boot:spring-boot-starter-remote-shell") compile("org.springframework.boot:spring-boot-starter-web") providedruntime("org.springframework.boot:spring-boot-starter-tomcat") testcompile("org.springframework.boot:spring-boot-starter-test") } eclipse { classpath { containers.remove('org.eclipse.jdt.launching.jre_container') containers 'org.eclipse.jdt.launching.jre_container/ org.eclipse.jdt.internal.debug.ui.launcher.standardvmtype/ javase-1.8' } } task wrapper(type: wrapper) { gradleversion = '2.3' }
i've answered similar question here.
you running external tomcat under java 1.7 jre, while having compiled code against 1.8.
strangely, there no error, , app appears in manager app, 404 when you're trying access it.
one way confirm @ tomcat log output, won't see spring boot banner.
to solve can compile code against java 1.7.
Comments
Post a Comment