views:

595

answers:

4

Greeting, I'm trying to put some Beanshell script in my Ant build.xml file. I've followed the Ant manual as well as I can but I keep getting "Unable to create javax script engine for beanshell" when I run Ant. Here is the test target I wrote mostly from examples in the Ant manual:

<target name="test-target">
    <script language="beanshell" setbeans="true">
        <classpath>
            <fileset dir="c:\TEMP" includes="*.jar" />
        </classpath>
        System.out.println("Hello world");
    </script>
</target>

My beanshell "bsh-2.0b4.jar" file is on the script task's classpath the way the manual recommended. Hope I have the right file. I'm working in c:\TEMP right now. I've been googling and trying for a while now. Any ideas would be greatly appreciated. Thanks.

+2  A: 

First, you need jsr-engines.zip from here:

https://scripting.dev.java.net/servlets/ProjectDocumentList

Inside, you'll find jsr223/beanshell/build/bsh-engine.jar. Some searching implied that you need to download bsh-2.05b.jar. I found it here:

http://beanshell.org/bsh-2.0b5.jar

The more easily findable bsh-2.0b4.jar also seemed to work, but it printed a message that implied it was experimental.

bkail
Ah that worked! Thanks a ton. I included both files on my task's classpath and it did the trick. I'm curious how you discovered the b5 version. Maybe it's a dev version.
John B.
Lots of searching on Google. I got the impression that beanshell has been abandoned.
bkail
Alas, it appears so.
John B.
A: 

bkail: You're my super hero.

It also works for javascript with ant 1.8 (just get the javascript/build/js-engine.jar instead of the bsh-engine)

Niek b
A: 

The Ant plug-in "org.apache.ant_1.7.0.v200803061910" have all the jar files needed

Supun Sameera
A: 

Configured my Eclipse environment as described by bkail (by having bsh-2.05b.jar and bsh-2.05b.jar on classpath) but having the following exception being thrown by Ant:

test-target:

BUILD FAILED Unable to load a script engine manager (org.apache.bsf.BSFManager or javax.script.ScriptEngineManager)

I'm running it within Eclipse. Eclipse is configured on jdk1.5, but I tried 1.6 as well with the same error.

What could be missing?

Thanks in advance, Simeon

Simeon Leyzerzon