Red5 / red5-server

Red5 Server core
Apache License 2.0
3.34k stars 982 forks source link

Red5 1.0.6 warDeployer ClassNotFoundException FilterDef #123

Closed jeromeheissler closed 8 years ago

jeromeheissler commented 8 years ago

Hi,

I would like to use the wardeployer to deploy my application. But when it parse my web.xml configuration it throw an exception :

ERROR] [Red5_Scheduler_Worker-2] org.apache.tomcat.util.digester.Digester - Begin event threw exception
java.lang.ClassNotFoundException: org.apache.tomcat.util.descriptor.web.FilterDef
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1332) ~[tomcat-embed-core.jar:8.0.26]
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1166) ~[tomcat-embed-core.jar:8.0.26]
    at org.apache.tomcat.util.digester.ObjectCreateRule.begin(ObjectCreateRule.java:116) ~[tomcat-embed-core.jar:8.0.26]
       ...
[ERROR] [Red5_Scheduler_Worker-2] org.apache.tomcat.util.descriptor.web.WebXmlParser - Parse error in application web.xml file at file:/opt/red5-server-1.0.6/webapps/test/WEB-INF/web.xml
org.xml.sax.SAXParseException: Error at (32, 13) : org.apache.tomcat.util.descriptor.web.FilterDef
    at org.apache.tomcat.util.digester.Digester.createSAXException(Digester.java:1908) ~[tomcat-embed-core.jar:8.0.26]
    at org.apache.tomcat.util.digester.Digester.createSAXException(Digester.java:1940) ~[tomcat-embed-core.jar:8.0.26]
    at org.apache.tomcat.util.digester.Digester.startElement(Digester.java:1181) ~[tomcat-embed-core.jar:8.0.26]
Caused by: java.lang.ClassNotFoundException: org.apache.tomcat.util.descriptor.web.FilterDef
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1332) ~[tomcat-embed-core.jar:8.0.26]
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1166) ~[tomcat-embed-core.jar:8.0.26]

My web.xml is :

