Error creating bean with name & #39; memcachedClient & #39;... java. lang. OutOfMemoryError

Source: Internet
Author: User

1. Tomcat startup error:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'memcachedClient' defined in file [/usr/local/apache-tomcat-6.0.37_6500/webapps/trade_service/WEB-INF/classes/META-INF/spring/springContext_memcached.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public net.rubyeye.xmemcached.MemcachedClient net.rubyeye.xmemcached.XMemcachedClientBuilder.build() throws java.io.IOException] threw exception; nested exception is java.lang.OutOfMemoryError        at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:581)        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1015)        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:911)        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)        ... 44 moreCaused by: org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public net.rubyeye.xmemcached.MemcachedClient net.rubyeye.xmemcached.XMemcachedClientBuilder.build() throws java.io.IOException] threw exception; nested exception is java.lang.OutOfMemoryError        at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:169)        at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:570)        ... 53 moreCaused by: java.lang.OutOfMemoryError

,

2. When you see an error when creating a memcache clent, go to the memcache server and check that memcache is running normally, and the memory is sufficient.

[root@localhost ~]# tail -f /tmp/memcache_error.log <287    0x00 0x00 0x00 0x00<287    0x00 0x00 0x00 0x00<287    0x00 0x00 0x00 0x00>287 Writing bin response:>287   0x81 0x0b 0x00 0x00>287   0x00 0x00 0x00 0x00>287   0x00 0x00 0x00 0x06>287   0x00 0x00 0x00 0x00>287   0x00 0x00 0x00 0x00>287   0x00 0x00 0x00 0x00...[root@localhost ~]# free -m             total       used       free     shared    buffers     cachedMem:          5938       3368       2570          0        195        296-/+ buffers/cache:       2876       3061Swap:         7935          0       7935[root@localhost ~]# 
Where is the problem? Check the error or warning information in the log:

[root@localhost ~]# cat  /tmp/memcache_error.log  |grep warning[root@localhost ~]# cat  /tmp/memcache_error.log  |grep error[root@localhost ~]#
There is no error message at all, and the problem is not identified in memcache.

3. check the tomcat server.

[root@localhost logs]# free -m             total       used       free     shared    buffers     cachedMem:         18022      16943       1078          0        104        675-/+ buffers/cache:      16162       1859Swap:        20031       8012      12019[root@localhost logs]# 
With only 1 GB of memory remaining, modify the tomcat memory Configuration:

[Root @ localhost bin] # vim catalina. sh

#JAVA_OPTS="-Xms2048m -Xmx2048m -Xss1024K -XX:PermSize=256m -XX:MaxPermSize=768m"# add by wangqi on 20140614 JAVA_OPTS="-Xms512m -Xmx512m -Xss128K -XX:PermSize=64m -XX:MaxPermSize=256m"
Restart tomcat again to see the same error.


4. Go back to the application to check the problem.

After troubleshooting with the developer, we can see that trade_service has started too many redundant transactions and reduced tomcat memory usage. Therefore, if you close unnecessary transactions and start tomcat again, no error will be reported.


Emotion: As with most web application cards and page logon failures, the slow response is mostly due to low-efficiency SQL statements. tomcat cannot be started, and most memory overflow occurs in java code, exercise caution when writing code or SQL statements.






Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.