JBOSS7 won't load deployment structure xml - java

I'm developing some App and at some point I already had code using xmlsec 1.4.3 but JBoss 7 loads by default xmlsec 1.5.1 so my code blows up.
I've been reading through the documentation and ended here: https://docs.jboss.org/author/display/AS7/Developer+Guide#DeveloperGuide-JBossDeploymentStructureFile
So, theoretically if I put the jboss-deployment-structure.xml on my WEB-INF folder (It is reading the XML because I failed writing properly the xsd and JBOSS crashed, and now without the xsd it says nothing) with this content:
<jboss-deployment-structure>
<ear-subdeployments-isolated>true</ear-subdeployments-isolated>
<deployment>
<!-- Exclusions allow you to prevent the server from automatically adding some dependencies -->
<exclusions>
<module name="org.apache.santuario.xmlsec" />
</exclusions>
</deployment>
</jboss-deployment-structure>
Then I would be able to use my xmlsec 1.4.3 and the module of JBOSS would be disabled.
However this isn't working.
What I am missing here? This should work right?

Related

How to make Log4J2 working in JBoss EAP 6.4

I have seen successful instance online to make Log4J2 works in JBoss EAP 6.x
My local war file has specific situation (JBoss EAP 6.4, JDK8):
The war is built on Spring 3 framework, where most logging is made by Apache Common Logging
Logging of the source code in the war is made by Slf4J
However, some in house dependencies in WEB-INF/lib is still made by Log4J 1.2, not slf4J
So I added following dependency to the project, listed below (only list the jar file instead of verbose pom xml):
### spring framework from jcl to slf4j
jcl-over-slf4j-1.7.25.jar
### slf4j to log4j 1.2 then to log4j2
slf4j-log4j12-1.7.25.jar
log4j-1.2-api-2.11.1.jar
### slf4j to log4j 2
slf4j-api-1.7.25.jar
slf4j-simple-1.7.25.jar
log4j-api-2.8.2.jar
log4j-core-2.8.2.jar
log4j-slf4j-impl-2.8.jar
My plan is to tell EAP 6.4 to never use any logging module from JBoss, instead just use whatever is provided from this war, so in the jboss-deployment-structure.xml I create following elements
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<deployment>
<exclude-subsystems>
<subsystem name="logging" />
</exclude-subsystems>
<dependencies>
<module name="oracle" />
</dependencies>
<exclusions>
<module name="org.apache.log4j" />
<module name="org.apache.commons.logging" />
<module name="org.jboss.logging" />
<module name="org.jboss.logging.jul-to-slf4j-stub" />
<module name="org.jboss.logmanager" />
<module name="org.jboss.logmanager.log4j" />
<module name="org.slf4j" />
<module name='org.slf4j.impl' />
<module name='org.slf4j.jcl-over-slf4j' />
</exclusions>
</deployment>
</jboss-deployment-structure>
And when the application starts, I can see following information show up in the server log, extracted here
Adding resource "/C:/Windows/content/MyApp.war/WEB-INF/lib/jcl-over-slf4j-1.7.25.jar" to module deployment.MyApp.war:main
Adding resource "/C:/Windows/content/MyApp.war/WEB-INF/lib/slf4j-log4j12-1.7.25.jar" to module deployment.MyApp.war:main
Adding resource "/C:/Windows/content/MyApp.war/WEB-INF/lib/slf4j-api-1.7.25.jar" to module deployment.MyApp.war:main
Adding resource "/C:/Windows/content/MyApp.war/WEB-INF/lib/slf4j-simple-1.7.25.jar" to module deployment.MyApp.war:main
Adding resource "/C:/Windows/content/MyApp.war/WEB-INF/lib/log4j-1.2-api-2.11.1.jar" to module deployment.MyApp.war:main
Adding resource "/C:/Windows/content/MyApp.war/WEB-INF/lib/log4j-api-2.8.2.jar" to module deployment.MyApp.war:main
Adding resource "/C:/Windows/content/MyApp.war/WEB-INF/lib/log4j-core-2.8.2.jar" to module deployment.MyApp.war:main
Adding resource "/C:/Windows/content/MyApp.war/WEB-INF/lib/log4j-slf4j-impl-2.8.jar" to module deployment.MyApp.war:main
there is not much further information regarding logging in the server log, no error.
However no matter how I configure the log appender (ROL or Console), there is no log4J log generated. I use FileAppender but there is no log file generated.
I don't think it is caused by log4J configuration issue, because same war file with the same log4J2.xml the logging output fine in Tomcat 8
How can I make this right so at least the application output logging successfully.
There are multiple SLF4J bindings in your dependencies:
slf4j-simple-1.7.25.jar
slf4j-log4j12-1.7.25.jar
log4j-slf4j-impl-2.8.jar
Action 1: Remove slf4j-simple and choose one of slf4j-log4j12 or log4j-slf4j-impl.
Beside that, TWO API dependencies for log4j look suspicious:
log4j-1.2-api-2.11.1.jar
log4j-api-2.8.2.jar
Action 2: Remove log4j-1.2-api-2.11.1.jar since you use implementation version 2.8.2 of log4j.

