Spark UI appears with wrong format (broken CSS)

2020-07-18 03:29发布

问题:

I am using Apache Spark for the first time. I run my application and when I access localhost:4040 I get what is shown in the picture. I found that maybe setting

spark.ui.enabled true 

could help but I don't know how to do that.

Thanks in advance.

回答1:

I have faced the same issue while using Spark on Google Cloud Dataproc.

If you will access Spark Job UI not through 4040 port directly, but through YARN Web UI (8088 port) you will see correctly rendered web pages.

To workaround this issue when accessing Spark UI directly through 4040 port you need to reset spark.ui.proxyBase property inside your Spark job (not in CLI/job submission command), because it gets overridden by Spark UI proxy:

sys.props.update("spark.ui.proxyBase", "")

Here is detailed description of this issue.



回答2:

I Had the same problem. Also the calls to http://localhost:4040/api/v1/applications failed returning with no response.

This happened due to a collision between 2 versions of Jersey in my classpath. Mainly conflict between 1.x and 2.x. What worked for me was to exclude in my Maven build the Jersey library that came from other dependencies that are not from Spark.

For example:

<dependency>
          <groupId>org.apache.parquet</groupId>
          <artifactId>parquet-avro</artifactId>
          <version>1.9.0</version> 

          <exclusions>
              <exclusion>
                  <groupId>com.sun.jersey</groupId>
                  <artifactId>*</artifactId>
              </exclusion>
          </exclusions>
</dependency>

Excluding version Jersey 1.x (My Spark distro used 2.x) solved the problem.

Edit:

Also -> happened when servlet api 2.5 JAR was in classpath instead or together with 3.x



回答3:

In case you are using WildFly, see if https://issues.apache.org/jira/browse/SPARK-27795 can help (there you find also (a quite ugly) workaround).



回答4:

I was also facing the same problem and tried with sys.props.update("spark.ui.proxyBase", ""). Spark UI was fixed but it was still triggering errors in logs for wrong CSS related to javax.

I added below dependency and it fixed all errors:

libraryDependencies += "javax.servlet" % "servlet-api" % "2.5" % "provided"