This discussion is archived
4 Replies Latest reply: Nov 2, 2011 10:25 AM by 897126 RSS

How should I set the class-path when using JavaEE technology in Eclipse?

897126 Newbie
Currently Being Moderated
I'm developing a JavaEE system with several applications on a Weblogic AS (10.3.5) using Eclipse indigo with OEPE plugin. I turned my computer off, turned it back on, started the eclipse, and all of a sudden I get class-path errors all over the place (didn't change a thing).

Now let me get this straight:
1. Say I have an application with one EAR project that contains an EJB project and an EJBClient project (both in the deployment assembly).
2. I have written a new regular Java project, and I want to use it in both the EJB and EJBClient projects (it needs to be visible to them).
3. As far as I know, I can simply add this Java project to the EAR project's deployment assembly, and it will be visible to the EJB and EJBClient projects.
4. This has been working for me so far, but now I get class-path errors and I have to add this Java project to the build path of each project.

How should I set the class-path when using JavaEE technology in Eclipse?
  • 1. Re: How should I set the class-path when using JavaEE technology in Eclipse?
    gimbal2 Guru
    Currently Being Moderated
    894123 wrote:
    I'm developing a JavaEE system with several applications on a Weblogic AS (10.3.5) using Eclipse indigo with OEPE plugin. I turned my computer off, turned it back on, started the eclipse, and all of a sudden I get class-path errors all over the place (didn't change a thing).
    Thats an Eclipse thing I sometimes suffer from too (before Eclipse 3.7, haven't suffered it in the latest version yet). Generally cleaning all projects will solve it. Note that this is usually a cascaded effect when you have project modules that depend on each other through workspace resolution; when a module fails to compile for whatever reason, it temporarily drops off the classpath of a module that depends on it and you get classpath errors there as well.
    How should I set the class-path when using JavaEE technology in Eclipse?
    Maven is good for any kind of project type, but especially JavaEE projects because the dependency hierarchy tends to be complicated. Note that you are talking about the classpath for compilation/test purposes. Runtime classpath is of course controlled by the container.

    If you want to know more about using Maven in Eclipse, I recently wrote an article about it. But this assumes you already know how Maven works.

    http://entjavastuff.blogspot.com/2011/10/using-maven-in-eclipse.html
  • 2. Re: How should I set the class-path when using JavaEE technology in Eclipse?
    897126 Newbie
    Currently Being Moderated
    I did cleaned the projects (of course) and it didn't help, and there's no dependencies missing (i checked). I tried to remove and re-add one of the "missing" Java project to the build path, and it seemed to work, but now I get some odd circular dependency errors (and there are none).

    I tried to use Maven once and my impression was that it might be a good tool, but it takes to much time and effort to learn it and use it properly. But maybe it's worth another shot.
  • 3. Re: How should I set the class-path when using JavaEE technology in Eclipse?
    gimbal2 Guru
    Currently Being Moderated
    894123 wrote:
    I tried to use Maven once and my impression was that it might be a good tool, but it takes to much time and effort to learn it and use it properly. But maybe it's worth another shot.
    nothing takes too much time to learn, what you mean to say is that you did not want to invest the time. I highly recommend you do though. I direct you to my article about basic Maven usage:

    http://entjavastuff.blogspot.com/2010/06/maven2-copy-pastable-template.html


    Perhaps it can give you an idea just where Maven can help you. I can tell you from experience that when you know what you are doing, it should take no more than 15 minutes to setup a clean mavenized project (and then more time to work out the dependency management which is highly project specific).
  • 4. Re: How should I set the class-path when using JavaEE technology in Eclipse?
    897126 Newbie
    Currently Being Moderated
    After some tweaking I managed to solve the errors:

    First I removed the library named 'EAR libraries' from the build path of each of my regular Java projects (I have no clue why Eclipse added them, they shouldn't be there).
    Then, for each EAR project, I deleted and re-added every project or jar that was not part of the EAR (regular Java projects, other EJBClient projects, etc).
    This solved the issue of not finding classes which aren't included in the EAR, but then I had a 'circular dependency' error.
    I narrowed that error down to the projects that caused it - It was a regular Java project that was using an EJBClient project of some application in its build path, and the EJBClient project was also using the Java project in its build path.
    Sounds trivial, then why havn't I seen it in the first place? Well, I looked into the EAR project of the application, and it didn't have the java project in the deployment assembly, and the EJBClient didn't have Java project as a 'required project'. So where was it?
    The java project was in the 'EAR libraries' library of the EJBClient project, which, according to Eclipse, is automatically generated according to the 'MANIFEST.MF' file (which was empty, btw).
    So I simply deleted and re-added the 'EAR libraries' library from the build path of the EJBClient project, and it solved the problem, and everything now works.

    In conclusion, it seems like the OEPE plugin for Eclipse have some bugs that needs to be fixed.

    Edited by: wafwaf on 10:25 02/11/2011

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points