Clarification On And Resolution Of 'Java EE Module Dependencies'

1.6k views Asked by At

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

2

There are 2 answers

4
Beez On BEST ANSWER

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!

0
Thorbjørn Ravn Andersen On

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.