jfinal+redis异常

今天用redisplugin做缓存,在set时候出现异常,一下为代码和异常信息,
配置为官网配置,求高手解答一下。

RedisPlugin redis = new RedisPlugin("test", "localhost");
me.add(redis);

controller

public void getRedisExampleList(){

Cache bbsCache = Redis.use("test");

bbsCache.set("key", "value");

}

在set的时候出错,报错信息
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
	at com.jfinal.aop.Invocation.invoke(Invocation.java:87)
	at com.mht.common.interceptor.ParameterInterceptor.intercept(ParameterInterceptor.java:28)
	at com.jfinal.aop.Invocation.invoke(Invocation.java:67)
	at com.jfinal.ext.interceptor.SessionInViewInterceptor.intercept(SessionInViewInterceptor.java:44)
	at com.jfinal.aop.Invocation.invoke(Invocation.java:67)
	at com.mht.common.interceptor.ParameterInterceptor.intercept(ParameterInterceptor.java:28)
	at com.jfinal.aop.Invocation.invoke(Invocation.java:67)
	at com.jfinal.core.ActionHandler.handle(ActionHandler.java:82)
	at com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:73)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1307)
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:453)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:560)
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1072)
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:382)
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1006)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
	at org.eclipse.jetty.server.Server.handle(Server.java:365)
	at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:485)
	at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:926)
	at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:988)
	at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:635)
	at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
	at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:628)
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.reflect.InvocationTargetException
	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 com.jfinal.aop.Invocation.invoke(Invocation.java:73)
	... 31 more
Caused by: java.lang.NoClassDefFoundError: redis/clients/util/SafeEncoder
	at com.jfinal.plugin.redis.serializer.FstSerializer.keyToBytes(FstSerializer.java:35)
	at com.jfinal.plugin.redis.Cache.keyToBytes(Cache.java:1155)
	at com.jfinal.plugin.redis.Cache.set(Cache.java:66)
	at com.mht.redis.RedisExampleController.getRedisExampleList(RedisExampleController.java:17)
	... 36 more
Caused by: java.lang.ClassNotFoundException: redis.clients.util.SafeEncoder
	at java.net.URLClassLoader.findClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	... 40 more


maven包

<dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-pool2</artifactId>
            <version>2.5.0</version>
        </dependency>
        
        
        <!-- https://mvnrepository.com/artifact/de.ruedigermoeller/fst 序列-->
		<dependency>
		    <groupId>de.ruedigermoeller</groupId>
		    <artifactId>fst</artifactId>
		    <version>2.50</version>
		</dependency>
	<dependency>
		    <groupId>redis.clients</groupId>
		    <artifactId>jedis</artifactId>
		    <version>3.0.0</version>
		</dependency>


评论区

JFinal

2019-02-25 18:16

可能是 maven 依赖的 jedis 下载 jar 包时出错了,将本地 maven 库中的 jedis 目录删掉,让 maven 重新下载

周小薰

2019-02-26 09:10

@JFinal 把jedis和fst本地包重新下载,问题依然。

Storm_Four

2019-08-17 18:13

jedis要2.9版本

邓小杰

2019-09-05 09:56

降低jedis版本

热门反馈

扫码入社