marklogic-samplestack icon indicating copy to clipboard operation
marklogic-samplestack copied to clipboard

Static resources not included in Jar

Open jgraham0325 opened this issue 9 years ago • 1 comments

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

jgraham0325 avatar Oct 20 '16 15:10 jgraham0325

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

grechaw avatar Oct 20 '16 16:10 grechaw