facebook

Potential solution to ClassNotFoundException

  1. MyEclipse IDE
  2.  > 
  3. Maven for MyEclipse (Maven4MyEclipse)
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #290785 Reply

    cherngje
    Member

    There is (or was) an issue with Maven4MyEclipse when use IDE to run application or JUnit test. The problem that I encountered was that when I try to run application or JUnit test by using IDE tool, I got ClassNotFoundException, however, everything is fine when using “Maven Test”. I can not remember the exact steps to recreate the problem, but the problem was most likely due to Java Build Path.

    If you see your project has both target and target-eclipse, it is very likely you will run into this kind of problem. What you can do is right click on the project, and then select Properties, then go to “Java Build Path”. In the menu, change the default output folder to ProjectName/target/classes. If your project follows standard structure, then the output folder for ProjectName/src/main/java should be changed to ProjectName/target/classes, and the output folder for ProjectName/src/test/java should be changed to ProjectName/target/test-classes. At this point, you can delete target-eclipse folder. One thing that I need to mention is that MyEclipse doesn’t create web project that follows the standard maven structure. I always change the structure and pom to follow standard maven structure, so the above steps can apply to the web project as well.

    After the Java Build Path is all set, you should be able to run maven clean follow by project/clean (with build automatically enabled), then you should be able run application/JUnit test from IDE.

    Maven clean will delete target folder and all the generated class files, and project/clean (with build automatically enabled) will recreate the target folder with most up-to-dated classes files.

    Hope this can help.

    #290793 Reply

    Riyad Kalla
    Member

    cherngie,

    We really appreciate you taking the time to type up that solution for other folks that might be running into it (I’m stickying this thread for now). In the mean time I have forwarded the issue along to the product team for evaluation.

    #290821 Reply

    allenparslow
    Member

    This issue looks like the same one that I’m observing: https://www.genuitec.com/forums/topic/myeclipse-7-0m2-maven-packaging-war-junit-don-t-execute/ [MyEclipse 7.0M2, maven packaging=war, JUnit don’t execute].

    The temporary workaround proposed by cherngje worked for me also.

    #290822 Reply

    allenparslow
    Member

    One thing that I need to mention is that MyEclipse doesn’t create web project that follows the standard maven structure. I always change the structure and pom to follow standard maven structure, so the above steps can apply to the web project as well.

    I also agree.

    #291937 Reply

    allenparslow
    Member

    In MyEclipse 7.0 (release), I am able to run (from the IDE) test-classes in src/test/java with packaging-war without ClassNotFoundException without changing the java build path.

    I think the issue has been resolved.

    #292273 Reply

    Riyad Kalla
    Member

    allenparslow, glad to hear it.

Viewing 6 posts - 1 through 6 (of 6 total)
Reply To: Potential solution to ClassNotFoundException

This topic is marked as closed to new replies, however your posting capabilities still allow you to do so.

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