Compliant J2EE/EJB class file packaging...

Hi,

I've just come across some commerical components which are packaged slightly strangely and I'd like to find out if their approach is J2EE compliant.

The components are EJBs which are packed into several EJB module archives (.jars) inside a main application archive (.ear). The interesting thing is, inside each EJB module .jar, they have packaged the .class files into several ordinary .jar files and added those .jars into the EJB .jar, rather than simply adding the classes to the EJB .jar itself. My question is, is this compliant?

Are application server classloaders suppsed to automatically open such embedded .jars and make the classes available to the container at runtime? I don't think so but I have been assured by the vendor in question that this is compliant (and runs in the J2EE 1.2 RI which I havn't tested).

There are no directives, either in the J2EE deployment descriptors or .jar Manifests which can be used to indicate that the 'inner' .jar files should be unpacked. The Class-Path Manifest attribute can be used to point to other jars using a relative URI but I don't believe it can be used to point to .jars inside the referencing .jar. (In any case, this vendor isn't using a Class-Path attribute)

Any thoughts appreciated!

Regards,

John.

[1333 byte] By [mroshea] at [2007-9-26 4:30:02]
# 1

> EJB module archives (.jars) inside a main application

> archive (.ear). The interesting thing is, inside each

> EJB module .jar, they have packaged the .class files

> into several ordinary .jar files and added those .jars

> into the EJB .jar, rather than simply adding the

> classes to the EJB .jar itself. My question is, is

> this compliant?

Yes, indeed I understand this is normal each jar contains the three elements of each ejb. The bean home, the object and the bean it;s self.

>

> Any thoughts appreciated!

>

> Regards,

>

> John.

MartinS. at 2007-6-29 17:42:03 > top of Java-index,Other Topics,Patterns & OO Design...
# 2

Hi,

> Yes, indeed I understand this is normal each jar

> contains the three elements of each ejb. The bean

> home, the object and the bean it;s self.

Interesting. My experience is that this isn't normal and I cannot find any references in either the J2EE, EJB or J2SE specifications indicating that ClassLoaders should search inside .jars embedded inside the main EJB .jar file for required .class files and resources. (The J2SE Extension Mechanism does describe how bundled .jars can be referenced in the Mainifest file but these .jars are refereced using URIs are are external to the referencing .jar file)

I guess a reference to something in the specifications would help...

j.

> >

> > Any thoughts appreciated!

> >

> > Regards,

> >

> > John.

>

mroshea at 2007-6-29 17:42:03 > top of Java-index,Other Topics,Patterns & OO Design...
# 3

mroshea,

If you notice carefully,

Yes, indeed I understand this is normal each jar contains the three elements of each ejb. The bean home, the object and the bean it;s self.

does not really address jar inside jar.

By the way, I am also eager to know the truth.

neville_sequeira at 2007-6-29 17:42:03 > top of Java-index,Other Topics,Patterns & OO Design...
# 4

>

> Yes, indeed I understand this is normal each jar

> contains the three elements of each ejb. The bean

> home, the object and the bean it;s self.

>

Ah, sorry, I though the jar's you were referring to were these odd internal jars. The 'main' jar will, of course, contain the EJB's classes (or refer to another Jar via a Class-Path entry in the Manifest.mf file which contains them)

John.

mroshea at 2007-6-29 17:42:03 > top of Java-index,Other Topics,Patterns & OO Design...
# 5

> Hi,

>

> > Yes, indeed I understand this is normal each jar

> > contains the three elements of each ejb. The bean

> > home, the object and the bean it;s self.

>

> Interesting. My experience is that this isn't normal

> and I cannot find any references in either the J2EE,

> EJB or J2SE specifications indicating that

> ClassLoaders should search inside .jars embedded

> inside the main EJB .jar file for required .class

> files and resources. (The J2SE Extension Mechanism

> does describe how bundled .jars can be referenced in

> the Mainifest file but these .jars are refereced using

> URIs are are external to the referencing .jar file)

>

> I guess a reference to something in the specifications

> would help...

http://java.sun.com/j2ee/j2sdkee/techdocs/guides/ejb/html/Overview5.html

MartinS. at 2007-6-29 17:42:03 > top of Java-index,Other Topics,Patterns & OO Design...
# 6

> > I guess a reference to something in the

> specifications

> > would help...

>

> http://java.sun.com/j2ee/j2sdkee/techdocs/guides/ejb/ht

> l/Overview5.html

Hmmm, I see nothing in this reference that says that the EJB class files can be placed inside a .jar file which is in turn placed inside the "main" J2EE module EJB .jar file.

I'm now almost certain this approach isn't compliant even though the vendor claims this runs ok in the J2EE Reference Implementation server (1.2). If there is a conflict between the specification and the reference implementation, which one wins? I presume the specification does.

cheers,

John.

mroshea at 2007-6-29 17:42:03 > top of Java-index,Other Topics,Patterns & OO Design...
# 7
does not really address jar inside jar.YEs, because JAR's ( and WAR's etc) are inifinite nestable.
MartinS. at 2007-6-29 17:42:03 > top of Java-index,Other Topics,Patterns & OO Design...
# 8

>

> Hmmm, I see nothing in this reference that says that

> the EJB class files can be placed inside a .jar file

> which is in turn placed inside the "main" J2EE module

> EJB .jar file.

Nesting .jar's has always been perfectly proper, why do you believe that ejb-jar do not support this ?

MartinS. at 2007-6-29 17:42:03 > top of Java-index,Other Topics,Patterns & OO Design...
# 9

>

> Nesting .jar's has always been perfectly proper,

It has? I've certainly never seen anything like this in my past java programming experience. Can you give me some examples or references to the J2SE or J2EE specifications that back up this assertion?

I believe J2SE doesn't allow you to simply place different classes in different jars, then nest those jars inside each other and expect a standard ClassLoader to be able to load the classes from the correct location at runtime. Try it, you'll see that doesn't work. I can see nothing in the J2EE spec that says that a J2EE appserver has to go looking into these nested jars.

> why

> do you believe that ejb-jar do not support this ?

Quite simply because there are no references to "nesting" jars in the specification, beyond

a) nesting J2EE modules (.jar, .war and .rar files) inside J2EE application .ear files

and

b) nesting required libraries in "WEB-INF/lib" location of a .war file.

Both of these cases are explicitly defined in the specification but I don't believe there is any support for "general" nesting or Jars.

mroshea at 2007-6-29 17:42:03 > top of Java-index,Other Topics,Patterns & OO Design...
# 10

So has anyone actually managed to include a utils.jar type file in a ejb-jar? As we want to include one, and always seem to get a "class not found" problem when we deploy to Weblogic 6.1. Love an example of how to do it if possible.

If possible we would prefer to not have to exctract the utils.jar to an exploded directory structure

alexburton at 2007-6-29 17:42:03 > top of Java-index,Other Topics,Patterns & OO Design...