Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Boot JSF packaging as a JAR

I am trying to create a spring boot app with jsf and gradle.

So far, during development everything was fine. When I wanted to run my App I just typed gradle bootRun, the app started and I was able to access it under 'localhost'.

Now I am at a point of time, where I want to deploy the app, therefore I run the command 'gradle clean distTar' which creates the tar file to deploy.

After running the generated script and accessing my app via Browser I just get an 404 with the message.

index.xhtml Not Found in ExternalContext as a Resource

Also in the jar file, there aren't any html files included. I included them in the jar with the command

from ("${projectDir}/src/main/webapp/"){
    into('resources')
}

Referring to https://spring.io/blog/2013/12/19/serving-static-web-content-with-spring-boot this files should be accessible. But still nothing changed.

Does anyone else have a clue? What am I doing wrong?

BR

like image 421
questionaire Avatar asked Feb 03 '26 20:02

questionaire


1 Answers

I've been also struggling with this thing and finally managed to come up with a working solution.

As stated in: https://stackoverflow.com/a/9473487/4250114 if you use Servlet3.x (and you probably are with SpringBoot).

For me structure in maven looks like below worked:

 src 
   |-main
     | ...
     |-resources
        |-META-INF
           |-faces-config.xml
           |-resources
               |-test.xhtml

So in jar it should be:

|-META-INF
    |-faces-config.xml
    |-resources
        |-test.xhtml
like image 56
Dawid Wysakowicz Avatar answered Feb 06 '26 10:02

Dawid Wysakowicz