Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.NullPointerException: Attempt to read from field 'java.util.List org.readium.r2_streamer.model.publication.EpubPublication.links' on a null object reference #221

Closed
hrishikesh-kadam opened this issue Jun 22, 2018 · 7 comments

Comments

@hrishikesh-kadam
Copy link
Contributor

`06-18 05:48:08.241 3435-3435/de.appcuisine.tigermedia.tigerbooks.alpha I/System.out: EpubContainer Reading epub at path: /storage/emulated/0/Android/data/de.appcuisine.tigermedia.tigerbooks.alpha/files/1478407.epub
06-18 05:48:08.241 3435-3435/de.appcuisine.tigermedia.tigerbooks.alpha I/System.out: EpubContainer Reading file at path: mimetype
06-18 05:48:08.287 3435-3435/de.appcuisine.tigermedia.tigerbooks.alpha I/System.out: EpubContainer Reading file at path: META-INF/container.xml
06-18 05:48:08.289 3435-3435/de.appcuisine.tigermedia.tigerbooks.alpha I/System.out: EpubContainer Reading file at path: content.opf
06-18 05:48:08.290 3435-3435/de.appcuisine.tigermedia.tigerbooks.alpha I/System.out: OPFParser rootFile:= content.opf
06-18 05:48:08.290 3435-3435/de.appcuisine.tigermedia.tigerbooks.alpha I/System.out: EpubContainer Reading file at path: toc.ncx
06-18 05:48:08.294 3435-3435/de.appcuisine.tigermedia.tigerbooks.alpha W/System.err: org.xml.sax.SAXParseException: expected: '>' actual: '"' (position:DOCDECL ncxPUBLIC @1:59 in java.io.StringReader@9e52fce)
06-18 05:48:08.294 3435-3435/de.appcuisine.tigermedia.tigerbooks.alpha W/System.err: at org.apache.harmony.xml.parsers.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:146)
06-18 05:48:08.294 3435-3435/de.appcuisine.tigermedia.tigerbooks.alpha W/System.err: at org.readium.r2_streamer.parser.EpubParser.xmlParser(EpubParser.java:129)
06-18 05:48:08.297 3435-3435/de.appcuisine.tigermedia.tigerbooks.alpha W/System.err: at org.readium.r2_streamer.parser.NCXParser.parseNCXFile(NCXParser.java:37)
06-18 05:48:08.298 3435-3435/de.appcuisine.tigermedia.tigerbooks.alpha W/System.err: at org.readium.r2_streamer.parser.OPFParser.parseSpineAndResourcesAndGuide(OPFParser.java:375)
06-18 05:48:08.298 3435-3435/de.appcuisine.tigermedia.tigerbooks.alpha W/System.err: at org.readium.r2_streamer.parser.OPFParser.parseOpfFile(OPFParser.java:186)
06-18 05:48:08.298 3435-3435/de.appcuisine.tigermedia.tigerbooks.alpha W/System.err: at org.readium.r2_streamer.parser.EpubParser.parseEpubFile(EpubParser.java:46)
06-18 05:48:08.298 3435-3435/de.appcuisine.tigermedia.tigerbooks.alpha W/System.err: at org.readium.r2_streamer.server.EpubServer.parse(EpubServer.java:90)
06-18 05:48:08.299 3435-3435/de.appcuisine.tigermedia.tigerbooks.alpha W/System.err: at org.readium.r2_streamer.server.EpubServer.addEpub(EpubServer.java:40)
06-18 05:48:08.299 3435-3435/de.appcuisine.tigermedia.tigerbooks.alpha W/System.err: at com.folioreader.ui.folio.activity.FolioActivity.addEpub(FolioActivity.java:175)
06-18 05:48:08.300 3435-3435/de.appcuisine.tigermedia.tigerbooks.alpha W/System.err: at com.folioreader.ui.folio.activity.FolioActivity.initBook(FolioActivity.java:163)
06-18 05:48:08.301 3435-3435/de.appcuisine.tigermedia.tigerbooks.alpha W/System.err: at com.folioreader.ui.folio.activity.FolioActivity.setupBook(FolioActivity.java:399)
06-18 05:48:08.301 3435-3435/de.appcuisine.tigermedia.tigerbooks.alpha W/System.err: at com.folioreader.ui.folio.activity.FolioActivity.onCreate(FolioActivity.java:134)
06-18 05:48:08.301 3435-3435/de.appcuisine.tigermedia.tigerbooks.alpha W/System.err: at android.app.Activity.performCreate(Activity.java:6664)
06-18 05:48:08.301 3435-3435/de.appcuisine.tigermedia.tigerbooks.alpha W/System.err: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
06-18 05:48:08.301 3435-3435/de.appcuisine.tigermedia.tigerbooks.alpha W/System.err: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)
06-18 05:48:08.301 3435-3435/de.appcuisine.tigermedia.tigerbooks.alpha W/System.err: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
06-18 05:48:08.301 3435-3435/de.appcuisine.tigermedia.tigerbooks.alpha W/System.err: at android.app.ActivityThread.-wrap12(ActivityThread.java)
06-18 05:48:08.302 3435-3435/de.appcuisine.tigermedia.tigerbooks.alpha W/System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
06-18 05:48:08.302 3435-3435/de.appcuisine.tigermedia.tigerbooks.alpha W/System.err: at android.os.Handler.dispatchMessage(Handler.java:102)
06-18 05:48:08.303 3435-3435/de.appcuisine.tigermedia.tigerbooks.alpha W/System.err: at android.os.Looper.loop(Looper.java:154)
06-18 05:48:08.303 3435-3435/de.appcuisine.tigermedia.tigerbooks.alpha W/System.err: at android.app.ActivityThread.main(ActivityThread.java:6077)
06-18 05:48:08.303 3435-3435/de.appcuisine.tigermedia.tigerbooks.alpha W/System.err: at java.lang.reflect.Method.invoke(Native Method)
06-18 05:48:08.303 3435-3435/de.appcuisine.tigermedia.tigerbooks.alpha W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
06-18 05:48:08.303 3435-3435/de.appcuisine.tigermedia.tigerbooks.alpha W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
06-18 05:48:08.303 3435-3435/de.appcuisine.tigermedia.tigerbooks.alpha I/System.out: EpubParser parserEpubFile() error org.readium.r2_streamer.parser.EpubParserException: Error while parsing
06-18 05:48:08.305 3435-3435/de.appcuisine.tigermedia.tigerbooks.alpha D/AndroidRuntime: Shutting down VM
06-18 05:48:08.315 3435-3435/de.appcuisine.tigermedia.tigerbooks.alpha E/AndroidRuntime: FATAL EXCEPTION: main
Process: de.appcuisine.tigermedia.tigerbooks.alpha, PID: 3435
java.lang.Error: FATAL EXCEPTION [main]
Unity version : 2017.2.0f3
Device model : Genymotion Google Nexus 9 - 7.0.0 - API 24 - 1536x2048
Device fingerprint: Android/vbox86p/vbox86p:7.0/NRD90M/genymo09131924:userdebug/test-keys

Caused by: java.lang.RuntimeException: Unable to start activity ComponentInfo{de.appcuisine.tigermedia.tigerbooks.alpha/com.folioreader.ui.folio.activity.FolioActivity}: java.lang.NullPointerException: Attempt to read from field 'java.util.List org.readium.r2_streamer.model.publication.EpubPublication.links' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Caused by: java.lang.NullPointerException: Attempt to read from field 'java.util.List org.readium.r2_streamer.model.publication.EpubPublication.links' on a null object reference
at org.readium.r2_streamer.server.EpubServer.addLinks(EpubServer.java:68)
at org.readium.r2_streamer.server.EpubServer.addEpub(EpubServer.java:42)
at com.folioreader.ui.folio.activity.FolioActivity.addEpub(FolioActivity.java:175)
at com.folioreader.ui.folio.activity.FolioActivity.initBook(FolioActivity.java:163)
at com.folioreader.ui.folio.activity.FolioActivity.setupBook(FolioActivity.java:399)
at com.folioreader.ui.folio.activity.FolioActivity.onCreate(FolioActivity.java:134)
at android.app.Activity.performCreate(Activity.java:6664)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707) 
at android.app.ActivityThread.-wrap12(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:154) 
at android.app.ActivityThread.main(ActivityThread.java:6077) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755) 

06-18 05:48:08.326 646-1398/system_process W/ActivityManager: Force finishing activity de.appcuisine.tigermedia.tigerbooks.alpha/com.folioreader.ui.folio.activity.FolioActivity
06-18 05:48:08.345 646-1398/system_process W/ActivityManager: Force finishing activity de.appcuisine.tigermedia.tigerbooks.alpha/de.appcuisine.tigermedia.tigerbooks.ui.splash.SplashActivity
`

@prilaga
Copy link

prilaga commented Jun 22, 2018

@hrishikesh-kadam @mahavir155
Thank you for your help!

I'm trying to get the book from my customer.

Here is the xml part which has a problem:
https://www.dropbox.com/s/3jf26fz1a1socf0/Reader.java?dl=0

@hrishikesh-kadam
Copy link
Contributor Author

String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
                "<!DOCTYPE ncx PUBLIC \"-//NISO//DTD ncx 2005-1//EN\" \"http://www.daisy.org/z3986/2005/ncx-2005-1.dtd\">" +
                "<ncx xmlns=\"http://www.daisy.org/z3986/2005/ncx/\" version=\"2005-1\"> <head>  <meta name=\"dtb:uid\" content=\"978-3-646-92170-0\"/>  <meta name=\"dtb:depth\" content=\"1\"/>  <meta name=\"dtb:totalPageCount\" content=\"0\"/>  <meta name=\"dtb:maxPageNumber\" content=\"0\"/> </head> <docTitle>  <text>Salz im Haar</text> </docTitle> <navMap>  <navPoint playOrder=\"1\" id=\"chapter_1\">   <navLabel>    <text>Cover</text>   </navLabel>   <content src=\"content-1.xhtml\"/>  </navPoint>  <navPoint playOrder=\"2\" id=\"chapter_2\">   <navLabel>    <text>Impressum</text>   </navLabel>   <content src=\"content-2.xhtml\"/>  </navPoint>  <navPoint playOrder=\"3\" id=\"chapter_3\">   <navLabel>    <text>EINE WICHTIGE WARNUNG</text>   </navLabel>   <content src=\"content-3.xhtml\"/>  </navPoint>  <navPoint playOrder=\"4\" id=\"chapter_4\">   <navLabel>    <text>ERSTER TEIL</text>   </navLabel>   <content src=\"content-4.xhtml\"/>   <navPoint playOrder=\"5\" id=\"chapter_5\">    <navLabel>     <text>Kapitel 1</text>    </navLabel>    <content src=\"content-5.xhtml\"/>   </navPoint>   <navPoint playOrder=\"6\" id=\"chapter_6\">    <navLabel>     <text>Kapitel 2</text>    </navLabel>    <content src=\"content-6.xhtml\"/>   </navPoint>   <navPoint playOrder=\"7\" id=\"chapter_7\">    <navLabel>     <text>Kapitel 3</text>    </navLabel>    <content src=\"content-7.xhtml\"/>   </navPoint>   <navPoint playOrder=\"8\" id=\"chapter_8\">    <navLabel>     <text>Kapitel 4</text>    </navLabel>    <content src=\"content-8.xhtml\"/>   </navPoint>   <navPoint playOrder=\"9\" id=\"chapter_9\">    <navLabel>     <text>Kapitel 5</text>    </navLabel>    <content src=\"content-9.xhtml\"/>   </navPoint>   <navPoint playOrder=\"10\" id=\"chapter_10\">    <navLabel>     <text>Kapitel 6</text>    </navLabel>    <content src=\"content-10.xhtml\"/>   </navPoint>   <navPoint playOrder=\"11\" id=\"chapter_11\">    <navLabel>     <text>Kapitel 7</text>    </navLabel>    <content src=\"content-11.xhtml\"/>   </navPoint>   <navPoint playOrder=\"12\" id=\"chapter_12\">    <navLabel>     <text>Kapitel 8</text>    </navLabel>    <content src=\"content-12.xhtml\"/>   </navPoint>   <navPoint playOrder=\"13\" id=\"chapter_13\">    <navLabel>     <text>Kapitel 9</text>    </navLabel>    <content src=\"content-13.xhtml\"/>   </navPoint>   <navPoint playOrder=\"14\" id=\"chapter_14\">    <navLabel>     <text>Kapitel 10</text>    </navLabel>    <content src=\"content-14.xhtml\"/>   </navPoint>   <navPoint playOrder=\"15\" id=\"chapter_15\">    <navLabel>     <text>Kapitel 11</text>    </navLabel>    <content src=\"content-15.xhtml\"/>   </navPoint>   <navPoint playOrder=\"16\" id=\"chapter_16\">    <navLabel>     <text>Kapitel 12</text>    </navLabel>    <content src=\"content-16.xhtml\"/>   </navPoint>  </navPoint>  <navPoint playOrder=\"17\" id=\"chapter_17\">   <navLabel>    <text>ZWEITER TEIL</text>   </navLabel>   <content src=\"content-17.xhtml\"/>   <navPoint playOrder=\"18\" id=\"chapter_18\">    <navLabel>     <text>Kapitel 13</text>    </navLabel>    <content src=\"content-18.xhtml\"/>   </navPoint>   <navPoint playOrder=\"19\" id=\"chapter_19\">    <navLabel>     <text>Kapitel 14</text>    </navLabel>    <content src=\"content-19.xhtml\"/>   </navPoint>   <navPoint playOrder=\"20\" id=\"chapter_20\">    <navLabel>     <text>Kapitel 15</text>    </navLabel>    <content src=\"content-20.xhtml\"/>   </navPoint>   <navPoint playOrder=\"21\" id=\"chapter_21\">    <navLabel>     <text>Kapitel 16</text>    </navLabel>    <content src=\"content-21.xhtml\"/>   </navPoint>   <navPoint playOrder=\"22\" id=\"chapter_22\">    <navLabel>     <text>Kapitel 17</text>    </navLabel>    <content src=\"content-22.xhtml\"/>   </navPoint>   <navPoint playOrder=\"23\" id=\"chapter_23\">    <navLabel>     <text>Kapitel 18</text>    </navLabel>    <content src=\"content-23.xhtml\"/>   </navPoint>   <navPoint playOrder=\"24\" id=\"chapter_24\">    <navLabel>     <text>Kapitel 19</text>    </navLabel>    <content src=\"content-24.xhtml\"/>   </navPoint>   <navPoint playOrder=\"25\" id=\"chapter_25\">    <navLabel>     <text>Kapitel 20</text>    </navLabel>    <content src=\"content-25.xhtml\"/>   </navPoint>   <navPoint playOrder=\"26\" id=\"chapter_26\">    <navLabel>     <text>Kapitel 21</text>    </navLabel>    <content src=\"content-26.xhtml\"/>   </navPoint>   <navPoint playOrder=\"27\" id=\"chapter_27\">    <navLabel>     <text>Kapitel 22</text>    </navLabel>    <content src=\"content-27.xhtml\"/>   </navPoint>  </navPoint>  <navPoint playOrder=\"28\" id=\"chapter_28\">   <navLabel>    <text>Avi</text>   </navLabel>   <content src=\"content-28.xhtml\"/>  </navPoint> </navMap></ncx>";

@OlegTarashkevich the xml contents are invalid, space is missing between ncx and PUBLIC keywords.
So that means epub file is invalid.

After Horizontal scroll release we will look into how to handle all the invalid epubs gracefully.

@prilaga
Copy link

prilaga commented Jun 22, 2018

Thank you for the response!
FYI I'm able to open this book on another apps from google play.

@hrishikesh-kadam
Copy link
Contributor Author

The proposed solution for this would be to use smarter libraries for xml parsing than inbuilt javax.xml.parsers.DocumentBuilder.

At the moment we are busy in Horizontal scroll feature. Till the time you can fix this error in the particular invalid book. This file would be toc.ncx and generally resides in OEBPS folder.

@prilaga
Copy link

prilaga commented Jun 25, 2018

Here is a link to the file toc.ncx: https://www.dropbox.com/s/pu7kj33jpj6rt77/toc.ncx?dl=0
I see that we have "\n" symbol between ncx and PUBLIC, but after parsing we have no any symbols between them.

mahavir155 pushed a commit to codetoart/r2-streamer-java-1 that referenced this issue Jun 25, 2018
hrishikesh-kadam added a commit to codetoart/FolioReader-Android that referenced this issue Jun 25, 2018
mahavir155 pushed a commit to codetoart/FolioReader-Android that referenced this issue Jun 25, 2018
@hrishikesh-kadam
Copy link
Contributor Author

@OlegTarashkevich Please upgrade FolioReader to v0.3.11

@prilaga
Copy link

prilaga commented Jun 25, 2018

@hrishikesh-kadam @mahavir155 Thank you, it works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants