Re: [Red5] Red5 with Twiiter API?

13 views
Skip to first unread message
Message has been deleted

Trevor Burton

unread,
Apr 26, 2011, 2:33:08 AM4/26/11
to red5in...@googlegroups.com
you appear to have a 'class not found' exception there - so you probably haven't included all the library jars you require in your application. Is the twitter4j lib definately in the /libs folder of the running application?

On Mon, Apr 25, 2011 at 11:29 PM, Iyad A. <i.al...@googlemail.com> wrote:
Hi there,

I was woundering, if a Twitter API (e.g. Twitter4J ) is working with Red5.
I just tried to use Twitter4J in my server application and i get following error.

first line:
Exception in thread "Launcher:/overlayStream" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'web.scope' defined in ServletContext resource [/WEB-INF/red5-web.xml]: Cannot resolve reference to bean 'web.handler' while setting bean property 'handler'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'web.handler' defined in ServletContext resource [/WEB-INF/red5-web.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: twitter4j/TwitterException

It sounds like a configuration issue in Red5...
What needs to be done?

Thank you

bidi




--
---------------------------
Trevor Burton

bidi

unread,
Apr 26, 2011, 4:08:31 AM4/26/11
to red5
the twitter4j core jar is included in eclipse,
I get the error during the server application deploys,
before even starting the client...

I used following code:

Twitter twitter = new TwitterFactory().getInstance();

try {
QueryResult result = twitter.search(new Query("test"));
List<Tweet> tweets = result.getTweets();
for (Tweet tweet : tweets) {
System.out.println("@" + tweet.getFromUser() + " - " +
tweet.getText());
}
} catch (TwitterException te) {
te.printStackTrace();
System.out.println("Failed to search tweets: " +
te.getMessage());
}


if I just use the first line (Twitter twitter = new
TwitterFactory().getInstance();)
I don't get the error during deploying but following error occures
during runtime:

java.lang.reflect.InvocationTargetException: null
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:
1.6.0_23]
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39) ~[na:1.6.0_23]
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25) ~[na:1.6.0_23]
at java.lang.reflect.Method.invoke(Method.java:597) ~[na:1.6.0_23]
at org.red5.server.service.ServiceInvoker.invoke(ServiceInvoker.java:
200) [red5.jar:na]
at org.red5.server.service.ServiceInvoker.invoke(ServiceInvoker.java:
118) [red5.jar:na]
at org.red5.server.net.rtmp.RTMPHandler.invokeCall(RTMPHandler.java:
163) [red5.jar:na]
at org.red5.server.net.rtmp.RTMPHandler.onInvoke(RTMPHandler.java:
405) [red5.jar:na]
at
org.red5.server.net.rtmp.BaseRTMPHandler.messageReceived(BaseRTMPHandler.java:
139) [red5.jar:na]
at
org.red5.server.net.rtmp.RTMPMinaIoHandler.messageReceived(RTMPMinaIoHandler.java:
198) [red5.jar:na]
at org.apache.mina.core.filterchain.DefaultIoFilterChain
$TailFilter.messageReceived(DefaultIoFilterChain.java:716) [mina-
core-2.0.2.jar:na]
at
org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:
434) [mina-core-2.0.2.jar:na]
at org.apache.mina.core.filterchain.DefaultIoFilterChain.access
$1200(DefaultIoFilterChain.java:46) [mina-core-2.0.2.jar:na]
at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl
$1.messageReceived(DefaultIoFilterChain.java:796) [mina-
core-2.0.2.jar:na]
at org.apache.mina.filter.codec.ProtocolCodecFilter
$ProtocolDecoderOutputImpl.flush(ProtocolCodecFilter.java:427) [mina-
core-2.0.2.jar:na]
at
org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:
245) [mina-core-2.0.2.jar:na]
at
org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:
434) [mina-core-2.0.2.jar:na]
at org.apache.mina.core.filterchain.DefaultIoFilterChain.access
$1200(DefaultIoFilterChain.java:46) [mina-core-2.0.2.jar:na]
at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl
$1.messageReceived(DefaultIoFilterChain.java:796) [mina-
core-2.0.2.jar:na]
at
org.red5.server.net.rtmpe.RTMPEIoFilter.messageReceived(RTMPEIoFilter.java:
116) [red5.jar:na]
at
org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:
434) [mina-core-2.0.2.jar:na]
at org.apache.mina.core.filterchain.DefaultIoFilterChain.access
$1200(DefaultIoFilterChain.java:46) [mina-core-2.0.2.jar:na]
at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl
$1.messageReceived(DefaultIoFilterChain.java:796) [mina-
core-2.0.2.jar:na]
at
org.apache.mina.core.filterchain.IoFilterAdapter.messageReceived(IoFilterAdapter.java:
119) [mina-core-2.0.2.jar:na]
at
org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:
434) [mina-core-2.0.2.jar:na]
at
org.apache.mina.core.filterchain.DefaultIoFilterChain.fireMessageReceived(DefaultIoFilterChain.java:
426) [mina-core-2.0.2.jar:na]
at
org.apache.mina.core.polling.AbstractPollingIoProcessor.read(AbstractPollingIoProcessor.java:
693) [mina-core-2.0.2.jar:na]
at
org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:
646) [mina-core-2.0.2.jar:na]
at
org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:
635) [mina-core-2.0.2.jar:na]
at org.apache.mina.core.polling.AbstractPollingIoProcessor.access
$400(AbstractPollingIoProcessor.java:67) [mina-core-2.0.2.jar:na]
at org.apache.mina.core.polling.AbstractPollingIoProcessor
$Processor.run(AbstractPollingIoProcessor.java:1079) [mina-
core-2.0.2.jar:na]
at
org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:
64) [mina-core-2.0.2.jar:na]
at java.util.concurrent.ThreadPoolExecutor
$Worker.runTask(ThreadPoolExecutor.java:886) [na:1.6.0_23]
at java.util.concurrent.ThreadPoolExecutor
$Worker.run(ThreadPoolExecutor.java:908) [na:1.6.0_23]
at java.lang.Thread.run(Thread.java:662) [na:1.6.0_23]
Caused by: java.lang.NoClassDefFoundError: twitter4j/TwitterFactory
at org.red5.core.Application.loadData(Application.java:75)
~[Application.class:na]
... 35 common frames omitted
Caused by: java.lang.ClassNotFoundException: twitter4j.TwitterFactory
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:
1516) ~[catalina-6.0.26.jar:6.0.26]
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:
1361) ~[catalina-6.0.26.jar:6.0.26]
... 36 common frames omitted

