Reputation: 1802
this time I'm figthing against JBoss 7.1. My simple application, something.jar, has this jboss-deployment-structure.xml:
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="deployment.EarApp.ear.Stuff1-1.0.jar" />
<module name="deployment.EarApp.ear.Stuff2-1.0.jar" />
<module name="deployment.EarApp.ear.Somelib-1.0.jar" />
<module name="org.apache.commons.io"/>
</dependencies>
</deployment>
</jboss-deployment-structure>
Compile, build and depoly goes fine. But when jboss execute this line
BodyPart bodypart = new MimeBodyPart();
bodypart.setDataHandler(new DataHandler(new FileDataSource(new File(attachment))));
bodypart.setFileName(FilenameUtils.getName(attachment)); //this one!!
m.addBodyPart(bodypart);
I got this error
...(more)
Caused by: java.lang.NoClassDefFoundError: org/apache/commons/io/FilenameUtils from [Module "deployment.EarApp.ear.Stuff2-1.0.jar:main" from Service Module Loader]
...(more)
What's wrong with it? Why my application can't see apache commons io?
Upvotes: 2
Views: 2798
Reputation: 1234
Well,
Stuff2 seems to be a jar within the EARApp standalone deployment - thus Stuff2 (or EARApp) needs to handle it's own deps, you cannot make that right from the deployment structure of "Some application". Everything is isolated these days.
So simplest solution in your case might be to add a similar jboss-deployment-structure.xml to the META-INF folder of the Stuff2 jar (or EARApp if also Stuff1 needs IO files), and make sure it has a reference to <module name="org.apache.commons.io"/>
. Or, as I'd prefer, instead make sure that your build tool (Maven?) adds a dependencies
attribute to MANIFEST.MF or Stuff2.jar (or EARApp) to org.apache.io and thus you'd not need the jboss-deployment-structure.xml-file.
That being said, this does not seem to be very JEE conformant - you are from "Some Application" (war, ear?) referencing jars inside other EARS? That sounds like trouble to me! You probably have a good reason why you went that direction, but you could of course consider repackage "Some Application" to a JEE standard way. If you'd drop both the Stuff2 jar and Commons IO jar into the lib
folder of "Some Application" you wouldn't need to think JBoss Modules, JBoss descriptor files or even standard descriptor files.
br, Jens
Upvotes: 1