I've been having problems with jboss/logback and I made a jboss-deployment-structure.xml and it looks like this
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<ear-subdeployments-isolated>false</ear-subdeployments-isolated>
<deployment>
<!-- Exclusions allow you to prevent the server from automatically adding
some dependencies -->
<exclusions>
<module name="org.apache.commons.logging" />
<module name="org.slf4j" />
<module name="org.slf4j.ext" />
<module name="org.slf4j.impl" />
<module name="org.apache.log4j" />
</exclusions>
</deployment>
</jboss-deployment-structure>
this is in the META-INF folder of the EAR, but now I've been thinking... the EAR also has a lib folder that has:
slf4j-api.jar,
logback-classic.jar,
logback-core.jar, and
log4j-over-slf4j.jar
as well as the other two other ejb projects wrapped up in it during deployment time.
my question is, do I have to specify the jars and other other ejb projects as sub-deployments in the jboss-deployment-structure.xml??
also, the jboss-deployment-structure.xml has been basically ignored everytime I deploy the ear and start the server, i know this because the server still is accessing the exclusions i have declared, is the xml in the right spot in the meta-inf of the ear?
thank you for the help
Yes I added the jars as subdeployments and fixed errors
Related
So we have found that JBoss 7.1 EAP provides its own version of Jackson-Databind. This version interferes with our deployment as we have a newer version in the WAR. We've proven out this theory by including this jboss-deployment-structure.xml at the WAR level's WEB-INF:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>
<exclude-subsystems>
<subsystem name="jaxrs"/>
</exclude-subsystems>
</deployment>
</jboss-deployment-structure>
This lets the WAR deploy on its own without errors when it previously received the errors.
However, when trying to implement the same solution at the EAR level of deployment I've been unsuccessful. I've tried putting the jboss-deployment-structure.xml in the META-INF, WEB-INF, and root level of the EAR. I've done that with all number of different configurations but I can't get it to correctly exclude jaxrs. It's worth mentioning that this is my first run on JBoss configurations and I could be missing something incredibly simple.
EAR level file:
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<deployment>
<exclude-subsystems>
<subsystem name="jaxrs" />
</exclude-subsystems>
</deployment>
<sub-deployment name="myWar.war">
<exclude-subsystems>
<subsystem name="jaxrs" />
</exclude-subsystems>
</sub-deployment>
</jboss-deployment-structure>
So, turns out that this was the answer. Just as it stands here. Another developer put the same file into his build and it worked. I don't know what the difference was between his environment and mine but I'm marking this question resolved.
I didn't think I would end up here but after a lot of Google and StackOverflow searches here I'm.
This is my exact problem except that I can't afford to make code changes.
The WAR I'm trying to deploy includes a JMS library (i.e. javax.jms, which I cannot exclude form the WAR.) which is already loaded by Jboss EAP 7 by default. The path to jar is something like this jboss/modules/system/layers/base/javax/jms/api/ain/jboss-jms-api_2.0_spec-1.0.0.Final-redhat-1.jar. Because of this two different versions of the same classes loading I'm getting ClassCastException.
org.apache.activemq-ra.ActiveMQConnectionFactory cannot to be cast to javax.jms.ConnectionFactory
So, I want Jboss to NOT load javax.jms so that my application can use the JAR included with the WAR.
So, I was wondering if there was any way to exclude the module globally (for all WAR deployments).
Excluding it per deployment would work too. And I do realize it can be acheivd using jboss-deployment-structure.xml but I can't get it to work.
Here is what I tried:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure
xmlns="urn:jboss:deployment-structure:1.2">
<deployment>
<exclude-subsystems>
<subsystem name="javax" />
<subsystem name="javax.jms" />
</exclude-subsystems>
</deployment>
</jboss-deployment-structure>
and
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure
xmlns="urn:jboss:deployment-structure:1.2">
<deployment>
<exclusions>
<module name="javax" />
<module name="javax.jms" />
<module name="javax.jms.api" />
</exclusions>
</deployment>
</jboss-deployment-structure>
I placed the file in WEB-INF directory. It didn't work. It still loaded the JMS class from modules folder of Jboss EAP. So, how do I correctly do this?
The correct jboss-deployment-structure.xml is here:
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<deployment>
<exclude-subsystems>
<subsystem name="messaging-activemq"></subsystem>
</exclude-subsystems>
<exclusions>
<module name="javax.jms.api"></module>
</exclusions>
</deployment>
</jboss-deployment-structure>
This way you exclude both messaging subsystem and the JMS api.
You should remove the JMS API JAR from your deployment. You can still keep the JMS implementation JAR in your deployment but that should probably end up in a RAR, preferably outside your deployment.
This link has some things you could try.
Notably:
I think the problem is that activemq-all-5.4.2.jar contains javax.jms.*. Your deployment already gets this implicitly from the javaee.api module (see more information about implicity module dependencies here). I don't think it is appropriate for an application module/jar to package Java EE interfaces. You can try simply deleting the javax directory from activemq-all-5.4.2.jar or using a different set of ActiveMQ jars in your module to limit it to only what you need.
and/or altering your module.xml for ActiveMQ
<module xmlns="urn:jboss:module:1.0" name="activemq">
<resources>
<resource-root path="activemq-all-5.4.2.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
</dependencies>
</module>
There appears to be a method to embed ActiveMQ in Jboss as well, if you're interested. I won't pull out information from that article, as it doesn't answer the original question.
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>
I am programming in Java. I have used executor service. Logs are printing in the specified trace.log file for the main thread. But for the threads created by the executor service, logs are getting printed in the Jboss server.log. How to get these logs in the trace.log instead of in server.log?
I found the concurrency should not affect the functionality of slf4j.
Is SLF4J good to be used in a multithreaded application for logging to a database?
Could somebody please tell what am I missing here?
Thanks in advance.
You have to exclude SLF4J from JBoss. You can do it with jboss-deployment-structure.xml
My jboss-deployment-structure is located in EAR module under resources/META-INF folder and looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">
<deployment>
<exclusions>
<module name="org.slf4j" slot="main" />
<module name="org.slf4j.impl" slot="main" />
</exclusions>
</deployment>
<sub-deployment name="some-war.war">
<exclusions>
<module name="org.slf4j" />
<module name="org.slf4j.impl" />
</exclusions>
</sub-deployment>
In some-war.war module I can use logback which logs properly into defined files.
I'm am having trouble logging using my appenders defined on my XML log4j configuration file.
I created the jboss-deployment-structure.xml on my EAR's META-INF folder with no sucess.
The jboss-deployment-structure.xml structure is:
<jboss-deployment-structure>
<ear-subdeployments-isolated>false</ear-subdeployments-isolated>
<deployment>
<exclusions>
<module name="org.apache.log4j" slot="main"/>
</exclusions>
</deployment>
</jboss-deployment-structure>
I have even tried to edit my standalone.conf.bat file adding the following line:
set "JAVA_OPTS=%JAVA_OPTS% -Dorg.jboss.as.logging.per-deployment=false"
My application deployment is like this:
-> MyAppEAR.ear
-> META-INF
-> MANIFEST.MF
-> MyAoo.war
-> META-INF
-> MANIFEST.MF
-> jboss-deployment-structure.xml
-> WEB-INF
-> web.xml
-> lib
-> log4j-1.2.17.jar
-> ---
-> classes
-> log4j.xml
-> ...
I've noticed the following error:
jboss-deployment-structure.xml in subdeployment ignored. jboss-deployment-structure.xml is only parsed for top level deployments.
I even tried migrating from JBOSS 7.1.0 to 7.1.1
Some help please!
Thanks
Thanks for the repply James.
I did what you said and moved the jboss-deployment-structure.xml file to MyAppEAR.ear/META-INF.
I've noticed that this way the exception:
jboss-deployment-structure.xml in subdeployment ignored. jboss-deployment-structure.xml is only parsed for top level deployments.
... doesn't occur. I don't know if that means that the file was parsed... how can I tell?
Despite of this new behaviour my log4j.xml configuration file still isn't loaded and the logger used still is Log4J's.
I know this becaused I wrote to the console:
System.out.println(Logger.getRootLogger().getClass().toString())
...and got:
class org.jboss.logmanager.log4j.BridgeLogger
I've also tried:
moving my log4j.xml to MyAppEAR.ear/META-INF.
removing the unecessary -Dorg.jboss.as.logging.per-deployment=false from standalone.conf.bat
removing slot from my jboss-deployment-structure.xml
Any more ideas?
Thanks
Hi RedEagle see the following configuration which i have tested and its working fine...
Step-1
Create a new module as
jboss-as-7.1.1.Final/modules/com/company/mylog/main/
-module.xml
-log4j-1.2.14.jar
Content of module.xml
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="com.company.mylog">
<resources>
<resource-root path="log4j-1.2.14.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
</dependencies>
</module>
Step-2
Now IN my.ear/META-INF/
-jboss-deployment-structure.xml
-MANIFEST.MF
content of jboss-deployment-structure.xml
<jboss-deployment-structure>
<deployment>
<exclusions>
<module name="org.apache.log4j" />
</exclusions>
</deployment>
<sub-deployment name="MyWeb.war">
<exclusions>
<module name="org.apache.log4j" />
</exclusions>
</sub-deployment>
<sub-deployment name="MyBeans.jar">
<exclusions>
<module name="org.apache.log4j" />
</exclusions>
</sub-deployment>
</jboss-deployment-structure>
Content of MANIFEST.MF
Manifest-Version: 1.0
Dependencies: com.company.mylog
Step-3
Content of MyLogger.java
public static Logger getLogger(String name) {
Logger logger= LogManager.getLogger(name);
PropertyConfigurator.configure("log4j.properties"); //Path to log4j.properties as many option available in my case for testing i used static path /home/gyani/log4j.properties
return logger;
}
Step-4
Here is log4j.properties
log4j.rootLogger=info,gyani
log4j.appender.gyani=org.apache.log4j.RollingFileAppender
log4j.appender.gyani.File=/home/gyani/myserverlog.log
log4j.appender.gyani.Append=true
log4j.appender.gyani.MaxFileSize=100000KB
log4j.appender.gyani.MaxBackupIndex=10
log4j.appender.gyani.layout=org.apache.log4j.PatternLayout
log4j.appender.gyani.layout.ConversionPattern=[%d{MMM d HH:mm:ss yyyy}] [%-5p] [%c]: %m%n
Your jboss-deployment-structure.xml needs to be in your MyAppEAR.ear/META-INF directory. There is also no need for the slot attribute for this case.
Also the -Dorg.jboss.as.logging.per-deployment=false isn't used in JBoss AS 7.1.1.Final, but it doesn't hurt anything either.