Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android ExceptionInInitializerError Caused by Unable to determine record types while new HSSFWorkbook(inputStream)

Getting error

E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
       java.lang.RuntimeException: An error occured while executing doInBackground()
           at android.os.AsyncTask$3.done(AsyncTask.java:299)
           at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
           at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
           at java.util.concurrent.FutureTask.run(FutureTask.java:239)
           at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
           at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
           at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
           at java.lang.Thread.run(Thread.java:856)
        Caused by: java.lang.ExceptionInInitializerError
           at b.b.a.c.c.p.<init>(HSSFWorkbook.java:326)
           at b.b.a.c.c.p.<init>(HSSFWorkbook.java:289)
           at b.b.a.c.c.p.<init>(HSSFWorkbook.java:224)
           at b.b.a.c.c.p.<init>(HSSFWorkbook.java:382)
           at b.b.a.c.c.p.<init>(HSSFWorkbook.java:364)
           at com.d.link.d.d.a(ExportUtils.java:134)
           at com.d.link.activity.ey.a(SplashScreen.java:55)
           at com.d.link.activity.ey.doInBackground(SplashScreen.java:51)
           at android.os.AsyncTask$2.call(AsyncTask.java:287)
           at java.util.concurrent.FutureTask.run(FutureTask.java:234)
           at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230) 
           at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080) 
           at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573) 
           at java.lang.Thread.run(Thread.java:856) 
        Caused by: b.b.a.c.b.dj: Unable to determine record types
           at b.b.a.c.b.dd.a(RecordFactory.java:434)
           at b.b.a.c.b.dd.<clinit>(RecordFactory.java:292)
           at b.b.a.c.c.p.<init>(HSSFWorkbook.java:326) 
           at b.b.a.c.c.p.<init>(HSSFWorkbook.java:289) 
           at b.b.a.c.c.p.<init>(HSSFWorkbook.java:224) 
           at b.b.a.c.c.p.<init>(HSSFWorkbook.java:382) 
           at b.b.a.c.c.p.<init>(HSSFWorkbook.java:364) 
           at com.d.link.d.d.a(ExportUtils.java:134) 
           at com.d.link.activity.ey.a(SplashScreen.java:55) 
           at com.d.link.activity.ey.doInBackground(SplashScreen.java:51) 
           at android.os.AsyncTask$2.call(AsyncTask.java:287) 
           at java.util.concurrent.FutureTask.run(FutureTask.java:234) 
           at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230) 
           at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080) 
           at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573) 
           at java.lang.Thread.run(Thread.java:856) 

 

For the second line(new HSSFWorkbook from InputStream) FileInputStream fileInS = new FileInputStream(outputXlsFile); hwb = new HSSFWorkbook(fileInS);

where org.apache.poi.hssf.usermodel.HSSFWorkbook is from apachePoi library

like image 453
Shirish Herwade Avatar asked Dec 14 '22 07:12

Shirish Herwade


1 Answers

Cant' help about why exception is thrown, but I can help you about stopping the app being force closed.

The problem is linked to the ExceptionInInitializerError class, that isn't derived by java.lang.Exception. Instead it is derived from java.lang.Error superclass (see ExceptionInInitializerError declaration)

So the solution is to add an explicit catch block for such kind of exception like, for example, one of the following:

catch(ExceptionInInitializerError e) // catch exactly this error

catch(Error e) // catch all Java errors (not exceptions!)

catch(Throwable t) // catch all Java errors and exceptions

Note that first and second catch blocks must be added to your existing catches, while third one can substitute them, because Throwable is superclass of both Exception and Error Java classes.

like image 168
Carlo Avatar answered Dec 28 '22 09:12

Carlo