-
1. Re: How to use external jars not contained in JBoss
alesj Sep 27, 2010 5:57 AM (in response to hugbert)How can I extend JBoss classloading to also look for jars located in an external directory, say c:\ForeignApp\java.
See how we do this for:
-
2. Re: How to use external jars not contained in JBoss
hugbert Sep 27, 2010 10:35 AM (in response to alesj)Ales,
Thanks for your info, but unfortunately I must admit that I don't get it. Is there any documentation available that explains this to non JBoss cracks?
I also read your mail on http://community.jboss.org/message/7542#7542 but I did not find the documentation you mentioned about configuring the deployer, I did not find any doc about custom deployers at all.
So after a few hours of internet searching: Could you please give me some more jump start on this?
Is there any doc available on how to do this for JBoss 5.1?
Is it correct that I have to derive from PathUrlIntegrationDeployer?
How do I connect/configure the deployer with the ear? I have no clue what files I have to put to the deployers directory and how to name them.
Thank you for your help
Hubert
-
3. Re: How to use external jars not contained in JBoss
jaikiran Sep 27, 2010 10:56 AM (in response to hugbert)From an end user point of view, I guess this is easier http://community.jboss.org/thread/153910
-
4. Re: How to use external jars not contained in JBoss
hugbert Sep 27, 2010 12:38 PM (in response to jaikiran)Jaikiran,
Thank you, I tried this before, not via jboss-service.xml but by adding the classpath on the command line.
This way I get different errors. For external jars any dependent Jar is loaded also from the external repository, instead from the JBoss installation. If not found external, it throws an error. For example it loads commons-fileupload.jar from the external directory because this is also contained there. I then get NoClassDefFoundError or ClassNotFound because other jars needed in my app are not in the external directory but in my JBoss installation.
java.lang.NoClassDefFoundError: javax/portlet/ActionRequest
at org.apache.commons.fileupload.portlet.PortletRequestContext.getContentType(PortletRequestContext.java:73)
at org.apache.commons.fileupload.FileUploadBase$FileItemIteratorImpl.<init>(FileUploadBase.java:882)
...portlet.jar and commons-fileupload.jar are contained in server\default\lib, but JBoss does not find portlet.jar because commons-fileupload.jar is loaded from the external jar repository. Any dependent jar specified on the command line must also be in the external repository. I need a way that JBoss looks for dependent jars in the JBoss installation first, if there is a dependency.
Thank you
Hubert
P.S.
And this way I will probably get in trouble if I have (what I do) wars of other vendors which contain different versions of the jars that I currently use.
-
5. Re: How to use external jars not contained in JBoss
alesj Sep 29, 2010 9:10 AM (in response to hugbert)Thanks for your info, but unfortunately I must admit that I don't get it. Is there any documentation available that explains this to non JBoss cracks?
I also read your mail on http://community.jboss.org/message/7542#7542 but I did not find the documentation you mentioned about configuring the deployer, I did not find any doc about custom deployers at all.
So after a few hours of internet searching: Could you please give me some more jump start on this?
Is there any doc available on how to do this for JBoss 5.1?
Unfortunately the community docs are poor wrt this issue, but support ... ;-)
But let's try to make this work anyway.
Is it correct that I have to derive from PathUrlIntegrationDeployer?
How do I connect/configure the deployer with the ear? I have no clue what files I have to put to the deployers directory and how to name them.
Yeah, or any UrlIntegrationDeployer (including it) would do -- depends on what you need.
I suggest you first read this article about VDF: http://java.dzone.com/articles/jboss-microcontainer-virtual-deployment-framework
to get a better feel for how deployers actually work -- if you haven't already.
Each deployer checks every deployment, sub-deployment, sub-sub-deployment, ..
So, when you write your own "integration" deployer, make sure you short circuit asap,
only applying integration logic to (sub*)deployments that really need it.
The logic of adding external lib is already written in the UrlIntDeployer, you just need to fill in the blanks.
Then simply deploy this new deployer in deployers/ dir as we do for some our JBoss deployers -- see *-jboss-beans.xml files.
Deployer is nothing than a MC bean, and the MC kernel will pick it up automagically. ;-)
What this UrlIntDeployer does it simply alters spec defined classpath with additional resources; e.g. your ext lib.
So, when constructing deployment's classloader we use this classpath, not really bothering where the resources come from.
If the resources are already shared by some parent classloader or common classloading domain,
and your classloader's lookup first delegates to them (e.g. plain cl behavior or non-web behavior),
you should also be fine with no dup classes loaded aka can easily be shared.
HTH?
-
6. Re: How to use external jars not contained in JBoss
hugbert Sep 29, 2010 12:39 PM (in response to alesj)Hey Ales,
HTH?
Yes, you certainly did, thank you. :-)
I will read trough the doc and follow your advice.
Thanks a lot
Hubert