facebook

Spring, Junit classpathing issue

  1. MyEclipse IDE
  2.  > 
  3. General Development
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #234538 Reply

    Randy
    Member

    Hi,
    – System Setup ——————————-
    Operating System and version: gentoo linux
    Eclipse version: 3.1
    Eclipse build id: I20050627-1435
    Fresh Eclipse install (y/n): y
    If not, was it upgraded to its current version using the update manager?
    Other installed external plugins: subclipse
    Number of plugins in the <eclipse>/plugins directory that begin with org.eclipse.pde.*: 3
    MyEclipse version: 4.0 M1
    Eclipse JDK version: 1.5 (sun)
    Application Server JDK version:
    Are there any exceptions in the Eclipse log file? nope

    If this is a DB related question please answer the following:

    RDBMS vendor and version:
    JDBC driver vendor and version, and access type (thin, type-2, etc):
    Connection URL:
    Eclipse error logs related to com.genuitec.eclipse.sqlexplorer packages:

    – Message Body ——————————-
    Addtional points: source code migrated from a jbuilder project, using svn.

    I have some existing unit tests that extend the spring unit tests. When I rightclick->run->run as junit, I get the following exception:
    Exception in thread “main” java.lang.NoClassDefFoundError: junit/framework/TestCase
    at java.lang.ClassLoader.findBootstrapClass(Native Method)
    at java.lang.ClassLoader.findBootstrapClass0(ClassLoader.java:891)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadSuiteClass(RemoteTestRunner.java:428)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.getTest(RemoteTestRunner.java:380)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:445)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

    1. junit is in my current project path. the junit-3.8.1.jar file is in the projhome/lib, and shows up under the buildpath. Also, if I create a new class, eclipse will autocomplete the import junit. statements with junit options.

    2. If I create a junit test that does not use spring, it works. I’ve added the spring-mock.jar to the Spring ME perspective as suggested in my previous question/post. Everything does complie with no errors now. This code also works in jbuilder, which makes me think it is a spring config issue.

    I’m a bit baffled as to why the classloader barfs on the junit class though. Any thoughts/ideas would be greatly appreciated.

    Also, when is 4.0 M3 going to be released?

    TIA!

    Randy

    Edit: added O/S info.

    #234578 Reply

    Randy
    Member

    I started over on this to generate more data.

    1. I created a new test case (using the New->Junit Test Case option on a simple domain object. This extends junit.framework.TestCase.
    2. one simple test that does a System.out.println”Blah:);
    3 select the new test case, run as -> junit test. works fine.

    I then change the extends TestCase to AbstractDependencyInjectionSpringContextTests, implement the necesary method (getConfigLocations()), and it fails with this (really same as before):
    Exception in thread “main” java.lang.NoClassDefFoundError: junit/framework/TestCase
    at java.lang.ClassLoader.findBootstrapClass(Native Method)
    at java.lang.ClassLoader.findBootstrapClass0(ClassLoader.java:891)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadSuiteClass(RemoteTestRunner.java:428)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.getTest(RemoteTestRunner.java:380)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:445)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

    If I do debug as-> Junit test case, it is in the classloader where it breaks.

    I can replicate at will, just comment out one public class def that implements TestCase, uncomment the one that implments the abstractSpring class and visa versa.

    #234688 Reply

    Randy
    Member

    Just to be consistent, I created a new user and installed eclipse without ME. I created a trivial domain object with one property, and getter/setters. I then rightclick on this new->JUnit test. Instead of TestCase as the class being extended, I use org.springframework.test.AbstractDependencyInjectionSpringContextTests. I then implement the abstract method protected String[] getConfigLocations(). The test works (well it actually gets into the code of the class, but bombs on the getConfigLocations since I don’t actually have a spring config file.

    I then switch users, and create a new project with myeclipse. Repeating the same test, I get the same errors as above, so it appears to be related to myeclipse and the classloader.

    Is anyone else able to actually use the spring unit test class above and get the junit to work with dependancy injection in the myeclipse environment? I am perfectly capable of screwing up a config.

    Tx again. I’m gonna try to think of more stuff I can do to narrow this down. I think I will compare the jars that are included for spring between the ME version and my non-ME version, see if that may be related.

    Tx again.

    Randy

    #260524 Reply

    aazurmendi
    Member

    I am having the same issue, is there a fix?
    thanks

    #260662 Reply

    Haris Peco
    Member

    aazurmendi,

    This is very old thread and it is related with old vesrion of MyEclipse
    Please, send us your install details (MyEclipse>Installation Summary>Installation Details) and your log
    (Windows>ShowView>Other>PDE Runtime>Show Error Log view)

    It would be fine that you open new thread

    Thanks
    Peco

Viewing 5 posts - 1 through 5 (of 5 total)
Reply To: Spring, Junit classpathing issue

You must be logged in to post in the forum log in