JBoss AS 7.1.1 Final and Log4j-extras - jboss

I want to add log4j-extras jar in my jboss server but i don't know how to do this correctly.
I put apache-log4j-extras-1.2.17.jar into jboss_HOME/modules\org\apache\log4j\main (same location as log4j-1.2.16.jar) and my module.xml looks like :
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="org.apache.log4j">
<properties>
<property name="jboss.api" value="private"/>
</properties>
<resources>
<resource-root path="log4j-1.2.16.jar"/>
<!-- Insert resources here -->
<resource-root path="apache-log4j-extras-1.2.17.jar"/>
</resources>
<dependencies>
<module name="org.dom4j" optional="true"/>
<module name="javax.api"/>
<module name="org.jboss.logmanager"/>
<module name="org.jboss.modules"/>
</dependencies>
</module>
After start jboss, i have new files in the directory :
apache-log4j-extras-1.2.17.jar.index and log4j-1.2.16.jar.index
I have an application which use an external log4j.properties.
The configuration is ok but when i try to add "log4j.appender.test=org.apache.log4j.rolling.RollingFileAppender", i have the error message "log4j:ERROR Could not instantiate class [org.apache.log4j.rolling.RollingFileAppender]"
So i guess that the add of log4j-extras is not ok.
Can someone tell me the correct configuration to do in jboss ? (maybe the module.xml is not correct or i need to create an other directory in module ?)
Thanks a lot !

Related

How to force wildfly-8.2.1.Final to load .class from a directory rather than war?

I want load .class file from a given directory so, i put compiled file inside the directory /opt/wildfly-8.2.1.Final/modules/packagename/ and also server load the classes from the same directory rather than war(WEB-INF/classes/packagename/).
I haven't tried this method myself, but you must:
Move /opt/wildfly-8.2.1.Final/modules/packagename/ to
/opt/wildfly-8.2.1.Final/modules/custom-classes/main/packagename/
Add file module.xml to
/opt/wildfly-8.2.1.Final/modules/custom-classes/main/
Add file jboss-deployment-structure.xml to your war.
Undeploy the war, restart the server and then redeploy the war.
Content of module.xml:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.3" name="custom-classes">
<resources>
<resource-root path="."/>
</resources>
</module>
Contents of jboss-deployment-structure.xml:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="custom-classes" />
</dependencies>
</deployment>
</jboss-deployment-structure>
Edit: If you want to add jars as well as non-jared classes to your module you must not only copy jars to /opt/wildfly-8.2.1.Final/modules/custom-classes/main/, but also list jars in module.xml like this:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.3" name="custom-classes">
<resources>
<resource-root path="."/>
<resource-root path="dependency1.jar"/>
<resource-root path="dependency2.jar"/>
<!-- and so on for other jars -->
</resources>
</module>
Resources:
Class Loading in WildFly
How to write jboss-deployment-structure.xml
How to ad directory to JBoss classpath

Jboss EAP7/Wildfly Oracle datasource error: Services with missing/unavailable dependencies

I'm using Jboss EAP 7.1 now, recently I add the Oracle datasource to the server as the datasource I correctly configured before. But I got the error message:
Services with missing/unavailable dependencies" => [
"org.wildfly.data-source.CreditDS is missing [jboss.jdbc-driver.oracle11g]"
CreditDs is my JNDI name and oracle11g is the driver name. Here are my configuration:
<!-- standalone.xml -->
<datasource jndi-name="java:jboss/datasources/CreditDS" pool-name="CreditDS" enabled="true">
<connection-url>jdbc:oracle:thin:#***</connection-url>
<driver>oracle11g</driver>
…… …… ……
</datasource>
<drivers>
<driver name="oracle11g" module="com.oracle.ojdbc14">
<xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
</driver>
</drivers>
Here is the modules.xml in modules/com/oracle/ojdbc14/main
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="com.oracle.ojdbc14">
<resources>
<resource-root path="ojdbc14-10.2.0.4.0.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
What's wrong?
I guess your oracle module is not recognized correctly.
The procedure for adding oracle JDBC module is as follows:
1 create folder com/oracle/ojdbc14/10.2.0.4.0 withing JBOSS_HOME/modules directory
2 copy your oracle jar file to the folder and add a module.xml with the following contents
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.3" name="com.oracle.ojdbc14" slot="10.2.0.4.0">
<resources>
<resource-root path="ojdbc14-10.2.0.4.0.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
3 Create driver definition in standalone.xml
<driver name="oracle14" module="com.oracle.ojdbc14:10.2.0.4.0">
<xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
</driver>
Couple of things to note:
Do pay attention to correct version of JBoss modules XMLNS - you tagged your questions with EAP7 - so you should use xmlns 1.3.
Note the slot value in both modules.xml and driver definition. This could be any value, but it is a good practice to use the lib version.
After adding any modules into JBoss, you need to restart it completely(restart JVM).
Lastly, you should use an up-to-date version of Oracle JDBC driver as ojdbc14 are not supported anymore, so it should be like this:
Module.xml
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.3" name="com.oracle.ojdbc7" slot="12.1.0.2">
<resources>
<resource-root path="ojdbc7-12.1.0.2.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
Folder modules/com/oracle/ojdbc7/12.1.0.2
Driver:
<driver name="oracle7" module="com.oracle.ojdbc7:12.1.0.2">
<xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
</driver>

How to configure a new module in JBoss AS 7.1.3?

This question is a spinoff of this one!
I now can configure my project to use a different version of Hibernate and my JBoss installation has a second slot named "5.1.1.Final" (located at ...\jboss-as-7.1.3.Final\modules\org\hibernate\5.1.10.Final) that has the following module.xml file:
<module xmlns="urn:jboss:module:1.1" name="org.hibernate:5.1.10.Final">
<resources>
<resource-root path="hibernate-core-5.1.10.Final.jar"/>
<resource-root path="hibernate-entitymanager-5.1.10.Final.jar"/>
<resource-root path="hibernate-infinispan-5.1.10.Final.jar"/>
<!-- Insert resources here -->
</resources>
<dependencies>
<module name="asm.asm"/>
<module name="javax.api"/>
<module name="javax.persistence.api"/>
<module name="javax.transaction.api"/>
<module name="javax.validation.api"/>
<module name="org.antlr"/>
<module name="org.apache.commons.collections"/>
<module name="org.dom4j"/>
<module name="org.infinispan" optional="true"/>
<module name="org.javassist"/>
<module name="org.jboss.as.jpa.hibernate" slot="4" optional="true"/>
<module name="org.jboss.logging"/>
<module name="org.hibernate.envers" services="import" optional="true"/>
<module name="org.hibernate.commons-annotations"/>
</dependencies>
</module>
However, when JBoss starts I receive the following error message: ParseError at [row,col]:[26,72] Message: Invalid/mismatched module name (expected org.hibernate:5.1.10.Final).
I can't understand why this message, since the required module name (org.hibernate:5.1.10.Final) is the exact name I specified at the file (name="org.hibernate:5.1.10.Final");
What am i missing?
The slot is a separate attribute. It should look like the following.
<module xmlns="urn:jboss:module:1.1" name="org.hibernate" slot="5.1.10.Final">
On a side note you may want to consider trying to upgrade to WildFly 11, current release is WildFly 11.0.0.Beta1. I'm not sure if Hibernate 5.1.x will work with JBoss AS 7.x. WildFly 10.1.0.Final uses Hibernate 5.0.10.Final.

Path setting for DLL's in JBOSS 7.1.1

We have some DLL's which are related to Java,VB. In Joss 4.X , We used to place in bin directory under Application Server.
We migrated to JBOSS 7.1.1 and when I removed from bin directory and placed them in libraries folder under C:\jboss-as-7.1.1.Final\modules\com\correction\main\libraries .
I am getting this exception
java.lang.UnsatisfiedLinkError: no xxxJavaWrapper in java.library.path
java.library.path = C:\Program Files\Java\jdk1.6.0_24\bin;.;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\apache-maven-3.0.4;C:\apache-maven-3.0.4\bin;C:\Python27;C:\Program Files\Java\jdk1.6.0_24;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem
java.lang.UnsatisfiedLinkError: com.xxxJavaWrapperJNI.new_xxx()J
module.xml
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="com.correction">
<resources>
<resource-root path="xxx.jar"/>
<resource-root path="xyz.jar"/>
<resource-root path="libraries"/>
</resources>
<dependencies>
<system export="true">
<paths>
<path name="libraries"/>
</paths>
<exports>
<include-set>
<path name="libraries"/>
</include-set>
</exports>
</system>
</dependencies>
</module>
But I place the same dll's in bin folder, it is working fine.
I want to place them in module folder and set the path from there instead of bin so that I can have all the application related jar's, properties and dll files at one place for ease maintainance.
Also I want to know how to set the path of txt and properties files in jboss 7.1.1
Regards
Srini
Configure module.xml as below:
<module xmlns="urn:jboss:module:1.1" name="com.correction">
<resources>
<resource-root path="xxx.jar"/>
<resource-root path="xyz.jar"/>
<resource-root path="lib/win-x86_64"/>
</resources>
<dependencies>
<module name="sun.jdk"/>
</dependencies>
</module>
Put the DLLs into the directory lib/win-x86_64. Check the another dependencies of your project.
In WEB-INF of your application creating the file jboss-deployment-structure.xml and put the content below:
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="com.correction"/>
</dependencies>
</deployment>
</jboss-deployment-structure>
That's all.
Another Question: How can you make these properties files accessible to applications deployed on JBoss 7?
create a custom module where you put your properties files and put jboss-deployment-structure.xml to your application archive (WAR/EAR) to use that custom module.
Create the new module directory under $JBOSS_HOME/modules(using app/conf in this example)
mkdir -p $JBOSS_HOME/modules/app/conf/main/properties/
Put your properties files in $JBOSS_HOME/modules/app/conf/main/properties/
Create a module.xmlhere $JBOSS_HOME/modules/app/conf/main/module.xml
<module xmlns="urn:jboss:module:1.1" name="app.conf">
<resources>
<resource-root path="properties"/>
</resources>
</module>
put the following jboss-deployment-structure.xml in WEB-INF:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="app.conf" />
</dependencies>
</deployment>
</jboss-deployment-structure>
Then you can access your properties files using thecode below (example assumes you have a
example.propertiesfile in $JBOSS_HOME/modules/app/conf/main/properties/)
Thread.currentThread().getContextClassLoader().getResource("example.properties");
Ps: I used JBoss AS 7.1.2 ( JBoss EAP 6 )
Regards
Mauricio Magnani

JBoss AS 7 modules: can do a module with all libraries in a directory?

I want to define a module with a resource-root like this:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="com.mymodule">
<resources>
<resource-root path="libs"/>
</resources>
<dependencies />
</module>
The directory contains all the libraries I need.
I've tried it and it not work, but if I put it this way it work:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="com.mymodule">
<resources>
<resource-root path="libs/lib1.jar"/>
<resource-root path="libs/lib2.jar"/>
<resource-root path="libs/lib3.jar"/>
<resource-root path="libs/lib4.jar"/>
........
</resources>
<dependencies />
</module>
Is there a way to do it the first?
Try and use libs.* in your first implementation
UPDATE:
This feature is not currently available, though its under R&D
If you need to include multiple jars in a module, you will need to instantiate each indivisually
I know this one is old, but I just had the same problem on EAP-7 and solved it as follows:
You may want to create the module using the JBoss CLI. My problem was to supply multiple resources as it was yours. I am using the attribute resource-delimiter and provide my list of resources as follows:
module add --name=my.module --resource-delimiter=, --resources=libA.jar,libB.jar,libC.jar --dependencies=my.dep.a,my.dep.b
This generates the following module.xml in the respective JBoss folder:
<?xml version="1.0" ?>
<module xmlns="urn:jboss:module:1.1" name="my.module">
<resources>
<resource-root path="libA.jar"/>
<resource-root path="libB.jar"/>
<resource-root path="libC.jar"/>
</resources>
<dependencies>
<module name="my.dep.a"/>
<module name="my.dep.b"/>
</dependencies>
</module>
Hope it helps.