Post a complete error first
Caused by: java.lang.IllegalStateException: Detected both log4j-over-slf4j.jar AND bound slf4j-log4j12.jar on the class path, preempting StackOverflowError. See also http://www.slf4j.org/codes.html#log4jDelegationLoop for more details.
at org.slf4j.impl.Log4jLoggerFactory.<clinit>(Log4jLoggerFactory.java:54)
... 13 more
Then a word about my environment and requirements, my requirement is to use Spark to calculate data in SpringBoot and display it on the front end, here are my Maven dependencies
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
</parent>
<!--spark-->
<dependencies>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.11</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-sql_2.11</artifactId>
<version>2.1.1</version>
</dependency>
<!--json-->
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
<classifier>jdk15</classifier>
</dependency>
<!--springboot-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
Here I used JSON and made this error because log4j-over-SLf4J and SLf44j-log4J12 are two Jars associated with the Java logging system that can cause a stack overflow exception when they appear together under clasSPath. Because Spring has built-in logging dependencies
Understand the problem and you’ll solve it: Add it to Maven
<!--Global exclusion of all dependencies within spring-boot-starter-logging.-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
Remove all springboot log dependencies. If you need Springboot logs, manually configure log4j-over-SLf4J and SLf44J-log4J12 to not appear in the classpath at the same time
I hope it helped you
Read More:
- [Solved] fasterxml ToStringSerializerBase Error: Caused by: java.lang.NoClassDefFoundError…
- How to Fix Error Caused by: java.util.MissingResourceException: Can‘t find bundle for base name xxx, locale zh_CN
- JUnit test classes error: java.lang.IllegalStateException: Failed to load ApplicationContext
- How to Solve Swagger error: IllegalStateException
- [Solved] stream Convert list to map Error: java.lang.IllegalStateException: Duplicate key
- [Solved] java.lang.IllegalStateException: Cannot call sendRedirect() after the response has been committed
- [Solved] Java.lang.IllegalStateException: Type handler was null on parameter mapping for property ‘__frch_it
- [Solved] Internal error (java.lang.IllegalStateException): Duplicate key org.jetbrains
- [Solved] Failed to start bean ‘documentationPluginsBootstrapper’; nested exception is java.lang.NullPointerException
- [Solved] Java.lang.IllegalStateException: getReader() has already been called for this request
- [Solved] Error: caused by: java.net.bindexception: the address is already in use
- [Solved] Failed to start bean ‘eurekaAutoServiceRegistration‘; nested exception is java.lang.NullPointerExce
- [Solved] Java.lang.ClassCastException: [Ljava.lang.Long; cannot be cast to java.util.List
- [Solved] Openfegn Remote Call Error: java.lang.NullPointerException: null
- [Solved] Logstash Error: Logstash – java.lang.IllegalStateException: Logstash stopped processing because of an err
- IDEA-Error java error release version 5 not supported (How To Fix)
- [Solved] nacos Startup Error: nested exception is java.lang.RuntimeException: java.lang.RuntimeException: [db-load-error
- [Solved] IDEA springboot Startup Error: java.lang.UnsatisfiedLinkError: no tcnative-1 in java.library.path
- [Solved] swagger Failed to start bean ‘documentationPluginsBootstrapper‘; nested exception is java.lang.NullP
- [Solved] Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: