Red5 1.0.7M10: Could not find or load main class F

2019-07-24 18:16发布

问题:

I was going to take a look at the latest 1.0.7 on a Windows 2012 server and downloaded the latest .zip. I extracted the .zip into my normal Red5 directory (d:\program files (x86)\Red5) and tried to run red5.bat and got the error, "Could not find or load main class Files". However, RED5_HOME and JAVA_HOME have not changed. What did I miss?

Output of the red5.bat file:

    D:\Program Files (x86)\Red5>if NOT DEFINED RED5_MAINCLASS set RED5_MAINCLASS=org
    .red5.server.Bootstrap

    D:\Program Files (x86)\Red5>if NOT DEFINED JAVA_HOME goto err

    D:\Program Files (x86)\Red5>REM JAVA options

    D:\Program Files (x86)\Red5>REM You can set JVM additional options here if you w
    ant

    D:\Program Files (x86)\Red5>if NOT DEFINED JVM_OPTS set JVM_OPTS=-Xverify:none -
    XX:+TieredCompilation -XX:+UseBiasedLocking -XX:+UseParNewGC -XX:InitialCodeCach
    eSize=8m -XX:ReservedCodeCacheSize=32m -Dorg.terracotta.quartz.skipUpdateCheck=t
    rue

    D:\Program Files (x86)\Red5>REM Set up logging options

    D:\Program Files (x86)\Red5>set LOGGING_OPTS=-Dlogback.ContextSelector=org.red5.
    logging.LoggingContextSelector -Dcatalina.useNaming=true

    D:\Program Files (x86)\Red5>REM Set up security options

    D:\Program Files (x86)\Red5>REM set SECURITY_OPTS=-Djava.security.debug=failure
    -Djava.security.manager -Djava.security.policy="D:\Program Files (x86)\Red5/conf
    /red5.policy"

    D:\Program Files (x86)\Red5>set SECURITY_OPTS=-Djava.security.debug=failure

    D:\Program Files (x86)\Red5>REM Set up tomcat options

    D:\Program Files (x86)\Red5>set TOMCAT_OPTS=-Dcatalina.home=D:\Program Files (x8
    6)\Red5

    D:\Program Files (x86)\Red5>REM Setup python/jython path

    D:\Program Files (x86)\Red5>set JYTHON_OPTS=-Dpython.home=lib

    D:\Program Files (x86)\Red5>REM Combined java options

    D:\Program Files (x86)\Red5>set JAVA_OPTS=-Dlogback.ContextSelector=org.red5.log
    ging.LoggingContextSelector -Dcatalina.useNaming=true -Djava.security.debug=fail
    ure  -Xverify:none -XX:+TieredCompilation -XX:+UseBiasedLocking -XX:+UseParNewGC
     -XX:InitialCodeCacheSize=8m -XX:ReservedCodeCacheSize=32m -Dorg.terracotta.quar
    tz.skipUpdateCheck=true -Dcatalina.home=D:\Program Files (x86)\Red5 -Dpython.hom
    e=lib

    D:\Program Files (x86)\Red5>set RED5_CLASSPATH=D:\Program Files (x86)\Red5\red5-
    service.jar;D:\Program Files (x86)\Red5\conf;

    D:\Program Files (x86)\Red5>if NOT DEFINED RED5_OPTS set RED5_OPTS=

    D:\Program Files (x86)\Red5>goto launchRed5

    D:\Program Files (x86)\Red5>echo Starting Red5
    Starting Red5

    D:\Program Files (x86)\Red5>"D:\Program Files\Java\jdk8\bin\java" -Dlogback.Cont
    extSelector=org.red5.logging.LoggingContextSelector -Dcatalina.useNaming=true -D
    java.security.debug=failure  -Xverify:none -XX:+TieredCompilation -XX:+UseBiased
    Locking -XX:+UseParNewGC -XX:InitialCodeCacheSize=8m -XX:ReservedCodeCacheSize=3
    2m -Dorg.terracotta.quartz.skipUpdateCheck=true -Dcatalina.home=D:\Program Files
     (x86)\Red5 -Dpython.home=lib -cp "D:\Program Files (x86)\Red5\red5-service.jar;
    D:\Program Files (x86)\Red5\conf;" org.red5.server.Bootstrap
    Java HotSpot(TM) 64-Bit Server VM warning: Using the ParNew young collector with
     the Serial old collector is deprecated and will likely be removed in a future r
    elease
    Error: Could not find or load main class Files

I was finally able to get Red5 started by changing the red5.bat file and messing with the quotes around some of the parameters. It's a Windows server so red5 is in c:\program files (x86)\red5. Here is the modified red5.bat file and subsequent error:

if NOT DEFINED RED5_HOME set RED5_HOME=%~dp0

if NOT DEFINED RED5_MAINCLASS set RED5_MAINCLASS=org.red5.server.Bootstrap

if NOT DEFINED JAVA_HOME goto err

if NOT DEFINED JVM_OPTS set JVM_OPTS=-Xverify:none -XX:+TieredCompilation -XX:+UseBiasedLocking -XX:+UseParNewGC -XX:InitialCodeCacheSize=8m -XX:ReservedCodeCacheSize=32m -Dorg.terracotta.quartz.skipUpdateCheck=true

