Re: [jgroups-dev] What does cause NullPointerException?
Development issues <[email protected]> Fri, 25 Dec 2015 08:57:30 +0100
| Newsgroups | gmane.comp.java.javagroups.devel,gmane.spam.detected |
|---|---|
| Message-ID | <[email protected]> |
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)
> at java.lang.Thread.run(Thread.java:745)
> Cheers,
> Ibrahim
> Ibrahim EL-Sanosi PHD student [hidden email]
> </user/SendEmail.jtp?type=node&node=10925&i=0>
>
>
> On Thursday, December 24, 2015 7:21 AM, JGroups - Dev mailing list [via
> JGroups] <[hidden email] </user/SendEmail.jtp?type=node&node=10925&i=1>>
> wrote:
>
>
>
>
> On 23/12/15 19:30, Development issues wrote:
> > >>I bet this occurs when trying to marshall Zab2PhasesHeader. Did
> you add
> > >>a magic-ID for your header, e.g.
> > >>ClassConfigurator.add(7200, Zab2PhasesHeader.class); ?
> > >>Also, you need to add your protocols as well, e.g.
> > >>ClassConfigurator.addProtocol(513, jzookeeper.Zab2Phases.class);
> >
> > Yes, I added all protocol headers in jg-magic-map.xml, and added all
> > protocols in jg-protocol-ids.xml files.
>
>
> OK, so this isn't the problem then...
>
>
> > I think the problem is in channel object, why I think that because I
> > tried to add line channel.getAddress() before channel.send(msg) the
> > excption points to channel.getAddress(), see below.
> >
> > ZABHeader resetProtocol = new ZABHeader(ZABHeader.RESET);
> > Message msg = new Message(null).putHeader(ID, resetProtocol);
> > Address local_addr = channel.getAddress();// The exception occurs here.
>
>
> 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
>
>
> > channel.send(msg);
> >
> > I will send stack trace tomorrow. Sorry for that.
>
> OK. Can you also subscribe properly? So far, I've had to approve all of
> your posts individually...
> Cheers,
>
> > Ibrahim
> >
> >
> > On Wednesday, December 23, 2015 5:45 PM, JGroups - Dev mailing list [via
> > JGroups] <[hidden email] </user/SendEmail.jtp?type=node&node=10922&i=0>>
> > wrote:
> >
> >
> >
> >
> > On 23/12/15 18:16, Development issues wrote:
> >
> > > Thank you for replaying.
> > >
> > > Yes, I never reuse a message. The following is a part of my code
> where
> > > the exception occurs:
> > > Client code:
> > > ---
> > > ---
> > > --
> > > Zab2PhasesHeader resetProtocol = new
> Zab2PhasesHeader(Zab2PhasesHeader
> > > .RESET);
> > > Message msg = new Message(null).putHeader(ID, resetProtocol);
> > > channel.send(msg); // The exception point to this line.
> > You still haven't shown the stack trace.
> > I bet this occurs when trying to marshall Zab2PhasesHeader. Did you add
> > a magic-ID for your header, e.g.
> > ClassConfigurator.add(7200, Zab2PhasesHeader.class); ?
> >
> > Also, you need to add your protocols as well, e.g.
> > ClassConfigurator.addProtocol(513, jzookeeper.Zab2Phases.class);
> >
> >
> >
> > > Note that I have 3 protocols (ZabMain, Zab2Phases and ZabProb), each
> > > with its own header and stack. The same client code (above code) is
> > > used (with different in protocol header) to benchmark all three
> > > protocols. The client code ran without any problems when I benchmark
> > > the protocols ZabMain and ZabProb. The problem only occurs when I
> > > benchmark the Zab2Phases protocol.
> > >
> > > The following is Zab2Phases stack as requested:
> > >
> > > <config xmlns="urn:org:jgroups"
> > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> > > xsi:schemaLocation="urn:org:jgroups
> > > http://www.jgroups.org/schema/JGroups-3.3.xsd">
> > > <UDP
> > > mcast_port="${jgroups.udp.mcast_port:45588}"
> > > tos="8"
> > > max_bundle_size="64K"
> > > max_bundle_timeout="30"
> > > enable_diagnostics="true"
> > > thread_naming_pattern="cl"
> > > ip_mcast="false"
> > > timer_type="new3"
> > > timer.min_threads="10"
> > > timer.max_threads="10"
> > > timer.keep_alive_time="3000"
> > > timer.queue_max_size="500"
> > > timer.rejection_policy="abort"
> > > thread_pool.enabled="true"
> > > thread_pool.min_threads="2"
> > > thread_pool.max_threads="8"
> > > thread_pool.keep_alive_time="5000"
> > > thread_pool.queue_enabled="true"
> > > thread_pool.queue_max_size="10000"
> > > thread_pool.rejection_policy="discard"
> > > oob_thread_pool.enabled="true"
> > > oob_thread_pool.min_threads="1"
> > > oob_thread_pool.max_threads="8"
> > > oob_thread_pool.keep_alive_time="5000"
> > > oob_thread_pool.queue_enabled="false"
> > > oob_thread_pool.queue_max_size="100"
> > > oob_thread_pool.rejection_policy="discard"/>
> > >
> > > <FILE_PING
> > > timeout="2000"
> > > num_initial_members="20"
> > > location="/home/pg/p13/a6915654/"/>
> > > <MERGE2 max_interval="30000"
> > > min_interval="10000"/>
> > > <FD_SOCK/>
> > > <FD_ALL/>
> > > <VERIFY_SUSPECT timeout="1500" />
> > > <BARRIER/>
> > > <pbcast.NAKACK2 xmit_interval="1000"
> > > xmit_table_num_rows="100"
> > > xmit_table_msgs_per_row="2000"
> > > xmit_table_max_compaction_time="30000"
> > > max_msg_batch_size="500"
> > > use_mcast_xmit="false"
> > > discard_delivered_msgs="true"/>
> > > <UNICAST3 xmit_interval="500"
> > > xmit_table_num_rows="100"
> > > xmit_table_msgs_per_row="2000"
> > > xmit_table_max_compaction_time="60000"
> > > conn_expiry_timeout="0"
> > > max_msg_batch_size="500"/>
> > > <pbcast.STABLE stability_delay="1000" desired_avg_gossip="50000"
> > > max_bytes="4M"/>
> > > <pbcast.GMS print_local_addr="true" join_timeout="3000"
> > > view_bundling="true"/>
> > > <UFC/>
> > > <MFC/>
> > > <RSVP resend_interval="2000" timeout="10000"/>
> > > <jzookeeper.Zab2Phases />
> > > <FRAG2 frag_size="60K" />
> > > <pbcast.STATE_TRANSFER />
> > > </config>
> > >
> > >
> > > Thank you indeed.
> > >
> > > Ibrahim
> > >
> > > The stack trace is as following?
> > > Ibrahim EL-Sanosi PHD student [hidden email]
> > > </user/SendEmail.jtp?type=node&node=10920&i=0>
> > >
> > >
> > > On Wednesday, December 23, 2015 7:22 AM, JGroups - Dev mailing
> list [via
> > > JGroups] <[hidden email]
> </user/SendEmail.jtp?type=node&node=10920&i=1>>
> > > wrote:
> > >
> > >
> > > What's the stack trace?
> > >
> > > I hope you're not reusing the message, as in:
> > >
> > > Message msg=new Message(null, "hello world');
> > > for(int i=0; i < 5; i++)
> > > ch.send(msg);
> > >
> > > This is incorrect as the send modifies the message. The correct code
> > > would be:
> > >
> > >
> > > for(int i=0; i < 5; i++) {
> > > Message msg=new Message(null, "hello world');
> > > ch.send(msg);
> > > }
> > >
> > > On 22/12/15 22:39, Development issues wrote:
> > >
> > > > I have a cluster consist of 5 machines, 3 allocated for
> services and
> > > 2 for
> > > > clients. I start the cluster and build a channel without any
> problem.
> > > Also
> > > > clients manage to send a request to the servers using
> > channel.send(msg).
> > > >
> > > > However, when I use channel.send(msg) again (in client side), it
> > > gives me
> > > > NullPointerException. Moreover, NullPointerException point to line
> > where
> > > > channel.send(msg) is.
> > > >
> > > > Can anyone tell what does cause such problem?
> > > >
> > > > Thank you
> > > >
> > > > Ibrahim
> > >
> > > --
> > > Bela Ban, JGroups lead (http://www.jgroups.org
> <http://www.jgroups.org/>
> > <http://www.jgroups.org/> <http://www.jgroups.org/>)
> > >
> > >
> > >
> >
> ------------------------------------------------------------------------------
>
> >
> > >
> > > _______________________________________________
> > > Javagroups-development mailing list
> > >
> > >
> > >
> > >
> ------------------------------------------------------------------------
> > > If you reply to this email, your message will be added to the
> discussion
> > > below:
> > >
> >
> http://jgroups.1086181.n5.nabble.com/What-does-cause-NullPointerException-tp10915p10918.html
> > >
> > > To unsubscribe from What does cause NullPointerException?, click
> here.
> > > NAML
> > >
> >
> <http://jgroups.1086181.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>
> >
> > >
> > >
> > >
> > >
> > >
> ------------------------------------------------------------------------
> > > View this message in context: Re: What does cause
> NullPointerException?
> > >
> >
> <http://jgroups.1086181.n5.nabble.com/What-does-cause-NullPointerException-tp10915p10920.html>
>
> >
> > > Sent from the JGroups - Dev mailing list archive
> > > <http://jgroups.1086181.n5.nabble.com/JGroups-Dev-f6604.html> at
> > Nabble.com.
> > >
> > >
> > >
> >
> ------------------------------------------------------------------------------
>
> >
> > >
> > >
> > >
> > > _______________________________________________
> > > Javagroups-development mailing list
> > >
> > --
> > Bela Ban, JGroups lead (http://www.jgroups.org
> <http://www.jgroups.org/> <http://www.jgroups.org/>)
> >
> >
> >
> ------------------------------------------------------------------------------
>
> >
> > _______________________________________________
> > Javagroups-development mailing list
> >
> >
> >
> > ------------------------------------------------------------------------
> > If you reply to this email, your message will be added to the discussion
> > below:
> >
> http://jgroups.1086181.n5.nabble.com/What-does-cause-NullPointerException-tp10915p10921.html
> >
> > To unsubscribe from What does cause NullPointerException?, click here.
> > NAML
> >
> <http://jgroups.1086181.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>
> >
> >
> >
> >
> > ------------------------------------------------------------------------
> > View this message in context: Re: What does cause NullPointerException?
> >
> <http://jgroups.1086181.n5.nabble.com/What-does-cause-NullPointerException-tp10915p10922.html>
>
> > Sent from the JGroups - Dev mailing list archive
> > <http://jgroups.1086181.n5.nabble.com/JGroups-Dev-f6604.html> at
> Nabble.com.
> >
> >
> >
> ------------------------------------------------------------------------------
>
> >
> >
> >
> > _______________________________________________
> > Javagroups-development mailing list
> >
> --
> Bela Ban, JGroups lead (http://www.jgroups.org <http://www.jgroups.org/>)
>
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> Javagroups-development mailing list
>
>
>
> ------------------------------------------------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
> http://jgroups.1086181.n5.nabble.com/What-does-cause-NullPointerException-tp10915p10924.html
>
> To unsubscribe from What does cause NullPointerException?, click here.
> NAML
> <http://jgroups.1086181.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>
>
>
>
> ------------------------------------------------------------------------
> View this message in context: Re: What does cause NullPointerException?
> <http://jgroups.1086181.n5.nabble.com/What-does-cause-NullPointerException-tp10915p10925.html>
> Sent from the JGroups - Dev mailing list archive
> <http://jgroups.1086181.n5.nabble.com/JGroups-Dev-f6604.html> at Nabble.com.
>
>
> ------------------------------------------------------------------------------
>
>
>
> _______________________________________________
> Javagroups-development mailing list
>
--
Bela Ban, JGroups lead (http://www.jgroups.org)
------------------------------------------------------------------------------
_______________________________________________
Javagroups-development mailing list