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

[1745 byte] By [Vassilycha] at [2007-11-27 3:12:29]
# 1

hi,

i am new to rad application.

Actually i am trying to call hibernate in ejb. But its not working. The same error was coming. I have read your solution, and i have done the same steps as you said, but when i tried to run the ejb application on server, some popup is coming with message cannot publish to the server. I have done the same steps as you said but i am getting the same error. So please give me the relevant solution if possible

Thanks and regards

RAtna sekhar

Nani2ratnaa at 2007-7-12 8:14:58 > top of Java-index,Desktop,Deploying...
# 2

Hi!

Well, RAD and WAS are amazing... in the worstest way!!! lol

I'm having problems with a pure servlet/jsp application. It responses good until many requests to the same page (dynamically generated with GET parameters). Then the application sends the same information even when the parameters change!!!

It seems like a cach?problem.

Do you like what to do?

Remnahusha at 2007-7-12 8:14:58 > top of Java-index,Desktop,Deploying...