'Spring/React Web application wont load the page and get stack overflow error

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@Controller
public class HomeController {
  @GetMapping(value = {"/"})
  public String forward() {
    return "forward:/";
  }
}

When I start the server and try to load up the webpage it gives me this error over and over "ERROR 6880 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] threw exception"

I suspect it has something to do with my HomeController class not being able to communicate with the react side of things. I had this all working before and started the project back up recently and now it wont load properly.

Here is a snippet of my pom file.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.5.1</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>reviews</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>reviews</name>
    <description>Launch Group Project</description>
    <properties>
        <java.version>11</java.version>
        <maven.compiler.source>${java.version}</maven.compiler.source>
        <maven.compiler.target>${java.version}</maven.compiler.target>
        <frontend-plugin.version>1.7.6</frontend-plugin.version>
        <node.version>v14.15.0</node.version>
        <yarn.version>v1.16.0</yarn.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
    <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-validation</artifactId> 
    </dependency>

And a snippet of the client side error

There was an unexpected error (type=Internal Server Error, status=500).
No message available
java.lang.StackOverflowError
    at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:244)
    at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:583)
    at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:244)
    at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:583)
    at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:244)
    at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:583)
    at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:244)
    at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:583)


Solution 1:[1]

aren't you forwarding to the same URL? when entering "/" endpoint you forward to "another" endpoint with address "/" which is the same... so infinite loop occurs?
you can test if app works correctly by switching to @RestController and as a response displaying some string message.
If you want to enter the app from react side, you might need to setup @CrossOrigin as well, you can use "*" (allow all) for testing.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Nebra