Skip to content
This repository has been archived by the owner on May 30, 2019. It is now read-only.

Static resources not included in Jar #704

Open
jgraham0325 opened this issue Oct 20, 2016 · 1 comment
Open

Static resources not included in Jar #704

jgraham0325 opened this issue Oct 20, 2016 · 1 comment

Comments

@jgraham0325
Copy link

Hi Folks,

Been doing a bit of fiddling about with generating a Jar and then deploying it to a separate server and found a bit of an issue.

Steps to reproduce:

  1. Open command prompt
  2. cd marklogic-samplestack\appserver\java-spring
  3. gradlew assemble
  4. cd build\libs
  5. java -jar samplestack-1.1.0.jar
    (NB, don't run it from the java-spring folder)

Expected result:

  • Application starts up using embedded tomcat and serves all content

Actual Result:

  • Application starts up and doesn't throw any errors, but can't access the home page (index.html. There is no static content in the jar file (extracting the jar confirms this)

Potential Fix:
It seems the reason for this is by default gradle doesn't include the "static" folder in its current location
Steps

  1. Move "static" folder into src/main/resources
  2. Rebuild -> now present in Jar
  3. Update marklogic-samplestack\shared\js\dev-tasks\context.js to:
    var javaStaticDir = path.resolve(
    projectRoot, 'appserver/java-spring/src/main/resources'
    );

Keen to hear if people think this is a sensible approach or if there's an obviously better way to go about it.

Here's a related stackoverflow answer:
http://stackoverflow.com/questions/29172612/spring-boot-app-not-serving-static-content

The spring boot docs mention this:
http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-developing-web-applications.html#boot-features-spring-mvc-static-content

Thanks,
James

@grechaw
Copy link
Contributor

grechaw commented Oct 20, 2016

Hi James, thanks for the detailed report, looks like it will be a straightforward change.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants