-
1. Re: web app packaging and classloading
alesj Jun 5, 2011 2:26 PM (in response to jboss_dev_16)1 of 1 people found this helpfulIs there an equivilant concept in JBoss?
Sure.
You could bundle all the libs into .ear/lib, and put this .ear into new CL domain via jboss-classloading.xml.
Then have your initial .war reference the same new CL domain; either as a parent or its domain.
* http://java.dzone.com/articles/jboss-microcontainer-classloading
-
2. Re: web app packaging and classloading
jboss_dev_16 Jun 5, 2011 2:40 PM (in response to alesj)Thanks, I will try this out. In initial investigation down this route I had problems though that may have been due to misconfiguration of the jboss-classloading.xml file. Are there example .ear and .war classloading XML files for a starting point?
-
3. Re: web app packaging and classloading
alesj Jun 5, 2011 2:52 PM (in response to jboss_dev_16)Are there example .ear and .war classloading XML files for a starting point?
jboss-classloading.xml is the same for all deployment types:
* http://community.jboss.org/wiki/JBoss5custommetadatafiles
More examples can be found in JBCL and Deployers tests:
* http://anonsvn.jboss.org/repos/jbossas/projects/jboss-cl/trunk/
* http://anonsvn.jboss.org/repos/jbossas/projects/jboss-deployers/trunk/
-
4. Re: web app packaging and classloading
jboss_dev_16 Jun 5, 2011 3:00 PM (in response to alesj)That should help, thanks.
One last question, will the ear get loaded first then by default once the war is referecing it in its jboss-classloding.xml?
-
5. Re: web app packaging and classloading
alesj Jun 5, 2011 5:00 PM (in response to jboss_dev_16)will the ear get loaded first then by default once the war is referecing it in its jboss-classloding.xml?
No, as we configured it now it's only referencing the same CL domain, not the actual deployment.
For that you would either have to use:
* <requirements><module ...> ... --- in jboss-classloading.xml
* jboss-dependency.xml from custommetadatafiles link
Meaning you somehow need to state an explict dependency between deployments.
-
6. Re: web app packaging and classloading
jboss_dev_16 Jun 5, 2011 4:33 PM (in response to alesj)This sounds like why I was having issues with geting the war to see the jars in the ear.
Thanks for the help.
-
7. Re: web app packaging and classloading
jboss_dev_16 Jun 6, 2011 9:07 AM (in response to jboss_dev_16)OK, I have tried the jboss-classloading.xml and jboss-dependency.xml route and I am still hitting a brick wall....
As mentioned before I have a .war file and a .ear file.
I want all library code (Spring, commons-* libs, etc) and java services we are writing to be contained in the .ear and only the web app code, jsp's, javascript, etc
to be contained in the .war.
It appears that I can only get the web app to look inside the web-inf lib foder for classes and not to inspect the .ear for libraries, services etc.
I have the foolowing jboss-classloading.xml in the .war file
<classloading xmlns="urn:jboss:classloading:1.0"
name="my_webapp"
domain="my_web_domain"
version="0.0.0"
parent-domain="parent_domain"
export-all="NON_EMPTY"
import-all="true" parent-first="true">
</classloading>
And the jboss-dependency.xml is
<dependency xmlns="urn:jboss:dependency:1.0">
<item whenRequired="Real" dependentState="Create">my_ear_file</item>
</dependency>
For the .ear I have to following jboss-classloading.xml
<classloading xmlns="urn:jboss:classloading:1.0"
name="my_shared_lib"
version="0.0.0"
parent-domain="DefaultDomain"
domain="parent_domain"
export-all="NON_EMPTY"
import-all="true"
parent-first="false"
top-level-classloader="true">
</classloading>
I had thought that the web app would attempt to load the classes from the web-inf/lib or classes directory first and then delegate to the parent
if they cannot be found, the parent being the ear in this case.
What I see is the web app not being able to find classes in the ear and thus throwing ClassNotFoundException.
So, I was moving jar files back into the .war but so that the ClassNotFoundException for Class X was resolved, but then Class Y, in the .ear, which
also relied on Class X was failing to get loaded. I suspect this was due to Class Y which is in the parent CL domain not being able to see the child?
If I can get the .war to see the jars etc in the .ear I think my problem is solved... I hope...
Any thoughts??
Cheers,
-
8. Re: web app packaging and classloading
alesj Jun 6, 2011 11:52 AM (in response to jboss_dev_16)In that jboss-dependency.xml, dependentState should be of DeploymentStage not ControllerState.
Since it's deployments that need to be "wired", not deployment and a service.
Try putting "ClassLoader":
And I guess you have aliases.txt in .ear/META-INF?
Other things look OK.
-
9. Re: web app packaging and classloading
jboss_dev_16 Jun 6, 2011 2:00 PM (in response to alesj)Ales Justin wrote:
In that jboss-dependency.xml, dependentState should be of DeploymentStage not ControllerState.
Since it's deployments that need to be "wired", not deployment and a service.
Try putting "ClassLoader":
And I guess you have aliases.txt in .ear/META-INF?
Other things look OK.
yes, I have aliases.txt in the correct location.
I'll try the change you suggest for jboss-dependency.xml.
Thanks again.