本来找了台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.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
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);
System.arraycopy(data, 16, nlend, 0, 4);
int nlen = XByteBuffer.toInt(nlend, 0);
发现这段代码重复执行了N次,第一次正常,第二次就开始报错,这里返回的 nlen 参数很大。
暂时也找不到解决办法了,没时间深入研究。
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/9399028/viewspace-744947/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/9399028/viewspace-744947/