3

My configration class looks as follow

@Configuration
@EnableAutoConfiguration
@ComponentScan(basePackages = "com.projectx")

public class Application extends SpringBootServletInitializer{

    public static void main(String[] args) {

        SpringApplication.run(applicationClass, args);

    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(Application.class);
    }
}

Also build.gradle file looks like this

apply plugin: 'java'
sourceCompatibility=1.8
targetCompatibility=1.8

apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot'
apply plugin: 'war'


mainClassName = 'com.projectx.data.config.Application'

buildscript {
    repositories {
        maven { url "http://repo.spring.io/libs-release" }
        mavenLocal()
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.1.RELEASE")
    }
}




war {
    baseName = 'gs-accessing-data-jpa'
    version =  '0.1.0'
}

repositories {
    mavenLocal()
    mavenCentral()
    maven { url "http://repo.spring.io/libs-release" }
    maven { url "https://repository.jboss.org/nexus/content/repositories/releases" }
}

configurations {

    providedRuntime

}

dependencies {
    compile("org.springframework.boot:spring-boot-starter-web")
    providedRuntime("org.springframework.boot:spring-boot-starter-tomcat")

}

So wherever i am deploying this project to tomcat it is showing following error. As I have mate all requirement to convert jar to war in spring not sure what is wrong this my project.

It gives 404 NOT FOUND.(I am using STS 3.6.0 with Gradle plugin)

MasterCode
  • 975
  • 5
  • 21
  • 44
  • Are you calling the correct URL? It looks like its deployed - but your not calling the correct URL – farrellmr Feb 20 '15 at 09:15
  • basically if you hit root then it will return error page defined in project when i run it as spring boot app with embedded tomcat..so i guess url is not an issue – MasterCode Feb 20 '15 at 09:24
  • Its a page not found error - what are you using to serve pages? Thymeleaf, jsp? You need to include the front end technlogy - eg compile("org.springframework.boot:spring-boot-starter-thymeleaf") – farrellmr Feb 20 '15 at 09:28
  • If same thing works fine with embedded server then why it is not working with external container..and I have tried doing that also,,still not working – MasterCode Feb 20 '15 at 09:33
  • Which URL are you calling standalone and which when deployed? What is the name of the war you are deploying? – M. Deinum Feb 20 '15 at 12:11
  • For standalone when I hit localhost:8080 it gives custom error page from by project...now with gs-handling-form-submission-0.1.0 war when I try to access http://localhost:8080/gs-handling-form-submission-0.1.0/. It giving me 404 – MasterCode Feb 20 '15 at 12:34

0 Answers0