WebSphere RAD 7.0 Tips & Hacks - How to add a JAR file to J2EE EAR
Hi,
After several days of frustration and getting runtime "NoClassDefFoundError" exception or deployment "Cannot be published on the Server" I finally got it. Hope it will save you some time too.
Setup: WebSphere RAD 7.0.0.1 (note that the previous version of WSAD did not have that problem) using WebSphere 6.1 Application Server.
Problem: Add an external JAR file containing non-J2EE stuff to a J2EE project in RAD 7 environment on Windows XP.
Erroneous Solution: adding external JAR file to the build path from a directory or from another project (compiles fine but will throw "NoClassDefFoundError" when running since the server has no clue where it is. Modifying ClassPath env variable does not help since the Server doesn't care about it). So the idea is to add the JARs inside of the EAR, which is, first, not easy, and second, not enough.
Solution:
1. - Right click on EAR Project, select Import -> J2EE Utility JAR
- Select Copy Utility JARs into an existing EAR from an external
location and Next
- Select JAR directory and then the checkboxes corresponding to
the JARs and Finish
2. - Right click on the EJB Project -> Properties -> J2EE Module Dependencies- Select checkboxes the new JAR files.
3. - Manually Open YourEARProject/.settings/org.eclipse.wst.common.component file and delete just created <dependent-module> entries for the JARs added in previous steps. Save the file, clean all the projects, rebuild and redeploy.
Without this last step-hack it didn't want to publish for me. Now everything is fine.
Please let me know if anyone knows an easier way of doing this with WebSphere RAD 7.
Cheers,
Vassili

