springmvc整合memcached,无法初始化SockIO pool,困惑!

问题描述

自己做了一个springMVC+memcached的示例,启动的时候抛了这个错误 [ERROR] attempting to get SockIO from uninitialized pool!memcachedPool可能有点问题,请大家帮忙看下,谢谢了。​备注:查了很多资料,咱们iteye中有人遇到过相同的问题,我按照他解决的办法并没有起作用。         pengmj 给出的解决办法是在 <bean id="memcahedPool"中加入lazy-init= false,也不行。大家帮看下我的代码哪里有问题~先谢过哈 spring配置文件如下: <?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd"><bean id="memcachedPool" class="com.danga.MemCached.SockIOPool" factory-method="getInstance" init-method="initialize" lazy-init="false" destroy-method="shutDown"><constructor-arg><value>memcachedPool</value></constructor-arg><property name="servers"><list><value>127.0.0.1:11211</value></list></property><property name="initConn"><value>20</value></property><property name="minConn"><value>20</value></property><property name="maxConn"><value>1000</value></property><property name="nagle"><value>false</value></property><property name="socketTO"><value>3000</value></property></bean><bean id="memcachedClient" class="com.danga.MemCached.MemCachedClient" ><constructor-arg><value>memcachedPool</value></constructor-arg></bean></beans> 使用了基于注解的方式,Controller类如下  package com.test.web;import java.util.Date;import javax.servlet.http.HttpSession;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestParam;import org.springframework.web.servlet.ModelAndView;import com.danga.MemCached.MemCachedClient;import com.test.utils.MemcachedUtils;@Controller@RequestMapping("/loginController")public class Login {@Autowiredprivate MemCachedClient mcc;@RequestMapping("/login")public ModelAndView login(@RequestParam(value = "username") String userid,@RequestParam(value = "password") String passwd, HttpSession session){ModelAndView m = new ModelAndView();m.setViewName("../index");MemcachedUtils.set("test", "hello memcached",new Date(1000 * 60));//这里有问题!Object o = MemcachedUtils.get("test");//这里有问题!System.out.println(o.toString());m.addObject("errMsg","成功返回!");return m;}} MemcachedUtils类代码如下:  import java.io.IOException;import java.io.PrintWriter;import java.io.StringWriter;import java.lang.management.ManagementFactory;import java.lang.management.RuntimeMXBean;import java.text.SimpleDateFormat;import java.util.Date;import org.apache.log4j.Logger;import com.danga.MemCached.MemCachedClient;public class MemcachedUtils {private static final Logger logger = Logger.getLogger(MemcachedUtils.class); private static MemCachedClient cachedClient; static { if (cachedClient == null) cachedClient = new MemCachedClient(); } private MemcachedUtils() { } /** * 添加memcached。 */ public static boolean set(String key, Object value, Date expire) { return setExp(key, value, expire); } private static boolean setExp(String key, Object value, Date expire) { boolean flag = false; try { flag = cachedClient.set(key, value, expire); } catch (Exception e) { logger.error(""Memcached set方法报错,key值:" + key + "rn"", e); } return flag; } /** * 获取memcached。 */ public static Object get(String key) { Object obj = null; try { obj = cachedClient.get(key); } catch (Exception e) { logger.error(""Memcached get方法报错,key值:" + key + "rn"", e); } return obj; } } 执行login类的login方法时出现[ERROR] attempting to get SockIO from uninitialized pool!大家帮看看,先谢过了哈。 错误堆栈信息如下:[ERROR] attempting to get SockIO from uninitialized pool![ERROR] attempting to get SockIO from uninitialized pool!2014-11-27 23:39:45 org.apache.catalina.core.StandardWrapperValve invoke严重: Servlet.service() for servlet springMVC threw exceptionjava.lang.NullPointerExceptionat com.test.web.Login.login(Login.java:37)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)at java.lang.reflect.Method.invoke(Unknown Source)at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:219)at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:100)at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:604)at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:565)at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)at java.lang.Thread.run(Unknown Source)

