aspose file tools*
The moose likes Ant, Maven and Other Build Tools and the fly likes Ant's junittask and classnotfound exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Ant Watch "Ant New topic
Author

Ant's junittask and classnotfound exception

Jorge Bendahan
Ranch Hand

Joined: Apr 11, 2008
Posts: 82
Hello, i'm calling and Ant script from a Java program, this is a piece of code of the AntCaller class
So after that, every target in the project gets executed, but the junit target that generates a report is saying that the tests failed
java.lang.ClassNotFoundException:xxx
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
. The strange thing is that the same script called from the command line works great, but I need to be able to call it from within the java program. What can i do?
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5772
    
    7

When you run Ant from the command line, it automatically includes every JAR file in the ant_home/lib directory in the classpath. This is in addition to the directories and JARs specified in the classpath property of any given Ant task. Because you are getting a ClassNotFoundException, you are missing one of those JARs or directories in your classpath. Unfortunately, I have no idea where class 'xxx' is located (I assume you replaced the actual class name with 'xxx').


JBoss In Action
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Ant's junittask and classnotfound exception
 
Similar Threads
Clarification on classpaths
[Ant]Does not run java task
Exception in thread "main" NoClassDefFoundError
[Ant] Run a jar file throw java.lang.NoClassDefFoundError: app/main/Main and Could not find the main
NoClassDefFoundError