How to know which modules a module depends on in JBoss? - java

How am I supposed to know which dependencies a module need such as the PostgreSQL driver below? If I hadn't Googled it I wouldn't know that. Where am I supposed to find this information?
<module xmlns="urn:jboss:module:1.1" name="org.postgresql">
<resources>
<resource-root path="postgresql-9.1-902.jdbc4.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>

You can use Tattletale.
Tattletale is an excellent tool that recursively scans your
application and provides detailed reports about its contents.
Tattletale 1.2.0.Beta2 or later contains additional support to help
with the new JBoss Modules class loading used in WildFly. Tattletale's
"jbossas7" report can be used to to automatically identify and specify
dependent module names in your application's
jboss-deployment-structure.xml file.
Use Tattletale to find application dependencies

Related

Order of classloading in JBoss 6.4: Is WEB-INF/classes or modules loaded first?

I have a property file named abc.properties in my WAR's WEB-INF/classes. Also, I have placed it inside a (correctly registered) module. When I then call:
ResourceBundle.getBundle("abc")
which file would be picked?
In our production environment, the file placed inside the WAR is being picked (consistently) but in the UAT environment (with the same version of JBoss), its the property file in the module that is getting picked (consistently)
Is there a defined order in which resources are loaded into classpath by JBoss, or does this happen randomly? (We haven't observed any randomness though.)
(The module is correctly registered in the production server, as other resources, namely the ojdbc jar placed in the module are getting loaded correctly)
This is our module.xml in the registered module
<module xmlns="urn:jboss:module:1.0" name="com.oracle">
<resources>
<resource-root path="ojdbc6.jar"/>
<resource-root path="properties"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
abc.properties is placed inside the properties folder as defined in the above module
P.S: I understand that its a wrong practice to have two property files of the same name placed in such a manner, but I want to know why am I seeing such a behaviour.
You can check the official documentation regarding the classloading precedence for EAP 6.4

set provided scope in maven integrated with jboss

I have developed a maven-based project (maven-3.3.9) using jboss-eap-6.4 in IntelliJIDEA 14.0. I am using bouncy castle libraries and I have to set them as provided scope in maven dependency.
Where exactly should I put the bouncy castle jar files?
What configuration should I set?
I have tried two options for the 1st question as follows:
I put jar files here: jboss-eap-6.4\modules\org\bouncycastle\main\
and
I put jar files here: jboss-eap-6.4\modules\system\layers\base\org\bouncycastle\main\
Also, I have provided the following configuration in module.xml beside the jar files:
<?xml version=1.0" encoding=UTF-8"?>
<module xmlns="run:jboss:module:1.1" name="org.bouncycastle">
<resources>
<resource-root path="bcpkix-jdk15on-1.54.jar"/>
<resource-root path="bcprov-jdk15on-1.54.jar"/>
</resources>
<dependencies>
<module name="javax.api" slot="main" export="true"/>
</dependencies>
</module>
However, when I clean and install maven I get the following error:
error during artifact deploment
caused by java.lang.RunTimeException:...
caused by java.lang.NoClassDefFoundError:...
caused by java.lang.ClassNotFoundException:...
The errors you mentioned are deployment errors those are not related to maven.
To add a JBoss module to your application create a file named WEB-INF\jboss-deployment-structure.xml and add the module in dependency. In your case the file content should be as follows.
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="org.bouncycastle"/>
</dependencies>
</deployment>
</jboss-deployment-structure>
The while deployment jboss will load the module in to classpath.

JBoss - How can to exclude javax.validation in jboss-deployment-structure?

I have .war using Jersey REST, and it works in tomCat. But I need to run my .war in JBoss 6.4.0 which causes an exception
java.lang.RuntimeException: java.lang.NoSuchMethodError:
javax.validation.spi.ConfigurationState.getParameterNameProvider()
because JBoss uses old version javax.validation, and I need to exclude javax.validation from deployment of JBoss.
I create jboss-deployment-structure.xml in WEB-INF of .war:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>
<exclude-subsystems>
<subsystem name="resteasy" />
<subsystem name="jpa"/>
<subsystem name="org.hibernate" />
<subsystem name="org.hibernate.validator" />
</exclude-subsystems>
<exclusions>
<module name="javaee.api" />
<module name="javax.ws.rs.api"/>
<module name="org.jboss.resteasy.resteasy-jaxrs"/>
<module name="javax.validation.api"/>
<module name="org.hibernate"/>
<module name="org.hibernate.validator"/>
</exclusions>
</deployment>
</jboss-deployment-structure>
This helped me to exclude javax.ws.rs, but How can to exclude javax.validation? Help me, please
Ok, so You need to exclude not only
<module name="javax.validation.api"/>
itself, but also modules that are dependent on javax.validation.api module. The easiest way to see which modules are dependent on javax.validation.api and force it to be included, even though it was excluded, is to search your .xml files in
JBOSS_DIRECTORY/modules for javax.validation.api, the modules that are dependent have something like that in module.xml:
<dependencies>>
<module name="javax.validation.api"/>
...
And those modules need to be excluded as well. For me - I also needed to exclude:
<module name="javax.faces.api"/>
<module name="org.jboss.resteasy.resteasy-hibernatevalidator-provider"/>
And then, javax validation eclusion was working :)
So, it is something! May be help to someone:
Library javax.validation.api in JBoss - belongs to Implicit module, documentation about implicit module: implicit module dependencies
So implicit modules are Automatic Dependencies, and their can exclusion, about this: class lading and automatic dependencies - part about Automatic Dependencies:
Automatic dependencies can be excluded through the use of jboss-deployment-structure.xml. But this is not work! :(, and JBoss has bug with similar library javax.persistence, and it bug open in tasks.
So - what can to do?
Update JBoss to 7.0.0 version, but now just Alpha and Beta versions :(
Replace old javax.validation.api .jar on new version .jar
(in EAP-6.4.0/modules/system/layers/base/javax/faces/api/main)
Add custom version, and it tangled:
change default config in EAP-6.4.0/modules/system/layers/base/javax/faces/api/main module.xml file, in line <module name="javax.validation.api" export="true"/> remove option export="true", result: <module name="javax.validation.api"/> This changed to allow you add a new custom library javax.validation.
And create custom folder with name 1.1 in EAP-6.4.0/modules/system/layers/base/javax/validation/api, put in 1.1 folder new javax.validation .jar and model.xml.
model.xml:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="javax.validation.api" slot="1.1">
<resources>
<resource-root path="validation-api-1.1.0.Final.jar"/>
</resources>
<dependencies>
<module name="org.jboss.logging"/>
</dependencies>
</module>
params:
slot - name custom folder (1.1),
path - path to .jar library
Last: add module to jboss-deployment-structure.xml in project:
<dependencies>
<module name="javax.validation.api" slot="1.1" export="true"/>
</dependencies>

How to configure Oracle AQ library as a Wildfly 8 module?

I'm currently stuck in the middle of a JBoss migration project from version 4.2.2GA to Wildfly 8.0.0.Final. The project uses the Oracle OCI driver for database access and Oracle AQ with it. Now, I'm starting Wildfly with the environment variable 'LD_LIBRARY_PATH' set to the location where the OCI native implementations reside and everything works fine, except AQ. This is the error I get when the AQ API is used: oracle.jms.AQjmsSession.ociinit([JIIZSII)J: java.lang.UnsatisfiedLinkError: oracle.jms.AQjmsSession.ociinit([JIIZSII)J
This is my module:
path: ${WILDFLY_HOME}/modules/oracle/aq/api/main
contents: aqapi.jar, module.xml
module.xml:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="oracle.aq.api">
<resources>
<resource-root path="aqapi.jar" />
</resources>
<dependencies>
<module name="javax.api" />
<module name="javax.jms.api" />
<module name="oracle.jdbc" />
</dependencies>
</module>
So the question now is, what is the reason Wildfly does not propagate the 'LD_LIBRARY_PATH' to the module classloader?
For older JBoss versions I found this issue: https://issues.jboss.org/browse/SOA-3570 which propagates to put the aqapi.jar into the server lib folder as we are doing so for JBoss 4. But how can I solve this issue for Wildfly? Any Ideas?
Thanks!
After a long journey through the shallows of the internet and many tries a colleague of mine finally found a solution.
The solution was to combine both modules to one jdbc/aq module looking so:
path: ${WILDFLY_HOME}/modules/oracle/jdbcaq/main
contents: ojdbc5.jar, aqapi.jar, orai18n.jar, module.xml
module.xml:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="oracle.jdbcaq">
<resources>
<resource-root path="aqapi.jar" />
<resource-root path="ojdbc5.jar"/>
<resource-root path="orai18n.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.jms.api" />
<module name="javax.transaction.api"/>
</dependencies>
</module>
I think this is somehow related to the module classloaders of wildfly. Maybe the communication between both modules (jdbc and aq) requires the native implementations to be loaded by the same classloader which causes this error when using two modules instead of a single one.
Instead of setting LD_LIBRARY_PATH, a JBoss/WildFly module can also automatically look for native libraries in a module: https://docs.jboss.org/author/display/MODULES/Native+Libraries
So you can load your shared libraries in ${WILDFLY_HOME}/modules/oracle/jdbcaq/main/lib/linux-x86_64/ either by copying .so files or thanks a symbolic link.

CORBA Configuration in JBoss 7.1.1, Unable to get NameService

I'm trying to setup a CORBA enabled application on JBoss 7.1.1 Final. It seems that I'm missing something because everything I try results in another exception. So, what I tried:
standalone -c standalone-ha.xml -Djboss.node.name=nodeA or
standalone -c standalone-full-ha.xml -Djboss.node.name=nodeA
then the 2nd line here
GlobalData.orb = org.omg.CORBA.ORB.init(args, p);
orb.resolve_initial_references("NameService");
throws the exception:
(MSC service thread 1-9) IDL:omg.org/CORBA/ORB/InvalidName:1.0: org.omg.CORBA.ORBPackage.InvalidName: IDL:omg.org/CORBA/ORB/InvalidName:1.0
at org.jacorb.orb.ORB.resolve_initial_references(ORB.java:1343) [jacorb-2.3.1.jbossorg-1.jar:]
at MyApp.startServer(MyApp.java:145) [server.jar:]
My /conf folder contains a jacorb.properties with the entry
ORBInitRef.NameService=corbaloc::localhost:3828/JBoss/Naming/root
Can anyone bring some light into the dark?
Thanks, Peter
I found solution for that problem, Jacorb require mandatory configuration (jacorb.propeity)
you can get that file from JBoss 4.2.2
Then
you need to include that file in your class path, to do that we create custom module
for instance go to jboss modules directory
create sub directory custom/myconfig/main for example
there add your property files
create module.xml file .. you will chose module name... for instnace custom.myconfig
<module xmlns="urn:jboss:module:1.1" name="custom.myconfig">
<properties>
<property name="jboss.api" value="private"/>
</properties>
<resources>
<resource-root path="."/>
<!-- Insert resources here -->
</resources>
<dependencies>
</dependencies>
</module>
In your jboss-deployment-structure.xml include this module to your app
<jboss-deployment-structure>
<ear-subdeployments-isolated>false</ear-subdeployments-isolated>
<deployment>
<dependencies>
<module name="custom.myconfig/>
</dependencies>
<resources>
</resources>
</deployment>
<sub-deployment name="My_WAR.war">
<dependencies>
<module name="custom.myconfig" />
</dependencies>
</sub-deployment>
Hope that help as it work with me

Categories