首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

Memcached-Java-Client 异常。请人指点!速结

2013-09-11 
Memcached-Java-Client 错误。请人指点!速结https://github.com/gwhalin/Memcached-Java-Client/wiki/HOWTO

Memcached-Java-Client 错误。请人指点!速结
https://github.com/gwhalin/Memcached-Java-Client/wiki/HOWTO

-----------------------
package test;

import com.danga.MemCached.*;

public class TestMemcache {

// create a static client as most installs only need
// a single instance
protected static MemCachedClient mcc = new MemCachedClient();

// set up connection pool once at class load
static {

// server list and weights
String[] servers = { "192.168.1.212:11211" };

Integer[] weights = { 3 };

// grab an instance of our connection pool
SockIOPool pool = SockIOPool.getInstance();

// set the servers and the weights
pool.setServers(servers);
pool.setWeights(weights);

// set some basic pool settings
// 5 initial, 5 min, and 250 max conns
// and set the max idle time for a conn
// to 6 hours
pool.setInitConn(5);
pool.setMinConn(5);
pool.setMaxConn(250);
pool.setMaxIdle(1000 * 60 * 60 * 6);

// set the sleep for the maint thread
// it will wake up every x seconds and
// maintain the pool size
pool.setMaintSleep(30);

// set some TCP settings
// disable nagle
// set the read timeout to 3 secs
// and don’t set a connect timeout
pool.setNagle(false);
pool.setSocketTO(3000);
pool.setSocketConnectTO(0);

// initialize the connection pool
pool.initialize();

// lets set some compression on for the client
// compress anything larger than 64k
mcc.setCompressEnable(true);
mcc.setCompressThreshold(64 * 1024);
}

// from here on down, you can call any of the client calls
public static void examples() {
mcc.set("foo", "This is a test String");
//String bar = (String)mcc.get("foo");
}
}
--------web----------------
  <body>
  <%
TestMemcache.examples();
%>
  This is my JSP page. <br>
  </body>

---------ERROR---------------------
HTTP Status 500 - 

type Exception report

message 

description The server encountered an internal error () that prevented it from fulfilling this request.

exception 

org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: 6 in the generated java file
Only a type can be imported. test.TestMemcache resolves to a package

An error occurred at line: 33 in the jsp file: /Test/MyTest.jsp
TestMemcache cannot be resolved
30:  
31: <body>
32: <%
33: TestMemcache.examples();
34: %>
35: This is my JSP page. <br>
36: </body>


Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:439)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:356)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:334)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:321)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:592)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


note The full stack trace of the root cause is available in the Apache Tomcat/6.0.33 logs.

---------------------



那位高人帮忙解决下。


[解决办法]

Java code
import com.danga.MemCached.*;import java.util.Date;public class CacheClient {  protected static MemCachedClient mcc = new MemCachedClient();  static {    String[] serverlist = {Constant.MEMCACHE_SERVER};    SockIOPool pool = SockIOPool.getInstance();    pool.setServers(serverlist);    pool.initialize();  }  public static String get(String strKey) {    return (String)mcc.get(strKey);  }  public static boolean set(String strKey,String strValue,Date objDate){    return mcc.set(strKey,strValue,objDate);  }}
[解决办法]
An error occurred at line: 33 in the jsp file: /Test/MyTest.jsp
TestMemcache cannot be resolved
 

一看就是没有引包吧。。。。
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.myexception.cn/java-web/317.html
我的异常网推荐解决方案:org.apache.jasper.JasperException: Unable to compile class,http://www.myexception.cn/j2ee/2308.html

热点排行