manchesliang
老生
老生
  • UID233
  • 粉丝0
  • 关注0
  • 发帖数13
阅读:6749回复:3

memcache报错问题请教

楼主#
更多 发布于:2016-03-25 22:32
 

在写memcached这一块,就是简单的输出一个cache中的字符串,都报错了,下面是代码和报错,还请老师帮忙瞅一眼,谢谢!


@RequestMapping("/newsdetail")
 public ModelAndView loadnewsdetail(int newsid) throws IOException
 {
  ModelAndView mv=new ModelAndView("newsdetail");
  net.spy.memcached.MemcachedClient mc=new net.spy.memcached.MemcachedClient(net.spy.memcached.AddrUtil.getAddresses("127.0.0.1:11211"));
  mc.set("test123",20,"非常好");
  System.out.println("test123");

  /*
  net.spy.memcached.MemcachedClient mc=new net.spy.memcached.MemcachedClient(net.spy.memcached.AddrUtil.getAddresses("127.0.0.1:11211"));
  
  
  NewsModel news=(NewsModel) mc.get("newsModel_key");
  if(news==null)
  {
   news=newsservice.newsdetail(newsid);
   mc.set("newsModel_key", 3600*6, news);
  }
  else
  {
   System.out.println("使用了缓存中的内容");  
  }*/
  mv.addObject("newsdetail",newsservice.newsdetail(newsid));
  return mv;
 }


报错:


pe Exception report
message Handler processing failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class sun.nio.ch.SocketChannelImpl$DefaultOptionsHolder
description The server encountered an internal error that prevented it from fulfilling this request.
exception

org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class sun.nio.ch.SocketChannelImpl$DefaultOptionsHolder
org.springframework.web.servlet.DispatcherServlet.triggerAfterCompletionWithError(DispatcherServlet.java:1302)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:977)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:969)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:860)
javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:845)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

root cause

java.lang.NoClassDefFoundError: Could not initialize class sun.nio.ch.SocketChannelImpl$DefaultOptionsHolder
sun.nio.ch.SocketChannelImpl.supportedOptions(Unknown Source)
sun.nio.ch.SocketChannelImpl.setOption(Unknown Source)
sun.nio.ch.SocketAdaptor.setBooleanOption(Unknown Source)
sun.nio.ch.SocketAdaptor.setTcpNoDelay(Unknown Source)
sun.nio.ch.WindowsSelectorImpl.<init>(Unknown Source)
sun.nio.ch.WindowsSelectorProvider.openSelector(Unknown Source)
java.nio.channels.Selector.open(Unknown Source)
net.spy.memcached.MemcachedConnection.<init>(MemcachedConnection.java:160)
net.spy.memcached.DefaultConnectionFactory.createConnection(DefaultConnectionFactory.java:197)
net.spy.memcached.MemcachedClient.<init>(MemcachedClient.java:207)
net.spy.memcached.MemcachedClient.<init>(MemcachedClient.java:177)
com.myweb.NewsAction.loadnewsdetail(NewsAction.java:64)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:222)
org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)
org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:814)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:737)
org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:969)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:860)
javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:845)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

note The full stack trace of the root cause is available in the Apache Tomcat/8.0.30 logs.
shenyi
管理员
管理员
  • UID1
  • 粉丝36
  • 关注0
  • 发帖数652
沙发#
发布于:2016-03-25 23:12
重新编译 全部工程。 并查看相应的类库是否引用正确
会讲故事的程序员
manchesliang
老生
老生
  • UID233
  • 粉丝0
  • 关注0
  • 发帖数13
板凳#
发布于:2016-03-26 11:23
找到原因了,我电脑的java自动升级了,tomcat里设置的java_home路径不对了。

谢谢沈叔!
1945605733
新生
新生
  • UID356
  • 粉丝0
  • 关注0
  • 发帖数3
地板#
发布于:2016-05-03 10:59
manchesliang:找到原因了,我电脑的java自动升级了,tomcat里设置的java_home路径不对了。

谢谢沈叔!
回到原帖
java还能自动升级吗
游客

返回顶部