Any idea?

Thanks

Trevor Burton

unread,
Apr 26, 2011, 4:18:46 AM4/26/11
to red5in...@googlegroups.com
the class has to be available at runtime - check that the jar that contains TwitterFactory is present in the /lib directoy of the webapp that's running on the server
--
---------------------------
Trevor Burton

bidi

unread,
Apr 26, 2011, 4:36:38 AM4/26/11
to red5
Thanks, I just moved the twitter4j jar from myProject/libs to
myProject/WebContent/Web-INF/lib
and edit the library path in eclipse. Where is this path given in
red5? and how can I change
the path?

Thanks for that :)

bidi

On Apr 26, 10:18 am, Trevor Burton <worldofpa...@googlemail.com>
wrote:

Trevor Burton

unread,
Apr 26, 2011, 4:43:36 AM4/26/11
to red5in...@googlegroups.com
If you want to have a class available in your webapp it has to be either under WEB-INF/classes (as a compiled class) or under WEB-INF/lib in a .jar file.

You can include jars in the RED5_HOME/lib directory and they'll be available in all webapps but unless you're sure you're need it that way you'd be better to keep them within your webapps.

This isn't something you should be changing.

I think i understand what's happening - you're assuming because it's available to Eclipse it should be available to Red5 - but when Red5 runs it sets up its own classpath and loads classes in a certain way - Eclipse is something different.

Are you using the Red5 Plugin for Eclipse? If so it should be copying those libraries over for you - if not it's probably worth installing and using as it'll save you these sorts of problems.

T
--
---------------------------
Trevor Burton

bidi

unread,
Apr 26, 2011, 5:02:20 AM4/26/11
to red5
OK that is understood. I'm just wondering, because I used
another lib (joda) and it was working without moving it to the WEB-INF
Folder...
The lib was available just by linking it in eclipse.

I am also using the red5 plugin, but it wasn't copying the lib by
itself...
Still i know a little bit more now :) Thanks


On Apr 26, 10:43 am, Trevor Burton <worldofpa...@googlemail.com>
wrote:
Reply all
Reply to author
Forward
0 new messages