Matt RaibleMatt Raible is a Web Developer and Java Champion. Connect with him on LinkedIn.

The Angular Mini-Book The Angular Mini-Book is a guide to getting started with Angular. You'll learn how to develop a bare-bones application, test it, and deploy it. Then you'll move on to adding Bootstrap, Angular Material, continuous integration, and authentication.

Spring Boot is a popular framework for building REST APIs. You'll learn how to integrate Angular with Spring Boot and use security best practices like HTTPS and a content security policy.

For book updates, follow @angular_book on Twitter.

The JHipster Mini-Book The JHipster Mini-Book is a guide to getting started with hip technologies today: Angular, Bootstrap, and Spring Boot. All of these frameworks are wrapped up in an easy-to-use project called JHipster.

This book shows you how to build an app with JHipster, and guides you through the plethora of tools, techniques and options you can use. Furthermore, it explains the UI and API building blocks so you understand the underpinnings of your great application.

For book updates, follow @jhipster-book on Twitter.

10+ YEARS


Over 10 years ago, I wrote my first blog post. Since then, I've authored books, had kids, traveled the world, found Trish and blogged about it all.

JBoss ClassLoader Logic

Is there any logic to how JBoss puts all WARs, EARs and their accompanying JARs into the same ClassLoader? It seems logical that I should be able to deploy different versions of a JAR in different WARs. This works fine on Tomcat, but doesn't seem to on JBoss. Is there someway to turn this segmentation on?

Posted in Java at Feb 25 2005, 08:00:36 AM MST 11 Comments
Comments:

Hi Matt, Welcome to the wonderful world of JBoss :-))

To answer your question : you should have a look at the "UseJBossWebLoader" attribute in your jboss-service.xml.

BTW, you might be interested by this blog entry (from my own blog) :
http://jroller.com/comments/julien.dubois?anchor=the_jboss_classloader_from_hell

HTH,

Julien.

Posted by Julien Dubois on February 25, 2005 at 03:21 PM MST #

Hi Matt, A quick Google suggests that they're doing this to make things simpler for users who can't figure out the J2ee class-loading scheme. (Although breaking it for those of use who /can/ figure out the J2ee scheme doesn't seem to woory them.) Anyway, it apparently can be switched off by setting

<jboss-app>
  <loader-repository>unique.domain:loader=yourapp.ear</loader-repository>
&lt/jboss-app>
in your apps jboss-app.xml. See http://members.capmac.org/~orb/blog.cgi/tech/java/jboss_ucl.html & http://docs.jboss.org/jbossas/admindevel326/html/ch2.chapter.html#ch2.scopedapp.ex although I don't use JBoss myself, so can't verify it works...

Posted by Gwyn Evans on February 25, 2005 at 03:31 PM MST #

Welcome to JBoss classloader hell. Yes, it's nonsensical and absurd. The only way around it that I've found so far is the aforementioned jboss-app.xml. If you think it's bad now, just wait until you find out that precompiled JSPs (can you say index.jsp?) and resource bundles (MessageResources.properties) fall under this scheme as well. Why they believe that a hierarchal classloader would be so difficult to understand is beyond me.

Posted by Rob Kischuk on February 25, 2005 at 03:44 PM MST #

Found a more complete explanation/solution here: http://www.jboss.org/wiki/Wiki.jsp?page=ClassLoadingConfiguration

Posted by Rob Kischuk on February 25, 2005 at 03:46 PM MST #

Any logic, as in any compelling reason that might be accepted as valid by a consensus of experts, or just a reproducible procedure? I'll assume you mean the second. :)

1. In $JBOSS_HOME/server/default/deploy/jbossweb-tomcat50.sar/META-INF/jboss-service.xml (assuming we're talking about the "default" server), inside the <mbean code="org.jboss.web.tomcat.tc5.Tomcat5" name="jboss.web:service=WebServer"> tag, make sure <attribute name="UseJBossWebLoader">false</attribute> is present. I belive its value defaults to true.

2. In $JBOSS_HOME/server/default/conf/jboss-service.xml, ensure that the following tags are present among the mbean definitions:

   <mbean code="org.jboss.deployment.EARDeployer" name="jboss.j2ee:service=EARDeployer"><br/>
      <attribute name="Isolated">true</attribute><br/>
      <attribute name="CallByValue">true</attribute><br/>
   </mbean>
I'm pretty sure the "jboss.j2ee:service=EARDeployer" mbean is defined in there by default, but the attribute values allow classpath promiscuity by default. These values should make you happy.

I'm told the better solution is to use JBoss 4. I think it conforms to the J2EE spec by default in this regard, but we don't use it in production yet, so I'm stuck with this silliness for now.

Posted by Tim Berglund on February 25, 2005 at 04:02 PM MST #

Hey, that worked well! I tried to make the XML browser-friendly, but it didn't work too well. In any event, looks like you've got the help you need here already. Email me if you want that XML snippet in its entirety.

Posted by Tim Berglund on February 25, 2005 at 04:06 PM MST #

I fixed the XML in your comment Tim - thanks for the tip!

Posted by Matt Raible on February 25, 2005 at 04:15 PM MST #

I believe that Tim's suggested adjustment will give you EAR-level scoping, but if you have multiple WARs in the EAR, you must fuss with the web app loader, as mentioned earlier, and you may also need to fuss with the delegation model. See also: the ClassLoadingConfiguration page on the JBoss wiki

Posted by Anil Gangolli on February 27, 2005 at 04:51 PM MST #

I'm trying to configure my sar to have classloader scoping. The configuration I use in META-INF/jboss-service.xml is: <loader-repository>dot.com:loader=spmi.sar <loader-repository-config>java2ParentDelegation=false</loader-repository-config> </loader-repository> It's not working as expected. Now I'm not able to start JBoss server. The environment has JBoss4.0.3SP1 and JBoss Portal 2.2 Any idea will help. Thanks

Posted by Anbu on April 27, 2006 at 06:00 PM MDT #

Anbu: What are you trying to do? Get the UnifiedClassLoader running? I don't understand your question.

Posted by Matt Raible on April 28, 2006 at 03:26 AM MDT #

Hi all, From my experience, if you want to make your webapps to behave like with standalone Tomcat, that is, each webapp to use its own classes and/or libraries, just modify jboss-service.xml under JBoss' embbeded Tomcat. By updating JBoss' EARDeployer MBean, you're 1st isolating your deployables, so each one will have its own classloader, and 2nd forcing call by value then. In that cases, performance will decrease 10 times (as per JBoss' forum) whenever you need to call remote classes, since serialization is necessary. Besides, you'll need to provide full scheme JNDI names (jnp://localhost:1099/myComp) for your deployable components. In conclusion, you just need to tell Tomcat "do not use JBoss' UnifiedClassloader and do it as you know", and do not tweak anymore JBoss' setup. It worked fine for me. I hope it's useful... Regards

Posted by Pablo Molina on September 26, 2007 at 08:25 AM MDT #

Post a Comment:
  • HTML Syntax: Allowed