Re: [jgroups-dev] What does cause NullPointerException?
Development issues <[email protected]> Thu, 24 Dec 2015 08:21:24 +0100
| Newsgroups | gmane.comp.java.javagroups.devel |
|---|---|
| Message-ID | <[email protected]> |
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/>)
> >
> >
> >
> ------------------------------------------------------------------------------
>
> >
> > _______________________________________________
> > 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/>)
>
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> 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)
------------------------------------------------------------------------------
_______________________________________________
Javagroups-development mailing list