解决方案

使用的什么客户端,xmemcached和spring的整合:http://silentwu.iteye.com/blog/2124413

时间: 2024-11-10 00:27:20

springmvc整合memcached,无法初始化SockIO pool,困惑!的相关文章

SpringMVC整合mybatis实例代码_java

MyBatis 本是apache的一个开源项目iBatis, 2010年这个项目由apache software foundation 迁移到了google code,并且改名为MyBatis . 一.逆向工程生成基础信息 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis G

pringmvc-求教,SpringMVC整合hessian,客户端找不到服务端的接口类!求配置代码活解决方案!谢谢!

问题描述 求教,SpringMVC整合hessian,客户端找不到服务端的接口类!求配置代码活解决方案!谢谢! 求教,SpringMVC整合hessian,客户端找不到服务端的接口类!求配置代码活解决方案!谢谢!

springmvc整合freemarker怎么弄

问题描述 springmvc整合freemarker整合流程和原理是什么?最好能有个demo! 问题补充:spirngmvc中freemarker自定义标签的使用原理 解决方案 一. 用macro实现自定义指令,例如:自定义指令可以使用macro指令来定义. <#macro greet person> <font size="+2">Hello ${person}!</font> </#macro> macro指令自身不打印任何内容,它只

Dubbo与Zookeeper、SpringMVC整合和使用(负载均衡、容错)(转)

 互联网的发展,网站应用的规模不断扩大,常规的垂直应用架构已无法应对,分布式服务架构以及流动计算架构势在必行,Dubbo是一个分布式服务框架,在这种情况下诞生的.现在核心业务抽取出来,作为独立的服务,使前端应用能更快速和稳定的响应.   第一:介绍Dubbo背景              大规模服务化之前,应用可能只是通过RMI或Hessian等工具,简单的暴露和引用远程服务,通过配置服务的URL地址进行调用,通过F5等硬件进行负载均衡. (1) 当服务越来越多时,服务URL配置管理变得非常困难

Dubbo与Zookeeper、SpringMVC整合和使用(负载均衡、容错)(转)

互联网的发展,网站应用的规模不断扩大,常规的垂直应用架构已无法应对,分布式服务架构以及流动计算架构势在必行,Dubbo是一个分布式服务框架,在这种情况下诞生的.现在核心业务抽取出来,作为独立的服务,使前端应用能更快速和稳定的响应.   第一:介绍Dubbo背景              大规模服务化之前,应用可能只是通过RMI或Hessian等工具,简单的暴露和引用远程服务,通过配置服务的URL地址进行调用,通过F5等硬件进行负载均衡. (1) 当服务越来越多时,服务URL配置管理变得非常困难,

SpringMVC整合hessian出现异常

问题描述 SpringMVC整合hessian出现异常 严重: Servlet.service() for servlet spring threw exception java.net.HttpRetryException: cannot retry due to redirection, in streaming mode at sun.net.www.protocol.http.HttpURLConnection.followRedirect(HttpURLConnection.java:

mybatis-mybaitis springmvc整合空指针异常

问题描述 mybaitis springmvc整合空指针异常 这是我的web.xml <?xml version="1.0" encoding="UTF-8"?> xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation=&quo

springmvc整合jasperreport,中文不显示

问题描述 springmvc整合jasperreport,中文不显示 我用sping mvc整合jasperreport做报表输出的部分,预览时中文显示不出来,itext,itextasian我都加过了,这是什么原因呢

求大神:springmvc整合hibernate在web.xml都需要注入什么啊

问题描述 求大神:springmvc整合hibernate在web.xml都需要注入什么啊 contextConfigLocation/WEB-INF/spring/root-context.xml <!-- Creates the Spring Container shared by all Servlets and Filters --> <listener> <listener-class>org.springframework.web.context.Conte