Ear,Startup , Log4j
ilyae May 15, 2014 7:04 AMHi.
We had some issues with log4j using WildFly8.0.0 final.
We resolved it already and I wanted to share our experience and receive some feedback.
Background.
It's a complex legacy system , development started back in 2000.
Deployment structure is
Ear
lib(contains log4j.jar)
Ejb1..EjbN
War1...WarN
We have our custom wrapper around log4j which actually just initializes log4j from a custom configuration file .
It's just another home made logger facade.
The initialization triggered by StartupServlet in one of the war files.
The logger supposed to be a singleton shared by all ejb's and war components in the ear.
The issue we initially had was that logger was initialized properly but during runtime whenever we tried to retrieve a logger for specific category
it failed and instead we got a root logger .
After some investigation I realized that there is another logj4 module and we need to exclude it from EAR classpath
by adding a exclusion element to the deployment descriptor jboss-deployment-structure.xml
<exclusions>
<module name="org.apache.log4j" />
</exclusions>
It solved most of the issues but one. There was an ejb witch had a class from log4j in it's interface so it failed during deployment.
After some more investigation I've added another element
<sub-deployment name="someEJB.jar">
<exclusions>
<module name="org.apache.log4j" />
</exclusions>
</sub-deployment>
and this seems to solve the issues we have for now.
It seems a little bit strange to configure module exclusion for each ejb (sub deployment) separately.
Also what would be the right way to initialize some singleton in the ear scope today.
I'm thinking about @Singleton and @Startup session bean
Also probably need to refactor the custom logger and use slf4j instead.
We must be able to deploy the Ear not only in WildFly but in other app servers per customer request.
I'm also very much interested in class loading mechanism in WildFly .
What is a module actually a module in our case (war , ear , all of the above)?
I saw some articles about it but would be happy to read more detailed explanation with examples etc ...
Can anyone please comment ?
Best
Thanks to all