avk tests.web.elements.WebEjbReferencesElement error with EAR

The test tests.web.elements.WebEjbReferencesElement in the AVK 1.4, is reporting an error that cannot find an EJB that is referenced in the web.xml,

This webapp is deployed in a EAR, where the EJB and the webapp are included. So the EJB should be found for the webapp, and it is not necessary to include the ejb-client classes in the WEB-INF/lib or WEB-INF/classes.

This application that does not pass this test runs fine on Sun Java System Application Server Platform 8, and WebLogic 6.1 or WebLogic 8.1

[523 byte] By [Bruno_Antunes] at [2007-9-30 19:28:28]
# 1

Hi,

There is no need to bundle the ejb implementation class in the war file. But it is a requirement that the ejb interface classes (i.e. home and component classes) be bundled inside the war file because of portability reasons. There is no guarantee that the ejb jar file be available to web container in every app server. So even if your app runs fine in BEA and Sun Java Systems App Server, there is no guarantee that it will continue to run in all future versions of those app servers. More over there may be some other app server where your app may not work, because the J2EE spec does not require this behavior. This is detailed in section#8.1.2 of J2EE 1.4 platform spec (http://java.sun.com/j2ee/download.html#platformspec).

You may already be familiar with how to go about fixing the issue. But in case, you are not, given below is an explanation of how to fix the issue.

Option #a: directly bundling the classes in war file:

You can just compile the ejb home/local home and remote/local interface classes and put those classes in WEB-INF/classes dir of the web app.

Or you can make a jar file containing these classes and put it in WEB-INF/lib dir of the war file.

Option #b: using Class-Path manifest attribute (This is a.k.a Bundled Optional Package Support mechanism in Java):

The problem with the first approach comes from the fact that in the ear file, ejb interface classes are duplicated once in ejb jar file and again in war file. To avoid this, follow these steps...

1) Compile the ejb home/local home and remote/local interface classes, make a jar file, say ejb_intf.jar.

2) Don't bundle these classes in ejb_jar file. Bundle only the ejb implementation classes in ejb_jar file.

3) Write a manifest file which contains the following line...

Class-Path: ejb_intf.jar

4)run 'jar uvfm <your_war_file_name> manifest'

This will update the META-INF/MANIFEST.MF file of your war file.

5)run 'jar uvfm <your_ejb_jar_file_name> manifest'

This will update the META-INF/MANIFEST.MF file of your ejb jar file.

6)run 'jar uvf <your_ear_file> <your_war_file> <ejb_jar_file> ejb_intf.jar'

Now your ear file is packages the updated ejb jar , war and ejb_intf.jar

The steps are not as complicated as they appear to start with. More on this can be found at section #8.2 of J2EE 1.4 platfom spec.

Thanks,

Sahoo

sahoo_s_k at 2007-7-6 23:42:19 > top of Java-index,Enterprise & Remote Computing,AVK Portability...