FAQ  •  Register  •  Login

Groovy Console Help Needed

<<

jhb50

DLNA master

Posts: 2843

Joined: Thu Jun 30, 2011 9:32 pm

Post Wed Nov 02, 2011 8:40 pm

Groovy Console Help Needed

As a test I have loaded the latest CNN.groovy into the console, and set CLASSPATH=C:\Program Files (x86)\Serviio\lib\serviio.jar

When executed I keep getting this error even though org.slf4j.Logger is in the serviio.jar.

I also added serviio.jar to the groovy lib in case it was a classpath problem but still the same problem.

Any ideas?

  Code:
 
(First part of cnn.groovy omitted) 
groovy>         static void main(args) {
groovy>         // this is just to test
groovy>         CNN extractor = new CNN()
groovy>         
groovy>         assert extractor.extractorMatches( new URL("http://rss.cnn.com/rss/edition.rss") )
groovy>         assert !extractor.extractorMatches( new URL("http://google.com/feeds/api/standardfeeds/top_rated?time=today") )
groovy>         
groovy>         Map videoLinks = ['default': new URL('http://edition.cnn.com/video/data/3.0/video/business/2011/11/01/intv-greece-market-reax.cnn/index.xml')]
groovy>         ContentURLContainer result = extractor.extractUrl(videoLinks, PreferredQuality.MEDIUM)
groovy>         println "Result: $result"         
groovy>     }
groovy> }
 
Exception thrown
Nov 2, 2011 4:32:14 PM org.codehaus.groovy.runtime.StackTraceUtils sanitize

WARNING: Sanitizing stacktrace:

java.lang.ClassNotFoundException: org.slf4j.Logger

   at org.codehaus.groovy.tools.RootLoader.findClass(RootLoader.java:156)

   at java.lang.ClassLoader.loadClass(ClassLoader.java:307)

   at org.codehaus.groovy.tools.RootLoader.loadClass(RootLoader.java:128)

   at java.lang.ClassLoader.loadClass(ClassLoader.java:252)

   at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)

   at java.lang.Class.getDeclaredFields0(Native Method)

   at java.lang.Class.privateGetDeclaredFields(Class.java:2291)

   at java.lang.Class.getDeclaredFields(Class.java:1743)

   at org.codehaus.groovy.vmplugin.v5.Java5.configureClassNode(Java5.java:321)

   at org.codehaus.groovy.ast.ClassNode.lazyClassInit(ClassNode.java:262)

   at org.codehaus.groovy.ast.ClassNode.getUnresolvedSuperClass(ClassNode.java:974)

   at org.codehaus.groovy.ast.ClassNode.getUnresolvedSuperClass(ClassNode.java:969)

   at org.codehaus.groovy.control.ResolveVisitor.checkCyclicInheritence(ResolveVisitor.java:1302)

   at org.codehaus.groovy.control.ResolveVisitor.visitClass(ResolveVisitor.java:1277)

   at org.codehaus.groovy.control.ResolveVisitor.startResolving(ResolveVisitor.java:148)

   at org.codehaus.groovy.control.CompilationUnit$8.call(CompilationUnit.java:601)

   at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:839)

   at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:544)

   at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:493)

   at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:306)

   at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:287)

   at groovy.lang.GroovyShell.parseClass(GroovyShell.java:731)

   at groovy.lang.GroovyShell.run(GroovyShell.java:516)

   at groovy.lang.GroovyShell.run(GroovyShell.java:172)

   at groovy.lang.GroovyShell$run.call(Unknown Source)

   at groovy.ui.Console$_runScriptImpl_closure16.doCall(Console.groovy:924)

   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

   at java.lang.reflect.Method.invoke(Method.java:597)

   at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)

   at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)

   at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272)

   at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:884)

   at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66)

   at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)

   at groovy.ui.Console$_runScriptImpl_closure16.doCall(Console.groovy)

   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

   at java.lang.reflect.Method.invoke(Method.java:597)

   at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)

   at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)

   at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272)

   at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:884)

   at groovy.lang.Closure.call(Closure.java:410)

   at groovy.lang.Closure.call(Closure.java:404)

   at groovy.lang.Closure.run(Closure.java:488)

   at java.lang.Thread.run(Thread.java:619)
Nov 2, 2011 4:32:14 PM org.codehaus.groovy.runtime.StackTraceUtils sanitize

WARNING: Sanitizing stacktrace:

