SoftInstigate / restheart-blog-example

Example blog application built with RESTHeart and AngularJS
GNU Affero General Public License v3.0
9 stars 6 forks source link

Embedding static resources doesn't work #5

Closed hannomalie closed 8 years ago

hannomalie commented 8 years ago

We tried to serve a small angular app via restheart. When we configure the resource as non-embedded, everything works fine. With 'embedded' set to 'true', we tried two scenarios: First, we added a seperate jar containing our app. Second, we simply copied our app into the root path of the restheart.jar file. In both cases, restheart reports a warning and an error:

15:38:28.794 [main] WARN o.restheart.utils.ResourcesExtractor - no resource to extract from path caas 15:38:28.796 [main] ERROR org.restheart.Bootstrapper - Error extracting embedded static resource caas java.lang.IllegalStateException: no resource to extract from path caas at org.restheart.utils.ResourcesExtractor.extract(ResourcesExtractor.java:85) at org.restheart.Bootstrapper.lambda$pipeStaticResourcesHandlers$2(Bootstrapper.java:776) at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1374) at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580) at org.restheart.Bootstrapper.pipeStaticResourcesHandlers(Bootstrapper.java:745) at org.restheart.Bootstrapper.getHandlersPipe(Bootstrapper.java:685) at org.restheart.Bootstrapper.startCoreSystem(Bootstrapper.java:558) at org.restheart.Bootstrapper.startServer(Bootstrapper.java:360) at org.restheart.Bootstrapper.main(Bootstrapper.java:137)

Our app is completely contained in a folder named 'caas' - within this folder, there are additional folders. We configured this folder in the exact same way as your HAL-browser is configured and embedded, but the error remains. Any ideas?

mkjsix commented 8 years ago

Hi @hannespernpeintner , The "embedded" is meant for a component that is tightly coupled with the restheart distribution, like the HAL browser, for Web apps that you just want to serve via restheart I'd go for the non-embedded configuration, exactly like the blog example. What's your specific requirement for using the embedded configuration?

ujibang commented 8 years ago

you should be able to distribute your app embedding it in the jar. the hal browser does actually work this way.

please paste in a comment your 'static-resources-mounts' configuration

do you also confirm that in the jar the folder caas is at the same level than the folder browser, for instrance by running jar -tf restheart.jar | grep caas/

hannomalie commented 8 years ago

@mkjsix yea, this app is... kind of... coupled to our restheart distribution. Having it not embedded would work as well, but it would be interesting if we did anything wrong, or if you have a bug :)

@ujibang As said, we copied our app directly into the root path of the restheart jar, just where the HAL browser lies. Our 'static-resources-mounts' is the following:

- what: browser
  where: /browser
  welcome-file: browser.html
  secured: false
  embedded: true

- what: caas
  where: /caas
  welcome-file: login/index.html
  secured: false
  embedded: false
ujibang commented 8 years ago

try embedded: true

hannomalie commented 8 years ago

xD

That's of course what I tried already. The posted one is the currently working configuration with the resources not embedded.

ujibang commented 8 years ago

I tried it and got the same issue.

I found a workaround by adding the resources in the jar in a directory (not right under the root)

try as follows

mkdir ext
mv caas ext

now your resources are in ext/caas

add ext to the jar

jar -uf restheart.jar ext

in the configuration file

static-resources-mounts:
    - what: ext/caas
      where: /caas
      welcome-file: index.html
      secured: false
      embedded: true

I created an issue in our jira, going to fix it in next version: https://softinstigate.atlassian.net/browse/RH-204

hannomalie commented 8 years ago

Since the workaround with not embedding the folder ist more suitable for us, we go this way. Happy fixing :)