wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes Loading EAR files in Java EE 5 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Loading EAR files in Java EE 5" Watch "Loading EAR files in Java EE 5" New topic
Author

Loading EAR files in Java EE 5

Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10067
    
163

I was reading the sample chapter 11 which you posted here. There's a sample ear file over there containing:

META-INF/application.xml
actionBazaar-ejb.jar
actionBazaar.war
actionBazaar-client.jar
lib/actionBazaar-commons.jar


Then there's the application.xml for this ear:



I noticed that there is no mention of the lib/actionBazaar-commons.jar in this xml. Would this mean that it will be loaded automatically during deployment?

That section further mentions an algorithm which is used to deploy an EAR and how it checks whether the file is an jar. Would this actionBazaar-commons.jar which is in a subfolder "lib" will ever be checked by this algorithm? Just curious


[My Blog] [JavaRanch Journal]
Debu Panda
author
Ranch Hand

Joined: Jan 21, 2007
Posts: 100
Hi Jaikisan,

Probably you did not read the label
Java EE 5 does not
require a deployment descriptor in the EAR module that identifies the type of modules packaged. It is the responsibility of Java EE container to determine the type of module based on its name
(extension) and its content.


The algorithm is for when there is no descriptor (application.xml) in the EAR.

Library e.g. actionBazaar-commons.jar module contains common classes (do not contain any EJB classes) and not a module of of its own and hence it is not deployed as a separate module. The classes packaged in that JAR will be loaded to the application level classloader will be available to all child modules.

Hope this makes sense.

-debu


Author: EJB 3 In Action (http://manning.com/panda)
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10067
    
163

Originally posted by Debu Panda:

The algorithm is for when there is no descriptor (application.xml) in the EAR.


I read that, but the reason why i asked this was i did not see a mention of the actionBazaar-commons.jar in the application.xml.
I would have expected it to be mentioned over there as a java module something similar to:



In the applications that i have been working on, that's what i have been doing to have a common utility jar file loaded by the classloader so that the classes in this jar can be accessed by the war as well as the ejb module which are present in the ear. My understanding is that if we dont mention this entry in the application.xml then the actionBazaar-commons.jar will not be loaded and the classes present in this jar will not be available neither for the ejb module nor the war module. Have i got this wrong?
Debu Panda
author
Ranch Hand

Joined: Jan 21, 2007
Posts: 100
If you have <module> <java>actionBazaar-commons.jar</java></module>

actionBazaar-commons.jar will betreated as an application client!

lib directory is an extension in Java EE 5 to put helpetr classes /libraries.

By default it is lib but you can customize to whatever directory you want



and then put your jars into


I had a section for this in my draft but the editor thought that's too much for an EJB book ! and I had to get rid of that
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10067
    
163

Originally posted by Debu Panda:

lib directory is an extension in Java EE 5 to put helpetr classes /libraries.

By default it is lib but you can customize to whatever directory you want



and then put your jars into



That explains it.

Originally posted by Debu Panda:
I had a section for this in my draft but the editor thought that's too much for an EJB book ! and I had to get rid of that


I wish that was there in the final published version of the book

Thanks Debu for the explanation.
Debu Panda
author
Ranch Hand

Joined: Jan 21, 2007
Posts: 100
Unfortunately we can't discuss everything in the horizon in a single book. I agree with the editor that was out of scope for an EJB 3 book. But if you look other EJB books they do not discuss about any such aspects that we dive down in Chapter 11 and you will find such differences in most of other chapters as best practices and things to avoid!
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10067
    
163

But if you look other EJB books they do not discuss about any such aspects that we dive down in Chapter 11 and you will find such differences in most of other chapters as best practices and things to avoid!


I agree. I mentioned this in one of the other posts that the classloader section that you have in your Chapter 11 is great. You would not find any discussion on such topics in other EJB books.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Loading EAR files in Java EE 5