1

I'm attempting to set up a web project's dependency on a utility project. My utility project is set up with the 'Utility Module' project facet and 'Java 5'. When I select 'Java EE Module Dependencies' in the properties of my web project, my utility project does not appear. I believe this is the problem and would love to resolve it!

I did also try the following: Since the Utility project does, however, show up in the 'Java EE Module Dependencies' in the properties of my EAR, I selected the dependency in my EAR and found that the Utility was now available to my web project, it appears as. e.g., Utility.jar. Ultimately, this seems to be the desired effect. However, the issue appears to be with the server's dependency resolution. The Jar is distributed to the EAR and added to the Web's Manifest as, i.e., Utility.jar. But the Utility project's dependencies are not being included along with that (or something to that affect). Note: My company uses Ivy for dependency resolution. The problem here is that the specific Jar that I'm receiving NoClassDefFoundError s on is included in the Web's dependency as well (i.e., the Jar exists in the WEB-INF/lib directory). So I'm not sure why, if this is a viable solution, the Jar isn't able to resolve the dependency from the Web's classloader.

Also worth mentioning, the Utility project has been added to the 'Project' tab of the web project's 'Build Path'; therefore, I'm not receiving any compilation errors.

I will continue to dig in and try to find a solution but I would appreciate any help or guidance along the way.

Here are some of the resources I've found related to my exhaustive research:


Solution Posted Below

To anyone who was looking into this issue for me, I appreciate your time. Hopefully this will help someone with a similar issue down the road.

Sincerely, Beez

Community
  • 1
  • 1
Beez
  • 2,081
  • 1
  • 20
  • 23

2 Answers2

0

Web projects cannot have utility project dependencies. That is for EAR files only because that is an EAR construction not present in WAR-files.

The Eclipse Java EE ecosystem is very over-engineered. I would strongly suspect that this was not developed from the ground up by Eclipse itself, but taken directly from one of IBM's commercial Eclipse offerings. It is open for discussion whether this was a good idea or not.

Thorbjørn Ravn Andersen
  • 73,784
  • 33
  • 194
  • 347
0

Before, I was unable to check the Utility project in the web project's properties > 'Java EE Module Dependencies' > 'Web Libraries'. I'm not sure why. The module appeared but when I checked it, clicked 'apply' and 'okay', when I reopened the properties the module was unchecked. So I added the dependency manually into the org.eclipse.wst.common.component file:

<dependent-module archiveName="Utility.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/Utility/Utility">
    <dependency-type>uses</dependency-type>
</dependent-module>

This resolved the issue completely and my app is fully functioning!

Beez
  • 2,081
  • 1
  • 20
  • 23
  • Does the "cannot check it" apply after changing it from an Utility project into a normal Java project? In any case, this sounds like a good candiate for a bugzilla report. – Thorbjørn Ravn Andersen Sep 01 '11 at 22:35
  • No, the Utility is a utility module and the Web is a Dynamic Web Module inside an EAR module. Why did you down-vote my answer? – Beez Sep 02 '11 at 12:17
  • Manipulating eclipse configuration files directly is a very brittle solution. – Thorbjørn Ravn Andersen Sep 03 '11 at 07:37
  • If the GUI allows that which is employed by this solution, it seems a logical means to an end. If a brand new Utility project and Web project are created, in this same workspace, this is precisely the file that is manipulated when the dependency is checked in the GUI. I would agree that there is a bug within that dialog, but that does not render this solution brittle; as the manual solution is the same outcome as what the GUI is intended to do. – Beez Sep 06 '11 at 13:21