Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 4722 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Does anyone know how to load the ant.jar classes dynamically rather than have to put them in the classpath for each machine you want to use them on??

Or can anyone explain WHY they need to be there ( same as mysql-connector or sqlitejdbc)???

  • 1 month later...
  • Newbies
Posted

I think that I'm having the same problem. When running this code:

def ant = new AntBuilder();

ant.unzip( src, dest, overwrite:"true");

I get:

java.lang.NoClassDefFoundError: org/apache/tools/ant/BuildException

I've uploaded ant.jar and ant-launcher.jar, and checked them under the 'Jars' tab.

I don't have the option of putting these classes into the classpath, since this if for a runtime.

I'm on ScriptMaster 4.124, FMPA 11.0v4, Mac OS 10.6.8, and Ant 1.8.2

Any help or advice is appreciated

Roger

Posted

Our plugins start the JVM and set the classpath (using command line), this likely overrides whatever is set using the environment variables.

You can however use the extensions folder:

/Library/Java/Extensions
 or 
C:Program Filesjre6libext

on Windows

  • Newbies
Posted

Thank for your quick reply Valentin, but I'm still at a loss as to what to do here.

As I mentioned, I'm using ScriptMaster to build a plugin for a runtime solution. I'd rather stay away from altering the users' systems.

According to what I've read I think that what I'm trying to do should be supported:

1) Load the .jar files into the scriptmaster file with "Add"

2) Create a new module

3) Enter the goovy code

4) Select the jars under the Jars tab

5) Register

6) Run

As far as I know, ant.jar and ant-launcher.jar are the only jars required, and they load without problems in ScriptMaster.

Can you tell me how to avoid "java.lang.NoClassDefFoundError?"

Thanks!

Roger

  • Newbies
Posted

Here's the stack trace:

java.lang.NoClassDefFoundError: org/apache/tools/ant/BuildException

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

at java.lang.Class.forName(Class.java:169)

at Script1.class$(Script1.groovy)

at Script1.$get$$class$groovy$util$AntBuilder(Script1.groovy)

at Script1.run(Script1.groovy:3)

at groovy.lang.GroovyShell.evaluate(GroovyShell.java:580)

at groovy.lang.GroovyShell.evaluate(GroovyShell.java:618)

at groovy.lang.GroovyShell.evaluate(GroovyShell.java:589)

at com.prosc.beanshell.BeanShellModel.evaluateGroovy(BeanShellModel.java:162)

at com.prosc.beanshell.BeanShellPlugin.EvaluateGroovy(BeanShellPlugin.java:594)

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 com.prosc.fmkit.StaticFunction.invoke(StaticFunction.java:230)

at com.prosc.fmkit.Plugin.invokeFunction(Plugin.java:337)

at com.prosc.fmkit.RegisterablePlugin.invokeFunction(RegisterablePlugin.java:79)

at com.prosc.fmkit.Plugin.invokeFunctionNoErrors(Plugin.java:318)

at com.prosc.fmkit.PluginBridge$3.run(PluginBridge.java:1041)

at com.prosc.fmkit.PluginBridge$5.run(PluginBridge.java:1137)

at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199)

at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:677)

at java.awt.EventQueue.access$000(EventQueue.java:85)

at java.awt.EventQueue$1.run(EventQueue.java:638)

at java.awt.EventQueue$1.run(EventQueue.java:636)

at java.security.AccessController.doPrivileged(Native Method)

at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)

at java.awt.EventQueue.dispatchEvent(EventQueue.java:647)

at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)

at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)

at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

Caused by: java.lang.ClassNotFoundException: org.apache.tools.ant.BuildException

at java.net.URLClassLoader$1.run(URLClassLoader.java:202)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(URLClassLoader.java:190)

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

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

... 34 more

and here is the code:

import org.apache.tools.ant.*;

def ant = new AntBuilder(); // create an antbuilder

ant.unzip(src:"$src", dest:"$dest", overwrite:"true" );

The jars that are loaded are

Ant.jar

Ant-Launcher.jar

Thanks for looking at it Valentin.

Posted

This is not very straight forward. AntBuilder is a Groovy class and it basically expects that ant.jar and ant-launcher.jar are on the classpath, but ScriptMaster (or one of our plugins that happens to launch before ScriptMaster) sets the classpath. We wrote our own class loader to load classes dynamically that's used by SMLoadJar function, which is used by the ScriptMaster.fp7 file. And I assume that Groovy or Ant use a different class loading or classpath inspection mechanism.

Bottom line, you can get around this by adding the jars to the Java extensions folder

You can however use the extensions folder:

/Library/Java/Extensions

or

C:Program Filesjre6libext

on Windows

Also, you need to use a recent version of Ant, ant 1.6.1 did not work for me, but ant 1.8.2 did. you can download it here: http://ant.apache.org/bindownload.cgi

  • Newbies
Posted

Thanks for looking into this for me Valentin.

Bottom line for me then is that this won't work in a Runtime situation.

Any way for ScriptMaster users to know in advance which classes can be loaded by ScriptMaster and which can't?

Thanks very much for your time.

This topic is 4722 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.