How do you ensure that the Utility project library dependency is packaged into the final EAR in Eclipse Galileo?
I have a "Utility Project" and an "EAR Project" which includes a "Utility Project". All classes from the "Utility Project" are eventually packaged as a JAR and placed in the "lib" directory of the exported EAR, for example:
EAR.ear
META-INF
MANIFEST.MF
lib
utility.jar (which expands to):
META-INF
MANIFEST.MF
com
acme
Foo.class
Bar.class
However, the Utility Project is based on a library (freemarker.jar) that was added to the build path using Properties> Java Build Path> Libraries. All I want to do is add freemarker.jar to EAR like this:
EAR.ear
META-INF
MANIFEST.MF
lib
**freemarker.jar**
utility.jar (which expands to):
META-INF
MANIFEST.MF
com
acme
Foo.class
Bar.class
While searching for Eclipse, I found 4 potential ways to achieve this goal, none of which worked. If someone can just interrupt the chase and tell me what I have to do, that would be great. But just in case, I'll iterate over them here:
In the Utility project properties:
- If I click "Java Build Path> Order and Export" and select "freemarker.jar" to export, the jar will not get into the EAR file at all.
- If I click on "Java EE Module Dependencies" and select the "freemarker.jar" library as a dependency, it says:
This JAR is a bundled EAR library and must be packaged in the EAR library directory. It conflicts with the manifest class of the path dependency you are trying to create. If you create this dependency, the JAR will be packaged in the root (not library) of the EAR directory. Are you sure you want to continue?
From the EAR project properties:
- If I click "Java EE Module Dependencies> Add JAR ..." and navigate to "freemarker.jar" and make it dependent, it is added to the root of the EAR: /freemarker.jar
- If I do the same as above, but check the "In Lib Dir" box, it is added to the lib folder, but contained in a different lib folder: /lib/lib/freemarker.jar
Thanks.
a source to share
I managed to solve this problem. In the Problems window, I received the following warning:
Class entry path / utility-project / lib / freemarker.jar will not be exported or published. Runtime ClassNotFoundExceptions may occur.
What I tried, on a whim, was to use the Ctrl-1 keyboard shortcut, which I used to quickly solve problems for my source code. It turns out that it also provides quick fix solutions for these errors and warnings. I chose the first of two options:
Mark the associated rawpathpath entry as a publish / export dependency.
and my problem was gone!
Unusually, this all seems to have resulted in librequare.jar lib being selected in the "Java EE Module Dependencies" properties dialog, which I did myself anyway. This could be an Eclispe bug!
a source to share
@MonoThreaded: after using the quick fix. > Mark the linked original path class entry as a published / export dependency, if you right click on the project> properties> depolyment assembly, you will notice that eclipse has added a new entry, something like source: /freemaker.jar, deployment path :. ./lib. You can also do this by choosing Add> Enter Java Build Path.
a source to share