Re: [jgroups-dev] What does cause NullPointerException?
Development issues <[email protected]> Fri, 25 Dec 2015 14:20:05 +0100
| Newsgroups | gmane.comp.java.javagroups.devel,gmane.spam.detected |
|---|---|
| Message-ID | <[email protected]> |
You didn't send the whole code, so I wasn't able to investigate. I suggest debug this yourself by setting a breakpoint in your code... this is probably the fastest way to find the cause On 25/12/15 13:03, Development issues wrote: > The exception occurs in your code (Zab2PhasesTest.resetProtocol), so > without that code I don't know what's going on. If you post a unit test > and package up the code I could take a look. Or you set a breakpoint in > Zab2PhasesTest.resetProtocol() and see what's null that triggers the NPE. > > Yes, The exception occurs in your code (Zab2PhasesTest.resetProtocol) in > line channel.send(msg). > In fact, I do not use Junit test, when I am coding and testing the > code, I just compile and run it in Linux machines using command line. > The attachment shows the codes. They are two files, one called > Zab2PhasesTest and second called Zab2PhasesClient. Zab2PhasesClient uses > by Zab2PhasesTest to initial senders to send requests to servers. > > Note that NPE occurs in Zab2PhasesTest.resetProtocol in line > channel.send(msg, line 192. > > Thank you indeed > > Ibrahim > > > > On Friday, December 25, 2015 7:58 AM, JGroups - Dev mailing list [via > JGroups] <[hidden email] </user/SendEmail.jtp?type=node&node=10927&i=0>> > wrote: > > > The exception occurs in your code (Zab2PhasesTest.resetProtocol), so > without that code I don't know what's going on. If you post a unit test > and package up the code I could take a look. Or you set a breakpoint in > Zab2PhasesTest.resetProtocol() and see what's null that triggers the NPE. > > On 24/12/15 22:34, Development issues wrote: > > > <<An NPE can only occur if channel is null at this point... > > <<JChannel.getAddress() can of course return null if the channel hasn't > > <<been connected yet, but you'd only get an NPE if you try to reference > > <<local_address > > The channel is connected and I use it without any problem before the > > line where the exception occur. Meaning that with the same code I manage > > to use channel to send requests to the servers, but where the execution > > come to line channel.send(msg), the exception occurs. This is why I am > > surprised when I use channel first time it worked but when I use it > > again I have NullPointerException. > > <<OK. Can you also subscribe properly? So far, I've had to approve > all of > > <<your posts individually... > > I thought I am already subscribe by using and logging in to this site > > http://jgroups.1086181.n5.nabble.com/. > > No worry, I have found another site and just subscribe today which is > > https://sourceforge.net/p/javagroups/mailman/javagroups-development/. I > > hope now I am subscribed correctly. > > The following is stack trace as requested: > > java.lang.NullPointerException > > at > > > org.jgroups.protocols.jz.Zab2PhasesTest.resetProtocol(Zab2PhasesTest.java:192) > > > at > > > org.jgroups.protocols.jz.Zab2PhasesTest.finishedSend(Zab2PhasesTest.java:318) > > > at > > > org.jgroups.protocols.jz.Zab2PhasesClient.receive(Zab2PhasesClient.java:143) > > > at org.jgroups.JChannel.invokeCallback(JChannel.java:812) > > at org.jgroups.JChannel.up(JChannel.java:736) > > at org.jgroups.stack.ProtocolStack.up(ProtocolStack.java:1029) > > at > org.jgroups.protocols.pbcast.STATE_TRANSFER.up(STATE_TRANSFER.java:146) > > at org.jgroups.protocols.FRAG2.up(FRAG2.java:165) > > at > > > org.jgroups.protocols.jz.Zab2Phases.handleOrderingResponse(Zab2Phases.java:588) > > > at org.jgroups.protocols.jz.Zab2Phases.up(Zab2Phases.java:256) > > at org.jgroups.protocols.jz.Zab2Phases.up(Zab2Phases.java:277) > > at org.jgroups.protocols.RSVP.up(RSVP.java:237) > > at org.jgroups.stack.Protocol.up(Protocol.java:420) > > at org.jgroups.protocols.pbcast.STABLE.up(STABLE.java:294) > > at org.jgroups.protocols.UNICAST3.deliverBatch(UNICAST3.java:1087) > > at org.jgroups.protocols.UNICAST3.removeAndDeliver(UNICAST3.java:886) > > at org.jgroups.protocols.UNICAST3.handleDataReceived(UNICAST3.java:790) > > at org.jgroups.protocols.UNICAST3.up(UNICAST3.java:426) > > at org.jgroups.protocols.pbcast.NAKACK2.up(NAKACK2.java:619) > > at org.jgroups.protocols.BARRIER.up(BARRIER.java:152) > > at org.jgroups.protocols.VERIFY_SUSPECT.up(VERIFY_SUSPECT.java:155) > > at org.jgroups.protocols.FD_ALL.up(FD_ALL.java:200) > > at org.jgroups.protocols.FD_SOCK.up(FD_SOCK.java:297) > > at org.jgroups.protocols.MERGE2.up(MERGE2.java:237) > > at org.jgroups.protocols.Discovery.up(Discovery.java:277) > > at org.jgroups.protocols.TP.passMessageUp(TP.java:1572) > > at org.jgroups.protocols.TP$MyHandler.run(TP.java:1791) > > at > > > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) > > > at > > > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) > -- Bela Ban, JGroups lead (http://www.jgroups.org) ------------------------------------------------------------------------------ _______________________________________________ Javagroups-development mailing list