Red5 and Apache Axis web service client crashes
Jim O'Halloran • January 6, 2010uncategorized
First post in a very long time, but I just wanted to document for the world something I've run into and was stumped by for a while. The solution isn't documented anywhere specifically regarding Red5 and unless you're familiar with the Apache Commons probably isn't obvious.
I'm developing a small Red5 application which allows users of a web site to stream video directly from their webcam to the server where it'll be stored and played back later. My problems began when I wanted to allow only authenticated users to store and playback video, but wanted to keep that logic in my PHP application (which is the primary user interface) rather than the Java code of the Red5 application. No problems, I thought, I'll just use a SOAP web service and have my Java code call the PHP for authentication.
I built a WSDL file and implemented a Proof of Concept soap server in PHP, then I went through the Web Service Client wizard in Eclipse to generate the necessary Java proxy classes. However, whenever I tried to instantiate the locator class the system would throw an Exception at runtime as follows:
Caused by: org.apache.commons.discovery.DiscoveryException: Class org.apache.commons.logging.impl.SLF4JLogFactory does not implement org.apache.commons.logging.LogFactory at org.apache.commons.discovery.tools.ClassUtils.verifyAncestory(ClassUtils.java:180) at org.apache.commons.discovery.tools.SPInterface.verifyAncestory(SPInterface.java:201) at org.apache.commons.discovery.tools.SPInterface.newInstance(SPInterface.java:195) at org.apache.commons.discovery.tools.DiscoverClass.newInstance(DiscoverClass.java:579) at org.apache.commons.discovery.tools.DiscoverSingleton.find(DiscoverSingleton.java:418) at org.apache.commons.discovery.tools.DiscoverSingleton.find(DiscoverSingleton.java:378) at org.apache.axis.components.logger.LogFactory$1.run(LogFactory.java:45) at java.security.AccessController.doPrivileged(Native Method) at org.apache.axis.components.logger.LogFactory.getLogFactory(LogFactory.java:41) at org.apache.axis.components.logger.LogFactory.<clinit>(LogFactory.java:33) ... 51 more
What's happened here is that the LogFactory class provided by theRed5 runtime and that provided in the commons-logging.jar added to your project by the Web Service Client wizard are different versions (see this Apache.org page for more info). The linked page goes into some detail as to how you can fix that with configuration, but being somewhat of a Java n00b, I went for the brute force approach.
My fix is to delete (through Eclipse, so it doesn't come back upon
deployment) the commons-logging.jar file from the project. You find it under
WebContent/WEB-INF/lib in your project. Right click on
and delete the file. I'm not sure why this works, but it seems to force Apache
Commons to use the logging classes within Red5, and everything seems to work with
no adverse consequences. There are probably better solutions, but that's mine!