set LOGGING_OPTS=-Dlogback.ContextSelector=org.red5.logging.LoggingContextSelector -Dcatalina.useNaming=true

set SECURITY_OPTS=-Djava.security.debug=failure

set TOMCAT_OPTS=-Dcatalina.home="%RED5_HOME%"

changed above line to include quotes

set JYTHON_OPTS=-Dpython.home=lib

set JAVA_OPTS=%LOGGING_OPTS% %SECURITY_OPTS% %JAVA_OPTS% %JVM_OPTS% %TOMCAT_OPTS% %JYTHON_OPTS%

set RED5_CLASSPATH=%RED5_HOME%\red5-service.jar";"%RED5_HOME%\conf;%CLASSPATH%

Added quotes to end of first param and beginning of second. Quotes are automatically added to front and end of parameter.

if NOT DEFINED RED5_OPTS set RED5_OPTS= 

goto launchRed5

:launchRed5
echo Starting Red5
"%JAVA_HOME%\bin\java" %JAVA_OPTS% -cp "%RED5_CLASSPATH%" %RED5_MAINCLASS% %RED5_OPTS%

However, after I was able to get Red5 running, I added my app, eTutor, and tried to record a stream. I got this error.

[INFO] [RTMPConnectionExecutor-1] maple.classroom.MapleClassroom - W3C x-category:session x-event:connect c-ip:76.242.102.xxx c-client-id:0
[INFO] [Red5_Scheduler_Worker-31] maple.classroom.MapleClassroom - W3C x-category:stream x-event:play c-ip:76.242.102.xxx x-sname:4fb77abf-56aa-45cd-8907-11aa2a333cb6
[INFO] [Red5_Scheduler_Worker-32] maple.classroom.MapleClassroom - W3C x-category:stream x-event:play c-ip:76.242.102.xxx x-sname:4fb77abf-56aa-45cd-8907-11aa2a333cb6 x-name:CADEaudio/2820/MOB_49_0_2
[INFO] [RTMPConnectionExecutor-1] org.red5.server.stream.StreamService - closeStream  stream id: 1 connection: WAOIKZMBN2YZO
[INFO] [RTMPConnectionExecutor-1] org.red5.server.stream.StreamService - Stream not found - streamId: 1 connection: WAOIKZMBN2YZO
[INFO] [Red5_Scheduler_Worker-17] maple.classroom.MapleClassroom - W3C x-category:stream x-event:stop c-ip:76.242.102.xxx cs-bytes:3953 sc-bytes:4031 x-sname:4fb77abf-56aa-45cd-8907-11aa2a333cb6
[INFO] [RTMPConnectionExecutor-4] org.red5.server.scope.BasicScope - ClientBroadcastStream already exists: org.red5.server.stream.ClientBroadcastStream@60f07d5c new: org.red5.server.stream.ClientBroadcastStream@60f07d5c
[INFO] [RTMPConnectionExecutor-4] org.red5.server.stream.ClientBroadcastStream - Stream start: CADEaudio/2820/MOB_49_0_2
[INFO] [RTMPConnectionExecutor-4] maple.classroom.MapleClassroom - W3C x-category:stream x-event:record-start c-ip:76.242.102.xxx x-sname:22665dc5-26ea-470a-98b5-0cf9b5894d5c x-file-name:MOB_49_0_2.flv
[WARN] [Red5_Scheduler_Worker-24] org.red5.server.stream.RecordingListener - Exception while pushing to consumer
java.nio.BufferUnderflowException: null
        at java.nio.HeapByteBuffer.get(Unknown Source)
        at org.apache.mina.core.buffer.AbstractIoBuffer.get(AbstractIoBuffer.java:625)
        at org.apache.mina.core.buffer.AbstractIoBuffer.get(AbstractIoBuffer.java:1337)
        at org.red5.server.stream.consumer.ImmutableTag.build(ImmutableTag.java:183)
        at org.red5.server.stream.consumer.FileConsumer$QueuedData.<init>(FileConsumer.java:795)
        at org.red5.server.stream.consumer.FileConsumer.pushMessage(FileConsumer.java:256)
        at org.red5.server.stream.RecordingListener.processQueue(RecordingListener.java:319)
        at org.red5.server.stream.RecordingListener.access$300(RecordingListener.java:57)
        at org.red5.server.stream.RecordingListener$EventQueueJob.execute(RecordingListener.java:383)
        at org.red5.server.scheduling.QuartzSchedulingServiceJob.executeInternal(QuartzSchedulingServiceJob.java:89)
        at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:75)
        at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
        at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)

回答1:

Ok, the original problem is fixed. The issue was in the red5.bat file and the handling of quotes around file paths. I had to put quotes around:

set TOMCAT_OPTS=-Dcatalina.home="%RED5_HOME%"

The RED5_CLASSPATH added its own quotes to the classpath value on the start and end but didn't add them to the individual parameters. So, I also had to put "inside" the following statement so each parameter was quoted:

set RED5_CLASSPATH=%RED5_HOME%\red5-service.jar";"%RED5_HOME%\conf;%CLASSPATH%

I have no idea yet what this is going to do when I try to run it as a service, but I'm hoping when 1.0.7 final is released, all will be good. There is the one error but that's another issue and post.