0

I have tried multiple combinations with frontend-maven-plugin but getting GET http://localhost:8081/demo/static/js/2.8d94841d.chunk.js net::ERR_ABORTED 404 this type of error on a View (JSP) where react page is included. I'm assuming it's due to an installation or page linking error while packaging.

my POM file snippet

           <plugin>
                <groupId>com.github.eirslett</groupId>
                <artifactId>frontend-maven-plugin</artifactId>
                <version>1.7.6</version>
                <configuration>
                    <workingDirectory>${frontend-src-dir}</workingDirectory>
                    <installDirectory>${project.build.directory}</installDirectory>
                </configuration>
                <executions>
                    <execution>
                        <id>install node and npm</id>
                        <goals>
                            <goal>install-node-and-npm</goal>
                        </goals>
                        <configuration>
                            <nodeVersion>v14.17.0</nodeVersion>
                            <npmVersion>6.14.13</npmVersion>
                        </configuration>
                    </execution>
                    <execution>
                        <id>npm install</id>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <configuration>
                            <arguments>install</arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>npm run build</id>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <configuration>
                            <arguments>run build</arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
             <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>generate-resources</phase>
                        <configuration>
                            <target>
                                <copy todir="target/Studio/resources/react">
                                    <fileset dir="${project.basedir}/react/demo/build"/>
                                </copy>
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

path to my react app - {frontend-src-dir}

JSP snippet with react app react app-

        <jsp:include page="HeaderPage.jsp">
            <jsp:param name="title" value="" />
        </jsp:include>
        
        <%@include file="/resources/react/index.html"%>
               

         <jsp:include page="FooterPage.jsp">
            <jsp:param name="title" value="" />
         </jsp:include> 
                

Project structure Project structure image

  • Are you sure you have a working build under `{frontend-src-dir}`? Did you successfully run this build outside? – k-wasilewski Jun 01 '21 at 17:21
  • Yes, I did run it separately and it ran successfully. This even worked when I run the project as Spring Boot in STS, but when I try to package it as war and run on tomcat, I get this error on the page which includes react app. – Rahul Tambe Jun 01 '21 at 18:17

0 Answers0