How to fix ExceptionInInitializerError in DFSMiniCluster caused by wrong default file permissions on certain linux distros on your bamboo OnDemand setup.
If your JUnit tests utilize DFSMiniCluster, you may hit an ExceptionInInitializerError when building your project on Bamboo OnDemand using elastic agents.
java.lang.ExceptionInInitializerError: null
at org.apache.hadoop.hdfs.MiniDFSCluster.startDataNodes(MiniDFSCluster.java:426)
at org.apache.hadoop.hdfs.MiniDFSCluster.(MiniDFSCluster.java:284)
at org.apache.hadoop.hdfs.MiniDFSCluster.(MiniDFSCluster.java:124)
at org.apache.pig.test.MiniCluster.setupMiniDfsAndMrClusters(MiniCluster.java:54)
at org.apache.pig.test.MiniGenericCluster.(MiniGenericCluster.java:50)
at org.apache.pig.test.MiniCluster.(MiniCluster.java:35)
at org.apache.pig.test.MiniGenericCluster.(MiniGenericCluster.java:46)
at org.apache.accumulo.pig.AccumuloPigClusterTest.setupClusters(AccumuloPigClusterTest.java:65)
This error is documented in HBASE-8944 and HDFS-2556 and there is a workaround for this kind of error happening on certain linux distros: You need to adjust your default file permissions on your linux system and change it to
umask 022
How to apply this to your elastic agent in Bamboo OnDemand
You could create your own custom elastic image or you can use “Instance Startup Script” functionality to inject this configuration on your (standard) instance types.
Navigate to Image Configurations and click edit on each instance type you want to configure. Then add
echo "umask 022" >> /etc/profile
to the Instance Startup Script section and you are done. Terminate and restart running instance and rebuild your project.