java.lang.NoClassDefFoundError: Lorg/slf4j/Logger;

   at java.lang.Class.getDeclaredFields0(Native Method)

   at java.lang.Class.privateGetDeclaredFields(Class.java:2291)

   at java.lang.Class.getDeclaredFields(Class.java:1743)

   at org.codehaus.groovy.vmplugin.v5.Java5.configureClassNode(Java5.java:321)

   at org.codehaus.groovy.ast.ClassNode.lazyClassInit(ClassNode.java:262)

   at org.codehaus.groovy.ast.ClassNode.getUnresolvedSuperClass(ClassNode.java:974)

   at org.codehaus.groovy.ast.ClassNode.getUnresolvedSuperClass(ClassNode.java:969)

   at org.codehaus.groovy.control.ResolveVisitor.checkCyclicInheritence(ResolveVisitor.java:1302)

   at org.codehaus.groovy.control.ResolveVisitor.visitClass(ResolveVisitor.java:1277)

   at org.codehaus.groovy.control.ResolveVisitor.startResolving(ResolveVisitor.java:148)

   at org.codehaus.groovy.control.CompilationUnit$8.call(CompilationUnit.java:601)

   at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:839)

   at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:544)

   at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:493)

   at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:306)

   at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:287)

   at groovy.lang.GroovyShell.parseClass(GroovyShell.java:731)

   at groovy.lang.GroovyShell.run(GroovyShell.java:516)

   at groovy.lang.GroovyShell.run(GroovyShell.java:172)

   at groovy.lang.GroovyShell$run.call(Unknown Source)

   at groovy.ui.Console$_runScriptImpl_closure16.doCall(Console.groovy:924)

   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

   at java.lang.reflect.Method.invoke(Method.java:597)

   at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)

   at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)

   at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272)

   at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:884)

   at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66)

   at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)

   at groovy.ui.Console$_runScriptImpl_closure16.doCall(Console.groovy)

   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

   at java.lang.reflect.Method.invoke(Method.java:597)

   at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)

   at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)

   at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272)

   at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:884)

   at groovy.lang.Closure.call(Closure.java:410)

   at groovy.lang.Closure.call(Closure.java:404)

   at groovy.lang.Closure.run(Closure.java:488)

   at java.lang.Thread.run(Thread.java:619)

Caused by: java.lang.ClassNotFoundException: org.slf4j.Logger

java.lang.NoClassDefFoundError: Lorg/slf4j/Logger;

Caused by: java.lang.ClassNotFoundException: org.slf4j.Logger
<<

owennewo

Serviio newbie

Posts: 9

Joined: Wed Nov 02, 2011 8:54 pm

Post Wed Nov 02, 2011 10:08 pm

Re: Groovy Console Help Needed

If CNN.groovy is similar to Youtube.groovy then you'll need to put a couple more jars on your classpath, e.g.

set CLASSPATH=C:\Program Files (x86)\Serviio\lib\serviio.jar;C:\Program Files (x86)\Serviio\lib\slf4j-api.jar;C:\Program Files (x86)\Serviio\lib\slf4j-log4j12.jar;C:\Program Files (x86)\Serviio\lib\log4j.jar;

I can't test the above because I'm not developing in windows. On linux I'm using:

groovy -cp lib/serviio.jar:lib/slf4j-api.jar:lib/slf4j-log4j12.jar:lib/log4j.jar S4c.groovy

this runs the static main method in Youtube.groovy which acts like a unit test. This is useful for development as the rss parsing can be tested without running serviio

Owen
<<

jhb50

DLNA master

Posts: 2843

Joined: Thu Jun 30, 2011 9:32 pm

Post Wed Nov 02, 2011 10:29 pm

Re: Groovy Console Help Needed

Thanks Owen. I tried that and still the same problem. I'll try with the youtube groovy after dinner.


===>> Same problem with youtube.groovy
Last edited by jhb50 on Wed Nov 02, 2011 11:08 pm, edited 1 time in total.
<<

jhb50

DLNA master

Posts: 2843

Joined: Thu Jun 30, 2011 9:32 pm

Post Wed Nov 02, 2011 10:56 pm

Re: Groovy Console Help Needed

Tried running a command like you did. It worked: Here's the output.
I'll try with the console. Thanks

  Code:
C:\Users\John>groovy -cp "C:\Program Files (x86)\Serviio\lib\serviio.jar;C:\Prog
ram Files (x86)\Serviio\lib\slf4j-api.jar;C:\Program Files (x86)\Serviio\lib\slf
4j-log4j12.jar;C:\Program Files (x86)\Serviio\lib\log4j.jar" "C:\Program Files (
x86)\Serviio\plugins\CNN.groovy"
Result: ContentURLContainer [fileType=VIDEO, contentUrl=http://cnn-f.akamaihd.ne
t/cnn/big/world/2011/10/20/vo-tripoli-celebrations.cnn_20090223_768x432_1300k.mp
4, thumbnailUrl=http://i2.cdn.turner.com/cnn/dam/assets/111020124415-vo-tripoli-
celebrations-00001115-story-top.jpg, expiresImmediately=false]
<<

jhb50

DLNA master

Posts: 2843

Joined: Thu Jun 30, 2011 9:32 pm

Post Wed Nov 02, 2011 11:53 pm

Re: Groovy Console Help Needed

OK, got the groovy console to work by putting all th jars in groovy lib.
I have no idea why CLASSPATH did not work.
<<

owennewo

Serviio newbie

Posts: 9

Joined: Wed Nov 02, 2011 8:54 pm

Post Thu Nov 03, 2011 10:50 pm

Re: Groovy Console Help Needed

I think my original suggestion didn't work because of the spaces in your path. They will mess things up. I should have suggested it with surrounding quotes

set CLASSPATH="C:\Program Files (x86)\Serviio\lib\serviio.jar;C:\Program Files (x86)\Serviio\lib\slf4j-api.jar;C:\Program Files (x86)\Serviio\lib\slf4j-log4j12.jar;C:\Program Files (x86)\Serviio\lib\log4j.jar;"

using an environment (as above) is no longer recommended, I'd stick with the -cp flag

Owen
<<

jhb50

DLNA master

Posts: 2843

Joined: Thu Jun 30, 2011 9:32 pm

Post Tue Nov 15, 2011 5:32 am

Re: Groovy Console Help Needed

Running same command that worked above with beta 1 and with beta 2 I get this different error, with every groovy... but they all compile fine when loaded in Serviio.

Can anyone help? Is there a new jar dependency?

  Code:
C:\Users\John>groovy -cp "C:\Program Files (x86)\Serviio\lib\serviio.jar;C:\Prog
ram Files (x86)\Serviio\lib\slf4j-api.jar;C:\Program Files (x86)\Serviio\lib\slf
4j-log4j12.jar;C:\Program Files (x86)\Serviio\lib\log4j.jar" "C:\Program Files (
x86)\Serviio\plugins\CNN.groovy"
Caught: java.lang.NoClassDefFoundError: Lorg/restlet/Client;
java.lang.NoClassDefFoundError: Lorg/restlet/Client;
Caused by: java.lang.ClassNotFoundException: org.restlet.Client
<<

kairoh

DLNA master

Posts: 180

Joined: Sun Aug 08, 2010 10:41 am

Location: France

Post Tue Nov 15, 2011 9:29 am

Re: Groovy Console Help Needed

jhb50 wrote:Can anyone help? Is there a new jar dependency?

Not really a new dependency; you need the REST API library : "org.restlet.jar".
About classpath, the simpler is to add everything in the lib directory.
On Windows :
  Code:
@echo off
SETLOCAL enabledelayedexpansion
(...)
set CLASSPATH="."
for %%i in ("%SERVIIO_HOME%\lib\*.jar") do set SERVIIO_CLASSPATH=!SERVIIO_CLASSPATH!;%%i
(...)
groovy -cp "%SERVIIO_CLASSPATH%" XXX

On Unix :
  Code:
#!/bin/sh
(...)
LIB=${SERVIIO_HOME}/lib
SERVIIO_CLASSPATH="."
for jar in `ls -1 ${LIB}/*.jar`; do SERVIIO_CLASSPATH="${SERVIIO_CLASSPATH}:${jar}"; done
(...)
groovy -cp "$SERVIIO_CLASSPATH" XXX
Serviio WebUI console developer : New Homepage | Support | Project | Issues

Samsung UA32C6600 | WinXP / Ubuntu 11.10 | Samsung Galaxy S | Freebox v6
HowTo: Provide supported formats of a device HowTo: Record a new ticket on Bitbucket
HowTo: Provide details of a video file that doesn't play HowTo: Turn on detailed logging

Return to Plugin development

Who is online

Users browsing this forum: No registered users and 7 guests

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.