简体   繁体   中英

How to properly set a JavaEE project classpath in Eclipse?

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM