Thursday, July 2, 2009

java.lang.NoClassDefFoundError: javax/script/ScriptEngineFactory in Java for Mac OS X 10.5 Update 4

On the uPortal user list Victor Bagley reports an issue:
     [java] Exception in thread "main" java.lang.RuntimeException: Unable to create the specified task:  properties
     [java]     at org.danann.cernunnos.runtime.XmlGrammar.newTask(XmlGrammar.java:118)
     [java]     at org.danann.cernunnos.runtime.ScriptRunner.compileTask(ScriptRunner.java:108)
     [java]     at org.danann.cernunnos.runtime.ScriptRunner.run(ScriptRunner.java:157)
     [java]     at org.danann.cernunnos.runtime.Main.main(Main.java:103)
     [java] Caused by: java.lang.RuntimeException: Unable to create the specified task:  with
     [java]     at org.danann.cernunnos.runtime.XmlGrammar.newTask(XmlGrammar.java:118)
     [java]     at org.danann.cernunnos.AbstractContainerTask.loadSubtasks(AbstractContainerTask.java:94)
     [java]     at org.danann.cernunnos.AbstractContainerTask.init(AbstractContainerTask.java:58)
     [java]     at org.danann.cernunnos.core.PropertiesTask.init(PropertiesTask.java:53)
     [java]     at org.danann.cernunnos.runtime.XmlGrammar.newTask(XmlGrammar.java:114)
     [java]     ... 3 more
     [java] Caused by: java.lang.RuntimeException: Unable to lazyLoad() the specified entry:
     [java]         name=groovy
     [java]         impl=org.danann.cernunnos.script.ScriptPhrase
     [java]     at org.danann.cernunnos.runtime.Entry.lazyLoad(Entry.java:279)
     [java]     at org.danann.cernunnos.runtime.Entry.getType(Entry.java:163)
     [java]     at org.danann.cernunnos.runtime.XmlGrammar.getEntry(XmlGrammar.java:303)
     [java]     at org.danann.cernunnos.runtime.XmlGrammar.newTask(XmlGrammar.java:105)
     [java]     at org.danann.cernunnos.AbstractContainerTask.loadSubtasks(AbstractContainerTask.java:94)
     [java]     at org.danann.cernunnos.AbstractContainerTask.init(AbstractContainerTask.java:58)
     [java]     at org.danann.cernunnos.core.WithTask.init(WithTask.java:65)
     [java]     at org.danann.cernunnos.runtime.XmlGrammar.newTask(XmlGrammar.java:114)
     [java]     ... 7 more
     [java] Caused by: java.lang.RuntimeException: Unable to create the specified phrase:  org.danann.cernunnos.script.ScriptEnginePhrase
     [java]     at org.danann.cernunnos.runtime.XmlGrammar.newPhrase(XmlGrammar.java:207)
     [java]     at org.danann.cernunnos.ReagentType$1.evaluate(ReagentType.java:72)
     [java]     at org.danann.cernunnos.runtime.Entry.lazyLoad(Entry.java:248)
     [java]     ... 14 more
     [java] Caused by: java.lang.RuntimeException: Unable to prepare an EntityConfig based on the specified information:
     [java]         Entity Name:  org.danann.cernunnos.script.ScriptEnginePhrase
     [java]         Source:  /org.danann.cernunnos.runtime.EncloseGrammarTask/entries/entry[62]/content-model/@engine
     [java]     at org.danann.cernunnos.runtime.XmlGrammar.prepareEntryConfig(XmlGrammar.java:409)
     [java]     at org.danann.cernunnos.runtime.XmlGrammar.newPhrase(XmlGrammar.java:200)
     [java]     ... 16 more
     [java] Caused by: java.lang.RuntimeException: Unable to lazyLoad() the specified entry:
     [java]         name=org.danann.cernunnos.script.ScriptEnginePhrase
     [java]         impl=org.danann.cernunnos.script.ScriptEnginePhrase
     [java]     at org.danann.cernunnos.runtime.Entry.lazyLoad(Entry.java:279)
     [java]     at org.danann.cernunnos.runtime.Entry.getFormula(Entry.java:174)
     [java]     at org.danann.cernunnos.runtime.XmlGrammar.prepareEntryConfig(XmlGrammar.java:358)
     [java]     ... 17 more
     [java] Caused by: java.lang.NoClassDefFoundError: javax/script/ScriptEngineFactory
     [java]     at java.lang.ClassLoader.defineClass1(Native Method)
     [java]     at java.lang.ClassLoader.defineClass(ClassLoader.java:675)
     [java]     at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
     [java]     at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
     [java]     at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
     [java]     at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
     [java]     at java.security.AccessController.doPrivileged(Native Method)
     [java]     at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
     [java]     at java.lang.ClassLoader.loadClass(ClassLoader.java:316)
     [java]     at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
     [java]     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:280)
     [java]     at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
     [java]     at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:374)
     [java]     at java.lang.Class.forName0(Native Method)
     [java]     at java.lang.Class.forName(Class.java:242)
     [java]     at sun.misc.Service$LazyIterator.next(Service.java:271)
     [java]     at javax.script.ScriptEngineManager.initEngines(ScriptEngineManager.java:109)
     [java]     at javax.script.ScriptEngineManager.access$000(ScriptEngineManager.java:37)
     [java]     at javax.script.ScriptEngineManager$1.run(ScriptEngineManager.java:80)
     [java]     at java.security.AccessController.doPrivileged(Native Method)
     [java]     at javax.script.ScriptEngineManager.init(ScriptEngineManager.java:78)
     [java]     at javax.script.ScriptEngineManager.(ScriptEngineManager.java:51)
     [java]     at org.danann.cernunnos.script.ScriptEnginePhrase.(ScriptEnginePhrase.java:43)
     [java]     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
     [java]     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
     [java]     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
     [java]     at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
     [java]     at java.lang.Class.newInstance0(Class.java:350)
     [java]     at java.lang.Class.newInstance(Class.java:303)
     [java]     at org.danann.cernunnos.runtime.Entry.lazyLoad(Entry.java:233)
     [java]     ... 19 more

Andrew Gherna provides the solution:

You need to move AppleScriptEngine.jar out of /System/Library/Java/Extensions and into /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/lib/ext. This is because of the scripting that Cernunnos uses.

No comments: