Which version of JBoss AS? I believe the classpath for a EAR changed between 4.2.x and 5.0. If you scan the JBossAS5 forum you will probably find a few discussions on this topic.
I use in JBoss 4.2
You told me that JBoss share all classes , but i think its true only for classes in the lib directory.
I run the following test:
1. ejb in the root of the ear call to a class which located in the root of the ear - failed. if i move the jar (utility jar) to the lib or add him to the ejb-manifest classpath it work.
2. ear - b call to a class which located in a jar in the root of ear-a - failed.
Dosnt JBoss has by default shared repository?
Yes, by default JBossAS shares all classes globally, including classes defined in an EAR file located in the deploy directory.
Maybe I am misunderstanding something in your post regarding the placement of classes. Please run "jar -tf xxx.ear" for both of your EAR files and post the output.
The structre of the ear is:
a stateless ejb in the ejb.jar failed to load class from the utility.jar
What is in your meta-inf/application.xml file? If it does not mention utility.jar, that jar is not loaded automatically (whereas JARs in 'lib' are automatically loaded).
i didnt add it to the application.xml
i know that if i will add it than it will work.
My question is why it dosnt work by default.
Dosnt the class loader suppose to share all classes?
This has to do with the Java EE spec and how EAR files are supposed to be handled. Only those JARs mentioned in application.xml or placed into xxx.ear/lib get loaded, thus only those classes are available.