EAP 7: Ignore or exclude Dependencies from 3rd party liberies MANIFEST.MF - jboss

In our war we bundle some 3rd party libraries that contain the Dependencies entries in their MANIFEST.MF files. JBoss modules with such names exist, so JBoss adds them to the application dependency list which causes that these JBoss-provided modules are used.
As we bundle all the required libraries in the war (they're different versions than those provided by JBoss anyway) we want to use these instead. However we don't seem to be able to exclude those undesired dependencies in any easy way so that we wouldn't have to modify those 3rd party libraries. jboss-deployment-structure.xml would be great, but excluding those modules here doesn't seem to have any effect.
Is there any way how to ignore the Dependencies entries in MANIFEST.MF files, or any other way how to force exclude those dependencies?

On a module dependency you can define the imports element and filter with exclude and include the paths inside your module that you don't want to be 'seen'. Something like this should work:
<imports>
<exclude-set>
<path name="META-INF/services"/>
</exclude-set>
</imports>

Related

Skinny War file with Maven in Eclipse

I have a Maven project 'Project A' which contains dependencies. I have a requirement to abstract the dependencies from this project into another project called 'Shared Lib' so that I can make what is called a "Skinny War" file from Project A. Both these files will then be uploaded to a Weblogic server.
However, I am having a lot of difficulties being able to get Project A to pick up the dependencies in Shared Lib.
Some guidance on how I should approach this problem would be much appreciated.
Thanks!
I would split the maven project into two modules. If we call one module SharedLib and the second one Skinny War then you will have something like:
<modules>
<module>sharedLib</module>
<module>skinnyWar</module>
</modules>
In the shared lib module pom.xml you will fill all the dependencies required for the project. In the skinnyWar module your first dependency in the list will be for the sharedLib module. You might need to setup the assembly plugin for the sharedLib module to create a jar in the package phase and you are good to go ;)
Some food of though - do you really want to do this? An important part about using maven is to take care of dependencies for you and package a easy to deploy jar. If you create two different jars it would cause all other kinds of troubles like - were both deployed. Are we using an older version of the dependencies etc.

Having a jboss-deployment-structure.xml with dependencies in common libraries

I have a small issue that is annoying me somewhat. We have built numerous commons libraries for all our applications deployed on JBoss/Wildfly. Some of those common libraries have dependencies to JBoss modules.
The common way for EAR and WAR files is to add a jboss-deployment-structure.xml to the archive, which contains a bunch of module-dependencies.
I have tried several times to add a jboss-deployment-structure.xml to my Commons JARs so that the WAR/EAR-archives that import them will automatically see the dependencies the JAR has as it's own, however, no attempt of doing this renders the correct result.
Has anyone successfully managed to declare "transitive" dependencies in JAR-files packed inside of WAR-files without having to redeclare the same dependencies in the WAR-file's jboss-deployment-structure.xml?
Any examples would be greatly appreciated!
You can use the MANIFEST.MF to declare dependencies for a JAR. The line will look something like:
Dependencies: org.some.module, org.another.module
The Maven plugin maven-jar-plugin will add it for you as part of the build process.
Your best option is to create your own JBoss module to hold all your common JARs used by all your different applications. This module would have it's own module.xml file declaring the dependencies on the JARs contained within it and one any libraries on other JBoss modules. These custom modules can also be versioned and applications can also depend on specific versions.

How can I combine our bundles with third party libraries into one large bundle for others use?

There is more than one bundles in our project when we develop RCP product.
We could have one bundle maybe named common-xxx that would provide some utils method for other bundle using it.
I want to add some 3rd party jars (such as Apache or log4j etc ) into this common-xxx bundle and therefore others should use its API.
How can I do this?
In the MANIFEST.MF editor put your jars in the plugin 'Classpath' (on the 'Runtime' tab) - this will add the jars to the manifest Bundle-ClassPath.
Then add the packages you want the plugin to export the the Exported Packages (also on the 'Runtime' tab). This will add the packages to the Export-Package entry in the manifest.
With these two entries the jar packages will be available to other plugins which have your plugin as a dependency.

JBoss 7, how to add library module to eclipse project build path

I wanted to move from jboss AS 6 to 7 with hibernate 4 support and now all libraries are in subfolders with module.xml files.
And I have no idea how to add those to my eclipse project build path.
Where do I define my module dependencies?
The easiest way is to do Build Path > Add External Archives and select the jars you want.
Slightly better might be to define a JBOSS_HOME classpath variable, and add the jars as variable entries. That would make things easier if you ever move your JBoss installation.
If you wanted more automation, it would be possible to write a script, for whatever build tool you use, that parses your application's manifest to find which modules it depends on, and add those to your classpath automatically. If you're good at scripting, that should be quite easy.

JBoss Custom lib directory

I have this third party framework which comes with a huge set of dependent libraries, which by the way, have not yet been indexed in any Maven repository. I want to use this framework with some Web Apps, but for obvious reasons I don't want to put all those libraries under WEB-INF/lib, neither do I want just to place them all under server/default/lib to avoid mixing them with other local and third party libraries.
Is there some way under JBoss 4.2.2 or higher to specify a custom lib directory for certain Web Apps? It's possible and/or advisable to have something like server/default/lib/myAppLib?
Any suggestion on this regard?
You can add the following entry in your server/default/conf/jboss-service.xml for putting your jars in server/default/myLibDir:
<classpath codebase="myLibDir" archives="*"/>
To my knowledge, you have three options:
Package you WARs in an EAR and move the library JARs out of WEB-INF/lib and
place them in a lib folder at the root of the EAR. No extra configuration required. This (non portable) solution is described in Configuring JBoss shared libs.
Move the library JARs out of WEB-INF/lib and place them into server/xxx/lib.
Deploy the JARs in the deploy/ folder and disable WAR file class loader isolation.
I don't recommend option #3. Option #2 is what you don't want. This leaves us with option #1 (which is IMO the cleanest).
Related questions
Jboss shared library
In JBoss can I configure a “shared library” location?