0

This is a continuation of another question that got partially answered. Since the question morphed, I thought I should open a question that is more inline with that.

I have a project that started out as a spring-boot 1.1.7.RELEASE and I started from a directory containing the jar and an application.properties file via:

java -jar edm-0.1.0.jar 

Everything was right as rain until I upgraded to spring-boot 1.2.1.RELEASE. Now, when I try to start with java -jar the app appears to start but trying to login gives me an error that the /templates html pages aren't found.

It would appear that the preferred way to start spring-boot apps is:

gradle bootRun

This would appear to work as long as I am in the top level of my project directory. But if I move the jar file off to another directory, and try to run it, I get the error: :temp$ gradle bootRun

FAILURE: Build failed with an exception.

* What went wrong:
Task 'bootRun' not found in root project 'temp'.

* Try:
Run gradle tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

so when I run "gradle tasks" I can see that "bootRun" is not available:

:temp$ gradle tasks
:tasks

------------------------------------------------------------
All tasks runnable from root project
------------------------------------------------------------

Build Setup tasks
-----------------
init - Initializes a new Gradle build. [incubating]
wrapper - Generates Gradle wrapper files. [incubating]

Help tasks
----------
dependencies - Displays all dependencies declared in root project 'temp'.
dependencyInsight - Displays the insight into a specific dependency in root project 'temp'.
help - Displays a help message
projects - Displays the sub-projects of root project 'temp'.
properties - Displays the properties of root project 'temp'.
tasks - Displays the tasks runnable from root project 'temp'.

I guess this is a spring-boot gradle issue, but I can't say for sure. My version:

:temp$ gradle -version

------------------------------------------------------------
Gradle 1.10
------------------------------------------------------------

Build time:   2013-12-17 09:28:15 UTC
Build number: none
Revision:     36ced393628875ff15575fa03d16c1349ffe8bb6

Groovy:       1.8.6
Ant:          Apache Ant(TM) version 1.9.2 compiled on July 8 2013
Ivy:          2.2.0
JVM:          1.8.0_31 (Oracle Corporation 25.31-b07)
OS:           Mac OS X 10.10.2 x86_64

And here is my build.gradle:

apply plugin: 'java'
apply plugin: 'groovy'
apply plugin: 'idea'
apply plugin: 'spring-boot'
apply plugin: 'jacoco'
apply plugin: 'maven'

idea {
    project {
        //if you want to set specific jdk and language level
        jdkName = '1.8'
        languageLevel = '1.8'
    }
}

jacoco {
    toolVersion = "0.7.0.201403182114"
}

project.ext {
    springBootVersion = '1.2.1.RELEASE'
}

configurations {
    querydslapt
}

buildscript {
    repositories {
        maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
        maven { url "http://repo.spring.io/libs-milestone" }
        maven { url "http://repo.spring.io/libs-snapshot" }
        mavenLocal()
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.1.RELEASE")
    }
}

jar {
    baseName = 'edm'
    version = '0.1.0'
}

repositories {
    mavenCentral()
    maven { url "http://repo.spring.io/libs-milestone" }
    maven { url "https://repository.jboss.org/nexus/content/repositories/releases" }
    maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
    maven { url "http://repo.spring.io/snapshot" }
    maven { url 'http://repo.spring.io/milestone' }
}

dependencies {
    querydslapt group: 'com.mysema.querydsl', name: 'querydsl-jpa', version: '2.8.0', classifier:   'apt-one-jar', transitive: false

    compile("org.springframework.boot:spring-boot-starter-web:$springBootVersion")
    compile("org.springframework.boot:spring-boot-starter-thymeleaf")
    compile("org.springframework.boot:spring-boot-starter-security")
    compile("org.springframework.boot:spring-boot-starter-data-jpa:$springBootVersion")
    compile("org.springframework.security:spring-security-web:4.0.0.M1")
    compile("org.springframework.security:spring-security-config:4.0.0.M1")
    compile('org.thymeleaf.extras:thymeleaf-extras-springsecurity3:2.1.1.RELEASE')

    compile('com.android.tools.build:gradle:1.0.1')
task wrapper(type: Wrapper) {
        gradleVersion = '2.0'
}

I did read the documentation, but nothing seems to address why I am having this problem. I would really appreciate any help you can send my way.

Community
  • 1
  • 1
sonoerin
  • 5,015
  • 23
  • 75
  • 132
  • Is your project hosted online? To have a try? – Opal Feb 17 '15 at 07:30
  • "It would appear that the preferred way to start spring-boot apps is `gradle bootRun`" - I don't think that is preferred by many, and certainly doesn't replace the `java -jar ...` option in production. You now have 2 questions here: "how to run an app from gradle?" and "how to fix the HTML template path in a broken jar?". I suggest you decide which one you want to ask and revise the question (or split it in 2). – Dave Syer Feb 17 '15 at 08:15
  • possible duplicate of [Spring-Boot html in /templates don't render from command line](http://stackoverflow.com/questions/28501414/spring-boot-html-in-templates-dont-render-from-command-line) – Dave Syer Feb 17 '15 at 08:57
  • I suggested using `gradle bootRun` in the other question, not because it's a recommended way to run you app, but as a way of narrowing down what the problem might be. You've now posted two questions that are essentially asking the same thing, neither of which actually contains enough information to diagnose the problem. May I suggest that you read http://stackoverflow.com/help/mcve and update one of the questions accordingly? – Andy Wilkinson Feb 17 '15 at 10:45
  • My apologies for the confusion, I thought I was facing two related issues, that would best be served with two specific questions. The other one was about the project being run incorrectly with "java -jar" and this one about using "gradle bootRun". Also, after @Andy suggestion about using gradle bootRun it seemed to me that my issue was gradle related, not jar file related. I will close this one, and return to that one. I would really like help understanding why this won't work. – sonoerin Feb 17 '15 at 12:23
  • `But if I move the jar file off to another directory, and try to run it` do you move the build.gradle file too ? how do you structure the new project. If you intend to move the jar file you should use the `java -jar ...` command – Frederic Henri Oct 13 '15 at 19:49

0 Answers0