Wildfly logging module exclusion does not work for a large web app

I've written a small web app which disables Wildfly 10.1's slf4j implementation and uses its own logging libraries (logback). It works fine because LoggerFactory.getILoggerFactory() resolves to ch.qos.logback.classic.LoggerContext as result.
But then I use the same code for a larger application (with 52 jar files in WEB-INF/lib/) LoggerFactory.getILoggerFactory() still resolves to a JBoss implementation org.slf4j.impl.Slf4jLoggerFactory, as by default.
How can I investigate what exactly retains server's logging instead of the one of mine? (And fix the situation of course.)
Maven dependencies used: "slf4j-api" 1.6.1, "logback-classic" and "logback-core" 0.9.28.
File jboss-deployment-structure.xml, which is known to be located properly in both cases:
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">
<deployment>
<exclusions>
<module name="org.apache.common.logging"/>
<module name="org.apache.log4j"/>
<module name="org.jboss.log4j"/>
<module name="org.jboss.log4j.logmanager"/>
<module name="org.jboss.logging"/>
<module name="org.slf4j"/>
<module name="org.slf4j.impl"/>
</exclusions>
</deployment>
</jboss-deployment-structure>
I know it's a old topic but i had a similar problem.
So, i will describe the problem and what i done to solve it.
I'm using spring-boot in my web application and running with jboss wildfly 10.
When i try to integrate sentry and logback on my project, the application reads the file logback.xml but use another logging system.
I realized that wildfly was ignoring logback and using jboss-logging instead.
So, i disabled the jboss logging module and than, my application started using logback and everything worked fine.
But this is how i disabled logging sub-system:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<deployment>
<exclude-subsystems>
<subsystem name="logging" />
</exclude-subsystems>
</deployment>
</jboss-deployment-structure>
The link when i found my anwser:

Deployment Order in Wildfly 9

I'm running an Wildfly 9 Application-Server and everything is deployed with "mvn clean install wildfly:deploy" except 2 War Files that are in the wildfly/standalone/deployments folder and are deployed automatically.
My Problem now is: Every other package has to use the 2 war Files (because its a database) and i can't find a way to tell Wildfly to first deploy the files in the deployment folder and then start to deploy the rest.
At the moment i'm working with TimerServices for each Package till the Database is deployed and running, but that is a real bad solution in my Opinion.
Do you know a way to solve this?
Thx in advance
You could create a jboss-deployment-structure.xml to build a dependency from your deployments.
For example, assuming your two wars deployed automatically are named 'alpha.war'/ 'betha.war' and your 'dependent' deployment is called 'omega.war', you just have to create (or edit) the file:
omega.war/WEB-INF(or META-INF for ears)/jboss-deployment-structure.xml
with the content...
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<jboss-deployment-structure>
<deployment>
<dependencies>
<module export="true" name="deployment.alpha.war"/>
<module export="true" name="deployment.betha.war"/>
</dependencies>
</deployment>
</jboss-deployment-structure>

JBoss 6 EAP, how can I change the module load order?

I'm running JBoss 6.1 EAP, one of the default modules has its own version of the org/omg/CORBA/ORB.class file, I want to use my own jar for that file. I've tried including it in my app's war file but it is still picking up the one from the JBoss module.
So the question is, what is the load order of modules in JBoss and how can I change it?
You need to include a jboss-deployment-structure.xml file with your artifact, and configure the file to exclude the container's CORBA impl.
Below is an example which will exclude log4j
<jboss-deployment-structure>
<deployment>
<!-- Exclusions allow you to prevent the server from automatically adding some dependencies -->
<exclusions>
<module name="org.apache.log4j" />
</exclusions>
</deployment>
</jboss-deployment-structure>

How do I disable app server embedded library(jar) for a particular WAR or EAR?

Sometimes you may have a third party libraries in your project which can cause conflicts with you server-embedded jars. Removing embedded jars from your application server lib folder can break other deployed apps.
Is there a way to disable server-embedded jars for only one project in TomEE, JBoss, GlassFish?
In JBoss, you can disable container managed libraries with a jboss-deployment-structure.xml descriptor in your WEB-INF directory.
<jboss-deployment-structure>
<deployment>
<!-- Exclusions allow you to prevent the server from automatically adding
some dependencies -->
<exclusions>
<!-- This will cause the JBoss container to not provide your deployed
application's log4j dependencies. This way you can use an implementation
deployed with your artifact. -->
<module name="org.apache.log4j" />
</exclusions>
</deployment>
</jboss-deployment-structure>
The documentation for class loading in JBoss AS 7 can be found here.

Categories

Resources