문제

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

도움이 되었습니까?

해결책

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.

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top