NutzCN Logo
问答 麻烦问下大佬如何处理这个 jwt异常
发布于 1704天前 作者 qq_bc3a431e 2776 次浏览 复制 上一个帖子 下一个帖子
标签:

麻烦大佬帮忙下,下面是报的异常

2020-03-16 20:40:56,184 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) DEBUG - SELECT COUNT(*) FROM user  WHERE userId=? AND userPassword=?
    |   1 |   2 |
    |-----|-----|
    | 123 | 123 |
  For example:> "SELECT COUNT(*) FROM user  WHERE userId='123' AND userPassword='123'"
2020-03-16 20:40:56,190 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) DEBUG - SELECT * FROM user  WHERE userId=? AND userPassword=? LIMIT 0, 1 
    |   1 |   2 |
    |-----|-----|
    | 123 | 123 |
  For example:> "SELECT * FROM user  WHERE userId='123' AND userPassword='123' LIMIT 0, 1 "
2020-03-16 20:40:56,193 com.king.ifs.business.UserIfs.appLogin(UserIfs.java:84) DEBUG - user-->123
2020-03-16 20:40:56,223 com.king.processor.LogTimeProcessor.process(LogTimeProcessor.java:24) DEBUG - 166ms [POST]URI=/ifs/userIfs/appLogin
2020-03-16 20:40:56,224 com.king.processor.ViewFailProcessor.process(ViewFailProcessor.java:65) DEBUG - error-->{}
java.util.ServiceConfigurationError: io.jsonwebtoken.io.Serializer: Provider io.jsonwebtoken.jackson.io.JacksonSerializer could not be instantiated
	at java.util.ServiceLoader.fail(ServiceLoader.java:232)
	at java.util.ServiceLoader.access$100(ServiceLoader.java:185)
	at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:384)
	at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404)
	at java.util.ServiceLoader$1.next(ServiceLoader.java:480)
	at io.jsonwebtoken.impl.lang.Services.loadFirst(Services.java:111)
	at io.jsonwebtoken.impl.lang.Services.loadFirst(Services.java:100)
	at io.jsonwebtoken.impl.lang.LegacyServices.loadFirst(LegacyServices.java:21)
	at io.jsonwebtoken.impl.DefaultJwtBuilder.compact(DefaultJwtBuilder.java:300)
	at com.king.util.JWTUtil.createJWT(JWTUtil.java:92)
	at com.king.ifs.business.UserIfs.appLogin(UserIfs.java:88)
	at com.king.ifs.business.UserIfs$FM$appLogin$51ae6ef90ba778e1fded7e2894d08282.invoke(UserIfs.java)
	at org.nutz.mvc.impl.processor.MethodInvokeProcessor.process(MethodInvokeProcessor.java:31)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.AdaptorProcessor.process(AdaptorProcessor.java:38)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFiltersProcessor.java:58)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:123)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcessor.java:27)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(UpdateRequestAttributesProcessor.java:15)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at com.king.processor.UrlActionFilersProcessor.process(UrlActionFilersProcessor.java:90)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at com.king.processor.LogTimeProcessor.process(LogTimeProcessor.java:19)
	at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:44)
	at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:67)
	at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31)
	at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:202)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:94)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:502)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1132)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:684)
	at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2527)
	at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2516)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/JsonProcessingException
	at java.lang.Class.getDeclaredConstructors0(Native Method)
	at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)
	at java.lang.Class.getConstructor0(Class.java:3075)
	at java.lang.Class.newInstance(Class.java:412)
	at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:380)
	... 45 more
Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.core.JsonProcessingException
	at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1335)
	at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1163)
	... 50 more
2020-03-16 20:40:56,228 com.king.processor.ViewFailProcessor.process(ViewFailProcessor.java:91) DEBUG - 请求错误--》io.jsonwebtoken.io.Serializer: Provider io.jsonwebtoken.jackson.io.JacksonSerializer could not be instantiated
2020-03-16 20:40:56,228 com.king.processor.ViewFailProcessor.process(ViewFailProcessor.java:92) DEBUG - aa请求错误--》io.jsonwebtoken.io.Serializer: Provider io.jsonwebtoken.jackson.io.JacksonSerializer could not be instantiated
jwt引用的是这里的代码
 https://nutz.cn/yvr/t/uup9qmdvtoj3cphscero2qi74t
 ```

这里是登录处的代码
@POST
@At
@Ok("json")
public Result appLogin(@Param("..")UserVO userVO){
int loginCount=userMOImpl.count(Cnd.where("userId","=",userVO.getUserId())
.and("userPassword","=",userVO.getUserPassword()));
if(loginCount>0){
UserVO userVO1=userMOImpl.fetch(Cnd.where("userId","=",userVO.getUserId())
.and("userPassword","=",userVO.getUserPassword()));

        NutMap nutMap=new NutMap();
       nutMap.setv("userId",userVO.getUserId()).
                setv("userName",userVO.getUserName()).
                setv("token", JWTUtil.createJWT(userVO.getUserId()));
        return Result.success(nutMap);
    }else {
        return Result.fail();
    }

```

2 回复

jackson版本问题

默认的依赖为下面的,但无法运行,更换最新的也还是没法运行
builder.compact()对应的包替换为0.11.0也还是不行,麻烦问下还有没有其他办法呢

<!-- api token web server -->
        <dependency>
            <groupId>io.jsonwebtoken</groupId>
            <artifactId>jjwt-api</artifactId>
            <version>0.10.5</version>
        </dependency>
        <dependency>
            <groupId>io.jsonwebtoken</groupId>
            <artifactId>jjwt-impl</artifactId>
            <version>0.10.5</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>io.jsonwebtoken</groupId>
            <artifactId>jjwt-jackson</artifactId>
            <version>0.10.5</version>
            <scope>runtime</scope>
        </dependency>
添加回复
请先登陆
回到顶部