"Cluster-MembershipReceiver" java.lang.OutOfMemoryError

xz43發表於2012-09-24
本來找了臺linux伺服器,打算用tomcat5.5.30和apache2.2.6搭建個叢集測試環境,一切按原來的方式安裝配置完畢,啟動一個tomcat,居然報如下錯誤,雖然不影響應用正常啟動,但還是沒達到效果:
警告: Error receiving mcast package (errorCounter=0). Sleeping 500 ms
java.lang.ArrayIndexOutOfBoundsException
        at java.lang.System.arraycopy(Native Method)
        at org.apache.catalina.cluster.mcast.McastMember.getMember(McastMember.java:175)
        at org.apache.catalina.cluster.mcast.McastServiceImpl.receive(McastServiceImpl.java:265)
        at org.apache.catalina.cluster.mcast.McastServiceImpl$ReceiverThread.run(McastServiceImpl.java:355)
Exception in thread "Cluster-MembershipReceiver" java.lang.OutOfMemoryError: Java heap space
        at org.apache.catalina.cluster.mcast.McastMember.getMember(McastMember.java:174)
        at org.apache.catalina.cluster.mcast.McastServiceImpl.receive(McastServiceImpl.java:265)
        at org.apache.catalina.cluster.mcast.McastServiceImpl$ReceiverThread.run(McastServiceImpl.java:355)
2012-9-24 16:07:25 org.apache.catalina.cluster.mcast.McastService registerMBean
 
奇怪了,我明明設定了JAVA_OPTS引數,怎麼會報記憶體溢位,去掉應用再啟動tomcat,報錯依舊。是不是JAVA_OPTS配置沒起作用,如是把JAVA_OPTS的配置移到/etc/profile裡面,再次啟動tomcat,記憶體溢位的錯誤不報了,但不停的報下面的錯誤:
警告: Error receiving mcast package (errorCounter=0). Sleeping 500 ms
java.lang.ArrayIndexOutOfBoundsException
        at java.lang.System.arraycopy(Native Method)
        at org.apache.catalina.cluster.mcast.McastMember.getMember(McastMember.java:175)
        at org.apache.catalina.cluster.mcast.McastServiceImpl.receive(McastServiceImpl.java:265)
        at org.apache.catalina.cluster.mcast.McastServiceImpl$ReceiverThread.run(McastServiceImpl.java:355)
2012-9-24 17:10:40 org.apache.catalina.cluster.mcast.McastService registerMBean
 
找到tomcat5.5的原始碼,找到問題程式碼,問題出在這個計算
byte[] nlend = new byte[4];
System.arraycopy(data, 16, nlend, 0, 4);
int nlen = XByteBuffer.toInt(nlend, 0);
發現這段程式碼重複執行了N次,第一次正常,第二次就開始報錯,這裡返回的 nlen 引數很大。
 
暫時也找不到解決辦法了,沒時間深入研究。

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9399028/viewspace-744947/,如需轉載,請註明出處,否則將追究法律責任。

相關文章