Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Ant and Cactus - classpath issues

 
Juarez Alvares Barbosa Junior
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello there,
We are trying to run in-container tests using Ant and Cactus. As far as we know, the classpath is configured properly.
When we run our build file, the output is as follows:
<error message="TestSampleServlet" type="java.lang.ClassNotFoundException">java.lang.ClassNotFoundException: TestSampleServlet
at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:141)
</error>
The directory in which our test classes are located is included in cactus classpath. The error above doesn't state if this classpath error is occurring in the client or the server.
The interesting point is that when we run our test using a web browser, everything works accordingly.
http://localhost:8080/test/ServletTestRunner?suite=TestSampleServlet
Please could anyone help ?
Thanks a lot !
Juarez Junior
SCPJ2/SCWCD/SCBCD
 
Juarez Alvares Barbosa Junior
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Problem was fixed. Thanks,
Juarez
 
Al Newman
Ranch Hand
Posts: 716
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How?
 
Al Newman
Ranch Hand
Posts: 716
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To answer my own question, as I recall the classloader problem occured because the <cactus> element needed the class file of the cactus test on it's classpath, not merely inside the ear/war file but the actual compiled .class file.
Looking at my changes from 10 days ago it appears as if I added a <pathelement location="${env.target_dir}/build/tmp/cactus-test"/>
statement to the <classpath> subelement of the <cactus> element. This points to the top of the package directory heirarchy for the CactusTest.class file.
That is, if the java file is in
package foo.foo2;
and the actual class file is in ${env.target_dir}/build/tmp/cactus-test/foo/foo2/CactusTest.class
Then the classpath has to have the base dir ${env.target_dir}/build/tmp/cactus-test on it to work. One of the lovely little thorns of Cactus.
Hope this helps.
[ November 21, 2003: Message edited by: Alfred Neumann ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic