0

I have just started to integrate JoinFaces into JHipster, which was really easy.

Following the example of JoinFaces, I put xhtml files to src/resources/META-INF/resources

Normal builds like mvn -Pdev spring-boot:run run without any problems.

I struggle at just one last piece in the puzzle, the production build. As stated above, xhtml files are stored in src/resources/META-INF/resources. After a production build mvn -Pprod package, they are located inside the war at /WEB-INF/classes/META-INF/resources/.

Running the application results in Status: Not Found (Not Found) Message: Not Found at http://localhost:8080/index.jsf

How am I fixing this? I really have no idea where the jhipster spring-boot app expects them to be. Then I could adjust the pom accordingly (thinking maven-resource plugin)

John Smith
  • 752
  • 9
  • 35
  • Please improve your title... And in 99% of the cases, the webapp is looking for the xhtml files in the wrong place. This is not the default place? Where do you normally put them? What is the config then? Did the config change now – Kukeltje Aug 12 '17 at 09:21
  • I should improve my question so that it becomes more clear that yes, they are in the wrong place after doing a production build. I should point out that is clear that they are, as in 99,99% of the cases. I wonder if I should also improve my question so it becomes more clear that I search for a solution of this problem. The best place to start off would be the pom.xml, which is a 955 line long beast. Which is why I seek help. – John Smith Aug 12 '17 at 15:59
  • 1
    Why not the other way around? Put them in the location where JSF can find them? https://stackoverflow.com/questions/3512234/jsf-files-inside-web-inf-directory-how-do-i-access-them – Kukeltje Aug 12 '17 at 19:22
  • Non-Production builds work fine, I have to adjust the pom anyway, particularly for the production build. – John Smith Aug 12 '17 at 22:09

1 Answers1

0

Why not the other way around? Put them in the location where JSF can find them?

Good idea. So playing around with it a bit more, I figured out that jhipster expects html files to be in target/www/ when running into the package phase of Maven. I use the maven-resources-plugin for that.

The following adjustments to the pom.xml have been made:

<profiles>
    <profile>
        <id>prod</id>
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-undertow</artifactId>
            </dependency>
        </dependencies>
        <build>
            <plugins>
                <plugin>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>3.0.2</version>
                    <executions>
                        <execution>
                            <id>copy-resources</id>
                            <phase>compile</phase>
                            <goals>
                                <goal>copy-resources</goal>
                            </goals>
                            <configuration>
                                <outputDirectory>${basedir}/target/www/</outputDirectory>
                                <resources>
                                    <resource>
                                        <directory>src/main/resources/META-INF/resources/</directory>
                                        <filtering>false</filtering>
                                    </resource>
                                </resources>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

I have also excluded the src/main/resources/ from sonar

<sonar.exclusions>src/main/webapp/content/**/*.*, src/main/webapp/bower_components/**/*.*,src/main/resources/META-INF/**/*.*,
        src/main/webapp/i18n/*.js, target/www/**/*.*
</sonar.exclusions>
John Smith
  • 752
  • 9
  • 35