Clustering Error: org.jivesoftware.openfire. handler.IQHandler - Internal server error

I’m running open fire on cluster but I get this error often. Sometimes my user is able to login and sometimes this error occurs:

(Please note that if I disable clustering this goes away)

2012.01.05 08:14:03 org.jivesoftware.openfire.handler.IQHandler - Internal server error
java.lang.NullPointerException
at org.jivesoftware.openfire.session.LocalClientSession.setDefaultList(LocalClient Session.java:530)
at org.jivesoftware.openfire.session.LocalClientSession.setAuthToken(LocalClientSe ssion.java:598)
at org.jivesoftware.openfire.handler.IQBindHandler.handleIQ(IQBindHandler.java:154 )
at org.jivesoftware.openfire.handler.IQHandler.process(IQHandler.java:65)
at org.jivesoftware.openfire.IQRouter.handle(IQRouter.java:372)
at org.jivesoftware.openfire.IQRouter.route(IQRouter.java:121)
at org.jivesoftware.openfire.spi.PacketRouterImpl.route(PacketRouterImpl.java:76)
at org.jivesoftware.openfire.net.StanzaHandler.processIQ(StanzaHandler.java:337)
at org.jivesoftware.openfire.net.ClientStanzaHandler.processIQ(ClientStanzaHandler .java:93)
at org.jivesoftware.openfire.net.StanzaHandler.process(StanzaHandler.java:302)
at org.jivesoftware.openfire.net.StanzaHandler.process(StanzaHandler.java:194)
at org.jivesoftware.openfire.nio.ConnectionHandler.messageReceived(ConnectionHandl er.java:169)
at org.apache.mina.common.support.AbstractIoFilterChain$TailFilter.messageReceived (AbstractIoFilterChain.java:570)
at org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(Ab stractIoFilterChain.java:299)
at org.apache.mina.common.support.AbstractIoFilterChain.access$1100(AbstractIoFilt erChain.java:53)
at org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.messageReceive d(AbstractIoFilterChain.java:648)
at org.apache.mina.common.IoFilterAdapter.messageReceived(IoFilterAdapter.java:80)
at org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(Ab stractIoFilterChain.java:299)
at org.apache.mina.common.support.AbstractIoFilterChain.access$1100(AbstractIoFilt erChain.java:53)
at org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.messageReceive d(AbstractIoFilterChain.java:648)
at org.apache.mina.filter.codec.support.SimpleProtocolDecoderOutput.flush(SimplePr otocolDecoderOutput.java:58)
at org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecF ilter.java:185)
at org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(Ab stractIoFilterChain.java:299)
at org.apache.mina.common.support.AbstractIoFilterChain.access$1100(AbstractIoFilt erChain.java:53)
at org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.messageReceive d(AbstractIoFilterChain.java:648)
at org.apache.mina.filter.executor.ExecutorFilter.processEvent(ExecutorFilter.java :239)
at org.apache.mina.filter.executor.ExecutorFilter$ProcessEventsRunnable.run(Execut orFilter.java:283)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java: 886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:51)
at java.lang.Thread.run(Thread.java:662)

Please advice,

Best Regards,

Stevenson Lee

I checked the codes in http://fisheye.igniterealtime.org/browse/~br=trunk/svn-org/openfire/trunk/src/ja va/org/jivesoftware/openfire/session/LocalClientSession.java?hb=true

(This could be an old code but I’m using openfire 3.7.1)

I think privacy list is somehow affected by clustering but I don’t know why. Does someone have any idea?

The error occurs on

``(defaultList != ``null && defaultList.getName().equals(``this``.defaultList))) {

but the default list is given by the caller… Is there a reason why this happens?

``/**

``* Sets the default Privacy list used for the session's user. This list is

``* processed if there is no active list set for the session.

``*

``* @param defaultList the default Privacy list used for the session's user.

``*/

``public void setDefaultList(PrivacyList defaultList) {

``// Do nothing if nothing has changed

``if ((``this``.defaultList == ``null && defaultList == ``null``) ||

``(defaultList != ``null && defaultList.getName().equals(``this``.defaultList))) {

``return``;

``}

``this``.defaultList = defaultList != ``null ? defaultList.getName() : ``null``;

``if (ClusterManager.isClusteringStarted()) {

``// Track information about the session and share it with other cluster nodes

``Cache<String,ClientSessionInfo> cache = SessionManager.getInstance().getSessionInfoCache();

``cache.put(getAddress().toString(), ``new ClientSessionInfo(``this``));

``}

``}

``public void setAuthToken(AuthToken auth, String resource) {

``setAddress(``new JID(auth.getUsername(), getServerName(), resource));

``authToken = auth;

``setStatus(Session.STATUS_AUTHENTICATED);

``// Set default privacy list for this session

``setDefaultList(PrivacyListManager.getInstance().getDefaultPrivacyList(auth.getUsername()));

``// Add session to the session manager. The session will be added to the routing table as well

``sessionManager.addSession(``this``);

``}

I tried clearing the privacy list cache and I am able to connect properly in mydomain:9090/system-cache.jsp

I don’t know what’s corrupting the privacy list cache when clustering is enabled.

Is there anyway to fix this without manually clearing the system cache?

Please advice

I was able to resolve my issue by modifying to code a bit

(defaultList != ``null &&

**defaultList.getName() != null && this.defaultList != null**

defaultList.getName().equals(``this``.defaultList))) {

just to avoid the null pointer exception.

If there is a better solution please inform me

Thanks guys,

Best regards,

Stevenson Lee

In the class org.jivesoftware.openfire.privacy.PrivacyList, modify the method of writeExternal(ObjectOutput out), you only add under code:

ExternalizableUtil.getInstance().writeBoolean(out, name != null);

if(name != null)

{

ExternalizableUtil.getInstance().writeSafeUTF(out, name);

}

and modify the method of readExternal(ObjectInput in),you need to add under code:

if(ExternalizableUtil.getInstance().readBoolean(in))

{

name = ExternalizableUtil.getInstance().readSafeUTF(in);

}

but the order of writing the name and reading the name need to be consistent

good luck!

hi huan, I’m still new to all this and haven’t really done anything heavy debugging on openfire. Could you explain how the changing writeExternal and readExternal will prevent this error?