Skip to content

AWS Glue v5.0 job Fontconfig head is null Error

2

Hello, all. Recently we migrated jobs from Glue 4.0 to 5.0 and we use pyspark. As for the doc Glue 5 dependencies are: Spark 3.5.2, Python 3.11,Scala 2.12.18 We use Spark-Excel 2.12-3.5.1_0.20.4 as this is the latest available to write output to Excel files. https://mvnrepository.com/artifact/com.crealytics/spark-excel And on the point of writing, we encounter an error that fails the job, this is a part of the trace we think is the root cause.

	at java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500) ~[?:?]
	at java.lang.reflect.Constructor.newInstance(Constructor.java:481) ~[?:?]
	at sun.font.FontManagerFactory$1.run(FontManagerFactory.java:85) ~[?:?]
	... 39 more
Caused by: java.lang.RuntimeException: Fontconfig head is null, check your fonts or fonts configuration
	at sun.awt.FontConfiguration.getVersion(FontConfiguration.java:1271) ~[?:?]
	at sun.awt.FontConfiguration.readFontConfigFile(FontConfiguration.java:224) ~[?:?]
	at sun.awt.FontConfiguration.init(FontConfiguration.java:106) ~[?:?]
	at sun.awt.X11FontManager.createFontConfiguration(X11FontManager.java:706) ~[?:?]
	at sun.font.SunFontManager$2.run(SunFontManager.java:358) ~[?:?]
	at sun.font.SunFontManager$2.run(SunFontManager.java:315) ~[?:?]

We found a related issue that suggests installing fonts or disabling them: https://docs.aspose.com/cells/java/how-to-fix-runtimeexception-fontconfig-head-is-null/

As we don't have any control over Glue image packages we tried to disable it with Java parameter -Djava.awt.headless=true like this:

spark_conf.set("spark.executor.extraJavaOptions", "-Djava.awt.headless=true")

We tried to pass it as part of the config file as well but it seems that it's not possible to pass extraJavaOptions from glue as we don't see any effect even when we try to set something like verbose GC. Does anybody know a way to pass the Java parameter using glue jobs or maybe knows how to workaround this issue? PS. On glue 4.0 and spark-excel_2.12-3.3.1_0.18.5.jar it works just fine.

asked 2 years ago305 views

1 Answer
0

The issue you're experiencing with AWS Glue 5.0 and the "Fontconfig head is null" error is likely related to font configuration in the Glue environment. This error typically occurs when the Java runtime cannot find or access the necessary font files.

Since you don't have direct control over the Glue image packages, passing Java parameters like -Djava.awt.headless=true can be challenging. However, there are a few approaches you can try to work around this issue:

  1. Use Glue job parameters: Instead of setting Spark configurations directly, try passing the Java option as a Glue job parameter. You can do this by adding --conf spark.executor.extraJavaOptions=-Djava.awt.headless=true to your job parameters.

  2. Set Spark configuration in your script: At the beginning of your Glue script, try setting the Spark configuration programmatically:

    from pyspark.conf import SparkConf
    conf = SparkConf()
    conf.set("spark.executor.extraJavaOptions", "-Djava.awt.headless=true")
    sc._jsc.sc().setConf(conf)
  3. Use a custom JAR: If possible, create a custom JAR that includes the necessary font files and add it to your Glue job's dependent JARs.

  4. Downgrade spark-excel: Consider using an earlier version of spark-excel that is compatible with Glue 5.0 and doesn't trigger this font issue.

  5. Alternative output format: If feasible for your use case, consider outputting to a different format (e.g., CSV) and then converting to Excel in a separate step.

If none of these solutions work, you may need to contact AWS support for further assistance, as they might be able to provide more specific guidance or a patch for this issue in the Glue 5.0 environment.

Remember to thoroughly test any changes in a non-production environment before applying them to your production jobs.

Sources
Upgrading from AWS Glue 4.0 to 5.0: PROXY Error and GlueBootstrap Bootstrapping Failure | AWS re:Post
Glue job failing with "Unknown time-zone ID: GMT000" error | AWS re:Post

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.