如何在red5服务器中嵌入我的代码?

时间:2017-08-04 08:24:27

标签: red5

我想在我的Red5服务器应用程序中使用JWT生成令牌代码。当我在本地生成JWT的令牌代码时,没有错误。当我在Red5服务器应用程序中嵌入生成令牌代码时,显示异常如下:

[ERROR] [RTMPConnectionExecutor-1] org.red5.server.net.rtmp.BaseRTMPHandler - Exception
java.lang.NoClassDefFoundError: com/auth0/jwt/JWTSigner
    at org.red5.jwt.util.JWTUtil.<clinit>(JWTUtil.java:23)
    at org.red5.core.Application.connect(Application.java:68)
    at org.red5.server.scope.Scope.connect(Scope.java:248)
    at org.red5.server.BaseConnection.connect(BaseConnection.java:366)
    at org.red5.server.net.rtmp.RTMPConnection.connect(RTMPConnection.java:486)
    at org.red5.server.net.rtmp.RTMPMinaConnection.connect(RTMPMinaConnection.java:93)
    at org.red5.server.net.rtmp.RTMPHandler.onCommand(RTMPHandler.java:337)
    at org.red5.server.net.rtmp.BaseRTMPHandler.messageReceived(BaseRTMPHandler.java:116)
    at org.red5.server.net.rtmp.ReceivedMessageTask.call(ReceivedMessageTask.java:72)
    at org.red5.server.net.rtmp.ReceivedMessageTask.call(ReceivedMessageTask.java:38)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: com.auth0.jwt.JWTSigner
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1285)
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1119)
    ... 16 common frames omitted

我的代码是这样的:

public class Application extends MultiThreadedApplicationAdapter {

    @Override
    public boolean connect(IConnection conn, IScope scope, Object[] params) {


        String token="eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9";

        PayLoadMapper userValid = JWTUtil.unsign(token, PayLoadMapper.class);

        System.out.println(userValid);
      }
}

为什么我无法将我的api代码嵌入到Red5应用程序中?这是我犯这个错误的方式。我怎么能这样做?

2 个答案:

答案 0 :(得分:1)

确保检查您应用程序下的JWT lib。

答案 1 :(得分:0)

我解决了这个问题。 Ip将jar放在red5服务器lib中,我的应用程序的lib是空的,所以我把JWT lib放在了应用程序下。现在没关系。