Your classpath does not include Commons Logging, hence the NoClassDefFoundError exception. Note that as written, your batch file is overwriting any classpath you may otherwise have had before that... if your intent was to add to the classpath, you need to add %classpath%; either at the beginning or end of what you have now. If that's not what you meant to do, add the JCL JAR to the classpath in the batch file and that exception should go away.

Frank

--
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM/Yahoo: fzammetti
MSN: [EMAIL PROTECTED]
Author of "Practical Ajax Projects With Java Technology"
 (2006, Apress, ISBN 1-59059-695-1)
and "JavaScript, DOM Scripting and Ajax Projects"
 (2007, Apress, ISBN 1-59059-816-4)
Java Web Parts - http://javawebparts.sourceforge.net
 Supplying the wheel, so you don't have to reinvent it!

Session Mwamufiya wrote:
I'm sorry to be dense about this, but it's not working for me.  Here is what
I've done:

I moved my build.bat file to the root level, and am only using one file to
build the code, the test, and run the test.  This is the content of
build.bat:

@echo off
set
CLASSPATH=WEB-INF\lib\xwork-2.0.1.jar;WEB-INF\lib\junit-4.3.1.jar;WEB-INF\cl
asses;WEB-INF\src\test

javac WEB-INF\src\java\*.java -d WEB-INF\classes

javac WEB-INF\src\test\*.java -d WEB-INF\classes

java helloworld.HelloWorldTest


I modified my HelloWorldTest.java file as follows according to JUnit.org:

package helloworld;

import junit.framework.TestCase;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;
import org.junit.*;

public class HelloWorldTest extends TestCase {

  @Test
  public void testHelloWorld() throws Exception {

    HelloWorld hello_world = new HelloWorld();
    String result = hello_world.execute();

    assertTrue("Expected a success result!",
      ActionSupport.SUCCESS.equals(result));

    assertTrue("Expected the default message!",
      HelloWorld.MESSAGE.equals(hello_world.getMessage()));
    }

  public static void main(String args[]) {
    org.junit.runner.JUnitCore.main("helloworld.HelloWorldTest");
    }
}


The output I get is:
java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
        at
com.opensymphony.xwork2.ActionSupport.<clinit>(ActionSupport.java:22)

        at helloworld.HelloWorldTest.testHelloWorld(HelloWorldTest.java:13)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at junit.framework.TestCase.runTest(TestCase.java:168)
        at junit.framework.TestCase.runBare(TestCase.java:134)
        at junit.framework.TestResult$1.protect(TestResult.java:110)
        at junit.framework.TestResult.runProtected(TestResult.java:128)
        at junit.framework.TestResult.run(TestResult.java:113)
        at junit.framework.TestCase.run(TestCase.java:124)
        at junit.framework.TestSuite.runTest(TestSuite.java:232)
        at junit.framework.TestSuite.run(TestSuite.java:227)
        at
org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.
java:76)
        at
org.junit.internal.runners.CompositeRunner.run(CompositeRunner.java:2
9)
        at org.junit.runner.JUnitCore.run(JUnitCore.java:130)
        at org.junit.runner.JUnitCore.run(JUnitCore.java:109)
        at org.junit.runner.JUnitCore.run(JUnitCore.java:100)
        at org.junit.runner.JUnitCore.runMain(JUnitCore.java:81)
        at org.junit.runner.JUnitCore.main(JUnitCore.java:44)
        at helloworld.HelloWorldTest.main(HelloWorldTest.java:24)

FAILURES!!!
Tests run: 1,  Failures: 1

Anything apparently wrong in what I'm doing?

Session A. Mwamufiya
Carnegie Mellon University
MBA | Tepper School of Business
MSE (software eng.) | School of Computer Science
T: (412) 508-5455 | [EMAIL PROTECTED]

-----Original Message-----
From: Dave Newton [mailto:[EMAIL PROTECTED] Sent: Saturday, June 09, 2007 4:29 PM
To: Struts Users Mailing List
Subject: RE: running the test in the HelloWorld tutorial

--- Session Mwamufiya <[EMAIL PROTECTED]> wrote:
- WEB-INF/scr/Test: my test java files, including
HelloWorldTest.java; as
well as the compiled class files for test java files
- WEB-INF/classes: contains struts.xml
- WEB-INF/classes/helloworld: the compiled class
files for the regular java
files

I'm running the test from "WEB-INF/scr/Test" where
both
"HelloWorldTest.java" and "HelloWorldTest.class" are
located.

You still need to add the directory containing the
test classes to your CLASSPATH.

I would also recommend running all that kind of stuff
from the root directory of the project; that may
better prepare you for using Ant or Maven in the
future.

I'm assuming the repetition of "scr" above (as opposed
to "src") is just an... oddly repetitive typo. I'd
also name the "Test" directory "test" (all
lower-case).

d.



____________________________________________________________________________
________
Boardwalk for $500? In 2007? Ha! Play Monopoly Here and Now (it's updated
for today's economy) at Yahoo! Games.
http://get.games.yahoo.com/proddesc?gamekey=monopolyherenow
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]








---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to