question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

java.lang.NullPointerException: in == null

See original GitHub issue

Using Jsoup 1.8.3 in my Android app which is now targetting SDK 23 (Marshmallow) and am seeing frequent crashes when trying to get the Document as follows:

Jsoup.connect(link).get()

The stack is as follows:

09-03 17:38:39.873 13223-13291/org.MAW.tweetcomb E/AndroidRuntime﹕ FATAL EXCEPTION: AsyncTask #2 Process: org.MAW.tweetcomb, PID: 13223 java.lang.RuntimeException: An error occurred while executing doInBackground() at android.os.AsyncTask$3.done(AsyncTask.java:309) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354) at java.util.concurrent.FutureTask.setException(FutureTask.java:223) at java.util.concurrent.FutureTask.run(FutureTask.java:242) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) at java.lang.Thread.run(Thread.java:818) Caused by: java.lang.ExceptionInInitializerError at org.jsoup.nodes.Entities.access$000(Entities.java:16) at org.jsoup.nodes.Entities$EscapeMode.<clinit>(Entities.java:19) at org.jsoup.nodes.Document$OutputSettings.<init>(Document.java:373) at org.jsoup.nodes.Document.<init>(Document.java:18) at org.jsoup.parser.TreeBuilder.initialiseParse(TreeBuilder.java:29) at org.jsoup.parser.TreeBuilder.parse(TreeBuilder.java:42) at org.jsoup.parser.HtmlTreeBuilder.parse(HtmlTreeBuilder.java:53) at org.jsoup.parser.Parser.parseInput(Parser.java:30) at org.jsoup.helper.DataUtil.parseByteData(DataUtil.java:132) at org.jsoup.helper.HttpConnection$Response.parse(HttpConnection.java:603) at org.jsoup.helper.HttpConnection.get(HttpConnection.java:195) at org.MAW.tweetcomb.AsyncTasks.JSoupFetcher.doInBackground(JSoupFetcher.java:47) at org.MAW.tweetcomb.AsyncTasks.JSoupFetcher.doInBackground(JSoupFetcher.java:21) at android.os.AsyncTask$2.call(AsyncTask.java:295) at java.util.concurrent.FutureTask.run(FutureTask.java:237)             at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)             at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)             at java.lang.Thread.run(Thread.java:818) Caused by: java.lang.NullPointerException: in == null at java.util.Properties.load(Properties.java:246) at org.jsoup.nodes.Entities.loadEntities(Entities.java:236) at org.jsoup.nodes.Entities.<clinit>(Entities.java:220)             at org.jsoup.nodes.Entities.access$000(Entities.java:16)             at org.jsoup.nodes.Entities$EscapeMode.<clinit>(Entities.java:19)             at org.jsoup.nodes.Document$OutputSettings.<init>(Document.java:373)             at org.jsoup.nodes.Document.<init>(Document.java:18)             at org.jsoup.parser.TreeBuilder.initialiseParse(TreeBuilder.java:29)             at org.jsoup.parser.TreeBuilder.parse(TreeBuilder.java:42)             at org.jsoup.parser.HtmlTreeBuilder.parse(HtmlTreeBuilder.java:53)             at org.jsoup.parser.Parser.parseInput(Parser.java:30)             at org.jsoup.helper.DataUtil.parseByteData(DataUtil.java:132)             at org.jsoup.helper.HttpConnection$Response.parse(HttpConnection.java:603)             at org.jsoup.helper.HttpConnection.get(HttpConnection.java:195)             at org.MAW.tweetcomb.AsyncTasks.JSoupFetcher.doInBackground(JSoupFetcher.java:47)             at org.MAW.tweetcomb.AsyncTasks.JSoupFetcher.doInBackground(JSoupFetcher.java:21)             at android.os.AsyncTask$2.call(AsyncTask.java:295)             at java.util.concurrent.FutureTask.run(FutureTask.java:237)             at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)             at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)             at java.lang.Thread.run(Thread.java:818)

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
MattWilliams89commented, Sep 5, 2015

So I fixed this locally by putting the Jsoup source locally in my project and moving the two .properties files to my “resources” folder and changing line 235 of Entities to InputStream in = Entities.class.getClassLoader().getResourceAsStream(filename); instead of InputStream in = Entities.class.getResourceAsStream(filename);

0reactions
jhycommented, Dec 24, 2018

Since 1.11.1 with this change #959, entities are loaded from data embedded in a class, not a property file, so we shouldn’t get hit by this Android bug any more.

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - What is a NullPointerException, and how do I fix it?
The NullPointerException (NPE) typically occurs when you declare a variable but did not create an object and assign it to the variable before...
Read more >
How to Fix and Avoid NullPointerException in Java - Rollbar
The NullPointerException occurs due to a situation in application code where an uninitialized object is attempted to be accessed or modified.
Read more >
Java NullPointerException - Detect, Fix, and Best Practices
This is one of the most common occurrences of java.lang.NullPointerException because it's the caller who is passing the null argument. The below ...
Read more >
How to resolve the java.lang.NullPointerException - Educative.io
In Java, the java.lang.NullPointerException is thrown when a reference variable is accessed (or de-referenced) and is not pointing to any object.
Read more >
NullPointerException (Java Platform SE 7 ) - Oracle Help Center
Thrown when an application attempts to use null in a case where an object is required. These include: ... Applications should throw instances...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found