How do I use a Groovy scriptFile?

  • 1
  • Question
  • Updated 6 years ago
I am trying to use a Groovy script and having problems.

Here is where I am declaring it in my proxy.

Here is the error I am getting. I looked around for a Groovy file
example and searched the forums and couldn't find anything. It looks
like it thinks I have a js file. Any help would be appreciated.

----------------------------------------------------------------------------------------------

2011-03-04 09:52:50,286 [-] [main] ERROR Sequence Error compiling script for sequence : mail_proxy_inSequence as a script of : js from file : conf/mediation/src/java/gov/ok/afis/storeandforward/esb/IncomingMail.groovy
javax.script.ScriptException: sun.org.mozilla.javascript.internal.EvaluatorException: missing ; before statement (#1)
at com.sun.script.javascript.RhinoScriptEngine.compile(RhinoScriptEngine.java:272)
at org.adroitlogic.ultraesb.core.Sequence.prepareScriptFromFile(Sequence.java:469)
at org.adroitlogic.ultraesb.core.Sequence.afterPropertiesSet(Sequence.java:181)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:219)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:122)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1245)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:308)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:297)
at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:941)
at org.adroitlogic.ultraesb.core.ConfigurationImpl.startConfigurationElements(ConfigurationImpl.java:473)
at org.adroitlogic.ultraesb.core.ConfigurationImpl.afterPropertiesSet(ConfigurationImpl.java:576)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:880)
at org.adroitlogic.ultraesb.core.config.ConfigurationElement.setApplicationContext(ConfigurationElement.java:103)
at org.springframework.context.support.ApplicationContextAwareProcessor.postProcessBeforeInitialization(ApplicationContextAwareProcessor.java:70)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:350)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1331)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
at org.adroitlogic.ultraesb.ServerManager.start(ServerManager.java:100)
at org.adroitlogic.ultraesb.UltraServer.(UltraServer.java:98)
at org.adroitlogic.ultraesb.UltraServer.main(UltraServer.java:75)
Caused by: sun.org.mozilla.javascript.internal.EvaluatorException: missing ; before statement (#1)
at sun.org.mozilla.javascript.internal.DefaultErrorReporter.runtimeError(DefaultErrorReporter.java:84)
at sun.org.mozilla.javascript.internal.DefaultErrorReporter.error(DefaultErrorReporter.java:71)
at sun.org.mozilla.javascript.internal.Parser.addError(Parser.java:111)
at sun.org.mozilla.javascript.internal.Parser.reportError(Parser.java:117)
at sun.org.mozilla.javascript.internal.Parser.statementHelper(Parser.java:1160)
at sun.org.mozilla.javascript.internal.Parser.statement(Parser.java:608)
at sun.org.mozilla.javascript.internal.Parser.parse(Parser.java:340)
at sun.org.mozilla.javascript.internal.Parser.parse(Parser.java:299)
at sun.org.mozilla.javascript.internal.Context.compileImpl(Context.java:2196)
at sun.org.mozilla.javascript.internal.Context.compileReader(Context.java:1252)
at sun.org.mozilla.javascript.internal.Context.compileReader(Context.java:1224)
at com.sun.script.javascript.RhinoScriptEngine.compile(RhinoScriptEngine.java:268)
... 57 more
2011-03-04 09:52:50,305 [-] [main] ERROR ServerManager Error starting the UltraESB
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mail' defined in file [C:\ultraesb-1.3.0\conf\ultra-root.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ultra-config' defined in file [C:\ultraesb-1.3.0\conf\ultra-root.xml]: Invocation of init method failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mail-proxy': Cannot create inner bean '(inner bean)' of type [org.adroitlogic.ultraesb.core.Sequence] while setting bean property 'inSequence'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#4': Invocation of init method failed; nested exception is org.adroitlogic.ultraesb.core.config.JavaSequencePreparationException: Error compiling script for sequence : mail_proxy_inSequence as a script of : js from file : conf/mediation/src/java/gov/ok/afis/storeandforward/esb/IncomingMail.groovy
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:480)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
at org.adroitlogic.ultraesb.ServerManager.start(ServerManager.java:100)
at org.adroitlogic.ultraesb.UltraServer.(UltraServer.java:98)
at org.adroitlogic.ultraesb.UltraServer.main(UltraServer.java:75)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ultra-config' defined in file [C:\ultraesb-1.3.0\conf\ultra-root.xml]: Invocation of init method failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mail-proxy': Cannot create inner bean '(inner bean)' of type [org.adroitlogic.ultraesb.core.Sequence] while setting bean property 'inSequence'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#4': Invocation of init method failed; nested exception is org.adroitlogic.ultraesb.core.config.JavaSequencePreparationException: Error compiling script for sequence : mail_proxy_inSequence as a script of : js from file : conf/mediation/src/java/gov/ok/afis/storeandforward/esb/IncomingMail.groovy
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:880)
at org.adroitlogic.ultraesb.core.config.ConfigurationElement.setApplicationContext(ConfigurationElement.java:103)
at org.springframework.context.support.ApplicationContextAwareProcessor.postProcessBeforeInitialization(ApplicationContextAwareProcessor.java:70)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:350)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1331)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
... 14 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mail-proxy': Cannot create inner bean '(inner bean)' of type [org.adroitlogic.ultraesb.core.Sequence] while setting bean property 'inSequence'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#4': Invocation of init method failed; nested exception is org.adroitlogic.ultraesb.core.config.JavaSequencePreparationException: Error compiling script for sequence : mail_proxy_inSequence as a script of : js from file : conf/mediation/src/java/gov/ok/afis/storeandforward/esb/IncomingMail.groovy
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:230)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:122)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1245)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:308)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:297)
at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:941)
at org.adroitlogic.ultraesb.core.ConfigurationImpl.startConfigurationElements(ConfigurationImpl.java:473)
at org.adroitlogic.ultraesb.core.ConfigurationImpl.afterPropertiesSet(ConfigurationImpl.java:576)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
... 29 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#4': Invocation of init method failed; nested exception is org.adroitlogic.ultraesb.core.config.JavaSequencePreparationException: Error compiling script for sequence : mail_proxy_inSequence as a script of : js from file : conf/mediation/src/java/gov/ok/afis/storeandforward/esb/IncomingMail.groovy
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:219)
... 48 more
Caused by: org.adroitlogic.ultraesb.core.config.JavaSequencePreparationException: Error compiling script for sequence : mail_proxy_inSequence as a script of : js from file : conf/mediation/src/java/gov/ok/afis/storeandforward/esb/IncomingMail.groovy
at org.adroitlogic.ultraesb.core.Sequence.handleCompilationException(Sequence.java:514)
at org.adroitlogic.ultraesb.core.Sequence.prepareScriptFromFile(Sequence.java:476)
at org.adroitlogic.ultraesb.core.Sequence.afterPropertiesSet(Sequence.java:181)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
... 53 more
Caused by: javax.script.ScriptException: sun.org.mozilla.javascript.internal.EvaluatorException: missing ; before statement (#1)
at com.sun.script.javascript.RhinoScriptEngine.compile(RhinoScriptEngine.java:272)
at org.adroitlogic.ultraesb.core.Sequence.prepareScriptFromFile(Sequence.java:469)
... 56 more
Caused by: sun.org.mozilla.javascript.internal.EvaluatorException: missing ; before statement (#1)
at sun.org.mozilla.javascript.internal.DefaultErrorReporter.runtimeError(DefaultErrorReporter.java:84)
at sun.org.mozilla.javascript.internal.DefaultErrorReporter.error(DefaultErrorReporter.java:71)
at sun.org.mozilla.javascript.internal.Parser.addError(Parser.java:111)
at sun.org.mozilla.javascript.internal.Parser.reportError(Parser.java:117)
at sun.org.mozilla.javascript.internal.Parser.statementHelper(Parser.java:1160)
at sun.org.mozilla.javascript.internal.Parser.statement(Parser.java:608)
at sun.org.mozilla.javascript.internal.Parser.parse(Parser.java:340)
at sun.org.mozilla.javascript.internal.Parser.parse(Parser.java:299)
at sun.org.mozilla.javascript.internal.Context.compileImpl(Context.java:2196)
at sun.org.mozilla.javascript.internal.Context.compileReader(Context.java:1252)
at sun.org.mozilla.javascript.internal.Context.compileReader(Context.java:1224)
at com.sun.script.javascript.RhinoScriptEngine.compile(RhinoScriptEngine.java:268)
... 57 more
Photo of Brian A

Brian A

  • 13 Posts
  • 1 Reply Like

Posted 6 years ago

  • 1
Photo of Asankha Perera

Asankha Perera, Founder and CTO

  • 384 Posts
  • 23 Reply Likes
Thanks for raising this question.. We will include a Groovy sample into our next release. The <u:script> and <u:scriptFile> tags accept an optional attribute "language" and this should show up if you've setup the IDE and use its context sensitive help. To invoke Groovy, you should specify the scripting language short name [1] as "groovy" as follows:

<u:script language="groovy"><![CDATA[
println "hello, world"
]]></u:script>

OR

<u:scriptFile filename="/tmp/test.groovy" language="groovy"/>

For an example with Groovy 1.7.5, I also needed to place the following JAR files into the lib/custom directory. You may need to add additional JARs if your code requires any other Groovy features etc.
antlr-2.7.7.jar
asm-3.2.jar
groovy-1.7.5.jar

[1] http://download.oracle.com/javase/6/d...
Photo of Brian A

Brian A

  • 13 Posts
  • 1 Reply Like
Thanks for the quick answer Asankha. That worked perfectly. Your support is awesome.