1

new to Gate, actually also not old to Java and Eclipse ;) and want to run the first test of setup.

what I have done:

  1. download gate-7.0-build4195-ALL and unzip it to C:\

  2. change enviroment variable CLASSPATH to ".;%JAVA_HOME%\lib;%JAVA_HOME%\lib\tools.jar;C:\gate-7.0-build4195-ALL\bin\gate.jar;C:\gate-7.0-build4195-ALL\lib"

  3. created a new java project in eclipse, and navigate to gate.jar\gate\TestGate.class and run it.

then I get the following error:

Failed to invoke suite(): java.lang.NoClassDefFoundError: org/apache/log4j/Logger
java.lang.reflect.InvocationTargetException
    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     org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestLoader.getTest(JUnit3TestLoader.java:108)
    at     org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestLoader.loadTests(JUnit3TestLoader.java:59)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.NoClassDefFoundError: org/apache/log4j/Logger
    at gate.Gate.<clinit>(Gate.java:83)
    at gate.TestGate.suite(TestGate.java:126)
    ... 10 more
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 12 more

did I miss something?
thank you

Matt
  • 741
  • 1
  • 6
  • 17

2 Answers2

1

You shouldn't set your CLASSPATH environment variable. If you want to use JAR files in an Eclipse project you should add them to your project's build path.

For GATE specifically, you need bin/gate.jar and all the JAR files from lib, but you don't need the lib directory itself on your build path.

Ian Roberts
  • 120,891
  • 16
  • 170
  • 183
  • I see, I just followed the instruction on Gate's site. But it says it cannot find or load main class, when do as you said. – Matt Jun 11 '12 at 13:08
  • I also suggest you look at how the test suite is normally executed from `build.xml` (the `test.gate` target), it relies on the presence of a few system properties in order to run correctly and will probably fail if they aren't set. – Ian Roberts Jun 11 '12 at 13:12
  • But overall you won't gain much from being able to run the test suite, a better way to get started would be to look through some of the track 2 training materials from http://gate.ac.uk/wiki/training-materials-2011.html, in particular my modules 5 and 7, which are designed to get you started programming to the API and writing your own resources. – Ian Roberts Jun 11 '12 at 13:18
0

I am using GATE API in java with netbeans and when I have integrated a test with junit I have had that error. The trick is to build the project without doint the test, once time built you can run the test as normally using GATE.

For example i have got this at the beginning in my test func:

@Test
public void test()
{
        if(false)
        {
            assertEquals(true, true);
            return;
        }

        ...
        Testing GATE

To build the jar without test, you only need to set to true overthere. It seems something about classpath of the jar used by GATE.

dlopezgonzalez
  • 4,217
  • 5
  • 31
  • 42