aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes JBoss suddenly deploying EJBs in random order Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "JBoss suddenly deploying EJBs in random order" Watch "JBoss suddenly deploying EJBs in random order" New topic
Author

JBoss suddenly deploying EJBs in random order

Aaron Beverly
Greenhorn

Joined: Sep 10, 2003
Posts: 19
Hello:
I have a problem with JBoss 3.2 deploying my EJBs in a random order. I have been working on an application for several months, with ~40 EJBs, among other things. Up until today, whenever I deploy EJBs to JBoss, it deploys them in alphabetical order, so I have named some beans such that they will be guaranteed to be deployed after some other beans that they require, just to avoid error messages in the logs. My experience with JBoss has led me to believe that this is the default behavior for the container (i.e., alpha order deployment of resources).
So, today, for reasons I cannot fathom, JBoss suddenly started deploying the EJBs in a seemingly random order, which is causing all sorts of deployment errors for me. I have not changed anything in the server configuration inthe last several days, and never anything that would seem to affect this behavior. Nothing I can do will make the damn thing revert to its previous behavior. So far, all I can do is touch the files after the server is done deploying and complaining about classes it cannot find, so it will forcibly redeploy the beans that threw errors.
What could be happening??!!
Aaron Beverly
Greenhorn

Joined: Sep 10, 2003
Posts: 19
Oh, and incidentally, the deployment scanner MBean configuration is still using default values, at least as far as I can see, ie, the URLComparator is the default implementation provided with JBoss. Yet, the deployment is not alpha order. It IS, however, still in the correct extension order (jar, war, wsr, ear, zip, etc);
Ade Barkah
Ranch Hand

Joined: Mar 17, 2004
Posts: 65
Hi Aaron,
The URLComparator mbean attribute only specifies the deployment ordering between application modules (ie., jar, war, ear), not the order within those modules.
For your EJBs, JBoss (3.2.x) first deploys all your Entity Beans following the declaration order your ejb-jar.xml file. Then it deploys all your Session Beans, again in the order specified by the ejb-jar.xml file.
So the obvious short-term solution is to rewrite your ejb-jar.xml keeping in mind the required declaration order. However, in the long-run you should try to eliminate these dependencies to begin with, so the beans can be deployed in any order.
Regards,
-Ade Barkah


-Ade<br /><a href="http://www.barkah.org" target="_blank" rel="nofollow">www.barkah.org</a>
Aaron Beverly
Greenhorn

Joined: Sep 10, 2003
Posts: 19
hhmmm.....well, here are some thing I don't get, then.
First, JBoss is not deploying the entity beans first, then session beans. It always has before yesterday, but now, since it ihas started deploying them in an unpredictable order, it is mixing the session beans with the entity beans, which is where the dependency error arise. None of my entity beans depend on each other, but my session beans do depend on many of the entity beans, as is almost alwyas the case. It is this that is my problem. So, if session beans are supposed to deploy after entity beans, which JBoss docs state they should, then my JBoss is broken somehow.
Also, as for the assertion that the beans do not necessarily deploy in alpha order (after, of course, they are sorted by extension, ie, jar, war, ear, etc), then it is highly coincidental to me that in ~300-400 deployments of the EJBs that comprise my current project, the container has deployed in alpha order 100% of the time, until yesterday. Also, my reading of many, many, many posts online suggest that alpha order (within the archive extension categories: sar, jar, war, ear, etc...) is in fact the way that the container deploys. This may be a side effect of the order that directory listings are returned and not necessarily by design, but it has always been the case for me before.
Anyways, even if that is not so, the EJBs are still deploying in an incorrect manner, ie, session beans are deploying, it seems, randomly interspersed with the entity beans declared in ejb.xml. I do not know how to write the session beans so that they do not depend on anyother bean at all. I don;t even think that is a wise design decision, since it would render the session beans somewhat useless...
Anyways....Help!!
[ March 31, 2004: Message edited by: Aaron Beverly ]
Aaron Beverly
Greenhorn

Joined: Sep 10, 2003
Posts: 19
Well, I dunno why, but I decided to just remove JBoss completely, download a fresh copy and reinstall. And now the beans deploy correctly...
Ade Barkah
Ranch Hand

Joined: Mar 17, 2004
Posts: 65
Glad things worked out.
I've also read the postings re: DeploymentSorter url comparator deploying beans in alphabetical order; but if you actually look at DeploymentSorter's source code, clearly it doesn't even look inside jar files. Besides, it's trivial to change the declaration order of beans in ejb-jar.xml and verify that JBoss indeed deploys according to my post above.
-Ade Barkah
Aaron Beverly
Greenhorn

Joined: Sep 10, 2003
Posts: 19
Well, it wouldn't have to look inside a jar file. My point was that if you had 25 separately jarred EJBs, packaged as a.jar thru z.jar, then URL Comparator will deploy a.jar first, then b.jar, then c.jar, etc....
So, if x.jar, y.jar, and z.jar are session beans depending on entity beans a.jar thru w.jar, they will deploy correctly unless the beans are deployed in something other than alpha order, which they always have been for me before. I suspect this has nothing at all to do with the code in the Comparator class but instead to do with the order in which directory listings are returned by the operating system.
In my case, however, even after packaging the EJBs into a single jar with a single ejb.xml, session beans were NOT deploying after all entity beans. I realize that is what is supposed to happen. That's why I posted in the first place.
After reinstalling JBoss, the beans ARE now deploying as you said they should, which is to say entity beans in order of appearance in ejb.xml, then session beans. I'm not saying you are wrong - clearly you are quite right. I am merely saying that something weird was occurring in my installation of JBoss for which your explanation did not resolve the issue.
[ March 31, 2004: Message edited by: Aaron Beverly ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JBoss suddenly deploying EJBs in random order