<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app
    xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
    version="2.4">

    <!--
   The display-name element contains a short name that 
   is intended to be displayed by tools. The display 
   name need not be unique.
   -->
   <display-name>test</display-name>

   <!--
   The context-param element contains the declaration of a web
   application's servlet context initialization parameters.
   -->    
   <context-param>
      <param-name>webAppRootKey</param-name>
      <param-value>/test</param-value>
   </context-param>

    <listener>
        <listener-class>org.red5.logging.ContextLoggingListener</listener-class>
    </listener>

    <filter>
        <filter-name>LoggerContextFilter</filter-name>
        <filter-class>org.red5.logging.LoggerContextFilter</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>LoggerContextFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <servlet>
        <servlet-name>gateway</servlet-name>
        <servlet-class>org.red5.server.net.servlet.AMFGatewayServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>gateway</servlet-name>
        <url-pattern>/gateway</url-pattern>
    </servlet-mapping>

    <servlet>
        <servlet-name>rtmpt</servlet-name>
        <servlet-class>org.red5.server.net.rtmpt.RTMPTServlet</servlet-class>
        <load-on-startup>2</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>rtmpt</servlet-name>
        <url-pattern>/open/*</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>rtmpt</servlet-name>
        <url-pattern>/idle/*</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>rtmpt</servlet-name>
        <url-pattern>/send/*</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>rtmpt</servlet-name>
        <url-pattern>/close/*</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>rtmpt</servlet-name>
        <url-pattern>/fcs/*</url-pattern>
    </servlet-mapping>

    <security-constraint>
        <web-resource-collection>
            <web-resource-name>Forbidden</web-resource-name>
            <url-pattern>/WEB-INF/*</url-pattern>
        </web-resource-collection>
        <auth-constraint />
    </security-constraint>
    <security-constraint>
        <web-resource-collection>
            <web-resource-name>Forbidden</web-resource-name>
            <url-pattern>/persistence/*</url-pattern>
        </web-resource-collection>
        <auth-constraint />
    </security-constraint>
    <security-constraint>
        <web-resource-collection>
            <web-resource-name>Forbidden</web-resource-name>
            <url-pattern>/streams/*</url-pattern>
        </web-resource-collection>
        <auth-constraint />
    </security-constraint>

</web-app>

If I unzip manually the war file, the application start normally. Does anyone know why it happens ?

jeromeheissler commented 8 years ago

I have the same issue with project oflaDemo from https://github.com/Red5/red5-examples. I do a mvn package then copy the war to the webapps directory and the war deployer throw the same exception :

[ERROR] [Red5_Scheduler_Worker-2] org.apache.tomcat.util.digester.Digester - Begin event threw exception
java.lang.ClassNotFoundException: org.apache.tomcat.util.descriptor.web.FilterDef
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1332) ~[tomcat-embed-core.jar:8.0.26]
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1166) ~[tomcat-embed-core.jar:8.0.26]
       ...
[ERROR] [Red5_Scheduler_Worker-2] org.apache.tomcat.util.descriptor.web.WebXmlParser - Parse error in application web.xml file at file:/opt/red5-server-1.0.6/webapps/oflaDemo/WEB-INF/web.xml
org.xml.sax.SAXParseException: Error at (19, 13) : org.apache.tomcat.util.descriptor.web.FilterDef

For more information i'm working on a mac with java 1.8.0_60

tyfly commented 8 years ago

same error here with the oflaDemo.

SEVERE: Parse error in application web.xml file at file:/opt/red5/webapps/oflaDemo/WEB-INF/web.xml
org.xml.sax.SAXParseException; systemId: file:/opt/red5/webapps/oflaDemo/WEB-INF/web.xml; lineNumber: 19; columnNumber: 13; Error at (19, 13) : org.apache.tomcat.util.descriptor.web.FilterDef
        at org.apache.tomcat.util.digester.Digester.createSAXException(Digester.java:1908)
        at org.apache.tomcat.util.digester.Digester.createSAXException(Digester.java:1940)
        at org.apache.tomcat.util.digester.Digester.startElement(Digester.java:1181)

Throws exception when i am going to install oflaDemo from the webpanel installer.

Tried all the other example apps. Can't get any of them properly installed. WebXMLParser throws SAXParseException on everyone of them.

red5 is installed on centos 7 with jdk 1.8.0_66.

mondain commented 8 years ago

I found the missing class in the regular tomcat archive; it is in the tomcat-util-scan.jar which is not part of the embeded package. You would be able to resolve this issue by adding the jar.

The-Crocop commented 8 years ago

added the jar - still not working

mondain commented 8 years ago

For all that have experienced this issue, does it only occur when the WarDeployer deploys your war, or does it happen every time your app starts up?

The-Crocop commented 8 years ago

happens when I build the war and then deploy it manually too

tyfly commented 8 years ago

It happens always when the WarDeployer deploys. This doesn't happen in 1.04.

mikesheppard commented 8 years ago

Same issue here. Worked in 1.0.4, testing 1.0.6 and experiencing this.

Any solutions?

mondain commented 8 years ago

Make sure you're using Spring 4.2.4; they fixed a classloader issue, it may be the same one we saw.

On Wed, Feb 10, 2016 at 7:11 PM Mike notifications@github.com wrote:

Same issue here. Worked in 1.0.4, testing 1.0.6 and experiencing this.

Any solutions?

— Reply to this email directly or view it on GitHub https://github.com/Red5/red5-server/issues/123#issuecomment-182645880.

mailsurfie commented 8 years ago

tried the above provided methods, all failed. are there any other suggestions?

mondain commented 8 years ago

Is this still an issue with the latest 1.0.7-M8 release? I can't replicate the issue.

mailsurfie commented 8 years ago

Well, expecting stable release of 1.0.7, thanks a lot

mondain commented 8 years ago

1.0.7-M8 is looking pretty good in our testing so far over at Red5 Pro; All of these M8 pre-releases are helping us get to our actual release, which should be very soon.

gongminrui commented 8 years ago

This occurs at deployment time, as long as there will not be an exception after deploying start

ncdanh90 commented 8 years ago

Hi, I has had the same error. The Red5 server has started after that I deploy a war package. It's version 1.0.7 Release latest.

[INFO] [pool-5-thread-1] org.red5.server.scope.WebScope - Set server [Server@511db9fbmap['/chat' -> 'default', '/vod' -> 'default', '/' -> 'default']] [INFO] [pool-5-thread-1] org.red5.server.Server - Add mapping global: default host: localhost context: installer [INFO] [pool-5-thread-1] org.red5.server.Server - Add mapping global: default host: localhost:5080 context: installer [INFO] [pool-5-thread-1] org.red5.server.service.Installer - Installer service created [INFO] [pool-4-thread-1] org.red5.server.tomcat.WarDeployer - Deploy wars with app start [INFO] [pool-4-thread-1] org.red5.server.tomcat.TomcatLoader - Starting Tomcat - Web application [INFO] [pool-4-thread-1] org.red5.server.tomcat.TomcatLoader - Application root: d:/red5/dev/red5-server-1.0.7-RELEASE/red5-server/webapps Aug 12, 2016 4:57:09 PM org.apache.tomcat.util.digester.Digester endElement SEVERE: End event threw exception java.lang.ClassNotFoundException: org.apache.tomcat.util.descriptor.web.ServletDef at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1305) at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1139) at org.apache.tomcat.util.IntrospectionUtils.callMethod1(IntrospectionUtils.java:359) at org.apache.tomcat.util.digester.SetNextRule.end(SetNextRule.java:145) at org.apache.tomcat.util.digester.Digester.endElement(Digester.java:956) at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source) at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1451) at org.apache.tomcat.util.descriptor.web.WebXmlParser.parseWebXml(WebXmlParser.java:120) at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1115) at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:779) at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:306) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:95) at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5150) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717) at org.red5.server.tomcat.EmbeddedTomcat.addWebapp(EmbeddedTomcat.java:52)

If I restart server, it's deploy ok.

I'm using Red5 version 1.0,5. It doesn't has that error.

Regards

ncdanh90 commented 8 years ago

I have had a solution. I only reset classLoader in EmbeddedTomcat class

Old code: public Context addWebapp(Host host, String contextPath, String docBase, ContextConfig config) { Context ctx = createContext(host, contextPath); ctx.setPath(contextPath); ctx.setDocBase(docBase); ctx.addLifecycleListener(new DefaultWebXmlListener()); ctx.setConfigFile(getWebappConfigFile(docBase, contextPath)); ctx.addLifecycleListener(config); config.setDefaultWebXml(noDefaultWebXmlPath()); if (host == null) { getHost().addChild(ctx); } else { host.addChild(ctx); } return ctx; }

New code:

public Context addWebapp(Host host, String contextPath, String docBase, ContextConfig config) { Context ctx = createContext(host, contextPath); ctx.setPath(contextPath); ctx.setDocBase(docBase); ctx.addLifecycleListener(new DefaultWebXmlListener()); ctx.setConfigFile(getWebappConfigFile(docBase, contextPath)); ctx.addLifecycleListener(config); config.setDefaultWebXml(noDefaultWebXmlPath()); if (host == null) { host = getHost(); } // reset ParentClassLoader if(!host.getParentClassLoader().equals(Thread.currentThread().getContextClassLoader())) { host.setParentClassLoader(Thread.currentThread().getContextClassLoader()); } host.addChild(ctx); return ctx; }

Rebuild red5 tomcat plugin and replace the old lib (red5-server\plugins\tomcatplugin-1.12.jar) And it work.

I built a file jar at: https://drive.google.com/file/d/0ByNfPmtze2FjWk1EQjJEaWM4dkk/view?usp=sharing

mondain commented 8 years ago

Thanks for the patch @ncdanh90 it'll be in tomcatplugin 1.14