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

Static resources not included in Jar #704

@jgraham0325

Description

@jgraham0325

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions