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.

NullPointerException - Cannot evaluate WhatsappWebSocket.toString()

See original GitHub issue

This is the code

    public static void main(String[] args) {
        var api = new WhatsappAPI();
        api.registerListener(new MyListener(api));
        api.connect();
    }
public class MyListener implements WhatsappListener {
    private final WhatsappAPI api;
    public MyListener(WhatsappAPI api){
        this.api = api;
    }

    public void onLoggedIn(@NonNull UserInformationResponse info) {
        System.out.println("Connected :)");
    }

    public void onChats(){
        System.out.printf("Recived chats: %s%n", api.manager().chats());
    }
}

And this is the error message:

issue

Any ideas what I’m doing wrong?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:16 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
SheikhZayedcommented, Nov 12, 2021

looks good: now I see a large QR code all over the screen. Offtopic: Is it possible for the code to be displayed a little smaller?

use this code to print the qr to ur path

BufferedImage image = MatrixToImageWriter.toBufferedImage(qr); File outputfile = new File("image.jpg"); ImageIO.write(image, "jpg", outputfile);

1reaction
Auties00commented, Nov 10, 2021

OK thanks. Is that also the explanation why I am not getting a connection?

I think I have the same error, it just never connects, it doesn’t work @Auties00

I try to connect but I never receive a qr code, the code is similar to the example and no errors are displayed.

I had that. This is my listener (from your documentation):

public class MyListener implements WhatsappListener {
    private final WhatsappAPI api;
    public MyListener(WhatsappAPI api){
        this.api = api;
    }

    public void onLoggedIn(@NonNull UserInformationResponse info) {
        System.out.println("Connected :)");
    }

    public void onChats(){
        System.out.printf("Recived chats: %s%n", api.manager().chats());
    }
}

Should be fixed in 2.2.2. Can you please double check?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Java code evaluation (IntelliJ IDE), use toString() in some point?
It turns out Intellij is trying to show an object with a null field, the toString of that object threw a null pointer...
Read more >
Method threw 'java.lang.NullPointerException ... - CodeRanch
NullPointerException ' exception. Cannot evaluate java.time.LocalDateTime.toS ... toString() within the implementation of print()
Read more >
Cannot evaluate com.couchbase.lite.Select.toString()
Method threw 'java.lang.NullPointerException' exception. Cannot evaluate com.couchbase.lite.Select.toString().
Read more >
java.lang.NullPointerException.toString java code examples
How to use. toString. method. in. java.lang.NullPointerException ... @Override public void close() throws IOException { if (this.output != null) { try { if ......
Read more >
OIDC - NullPointerException · Issue #26236 · quarkusio/quarkus
Method threw 'java.lang.RuntimeException' exception. Cannot evaluate io.quarkus.oidc.runtime.DefaultTenantConfigResolver_ClientProxy.toString() ...
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