Monday, November 11, 2013

Disable, Exclude JBoss EAP 6 Logging : Exclude Logmanager Module

Removed
The JBoss EAP 6 comes with a new look :). It is no more the same directory structure, modules ...


I was trying to move from JBoss as 5 to JBoss 6. After a hard work, I have discovered that the JBoss 6 is End Of Life.


Ok no prblem. Let's move to JBoss EAP6 which uses JBoss as7. Go go go.
After fixing the dataSource configuration, which you can consult in this link. I was happy to deploy for the first time my application. And here Boooom. I get multiple errors ;(.

I have this error message :

[org.jboss.msc.service.fail] (MSC service thread 1-8) MSC000001: Failed to start service jboss.deployment.unit."myapp.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.unit."myapp.war".POST_MODULE: JBAS018733: Failed to process phase POST_MODULE of deployment "myapp.war"

Caused by: java.lang.NoClassDefFoundError: javax/mail/internet/AddressException
at java.lang.Class.getDeclaredConstructors0(Native Method) [rt.jar:1.6.0_20]
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389) [rt.jar:1.6.0_20]
at java.lang.Class.getConstructor0(Class.java:2699) [rt.jar:1.6.0_20]
at java.lang.Class.newInstance0(Class.java:326) [rt.jar:1.6.0_20]
at java.lang.Class.newInstance(Class.java:308) [rt.jar:1.6.0_20]
at org.apache.log4j.xml.DOMConfigurator.parseAppender(DOMConfigurator.java:247) [log4j-jboss-
Caused by: java.lang.ClassNotFoundException: javax.mail.internet.AddressException from [Module "org.jboss.log4j.logmanager:main" from local module loader @1b64e6a (finder: local module finder @1d62270 (roots: C:\jboss-eap-6.1\modules,C:\jboss-eap-6.1\modules\system\layers\base))]

In fact, as my application uses log4j which is also provided by JBoss. This later will try implicitly to load this module. In the internet, I have discovered that there is an open bug regarding this error. So in order to control this loading, JBoss proposes to use the jboss-deployment-structure.xml. We will not use the Log4j provided by JBoss and use the old method by providing our jar and log4j.xml file.

Step 1 :

Create a jboss-deployment-structure.xml under WEB-INF/  directory.



Step 2 :

Make sure that you put the log4j.jar in the  WEB-INF/lib  directory.


Finally add this parameter "-Dorg.jboss.as.logging.per-deployment=false "in the VM:



Coool it's deploying now :)

8 comments :

  1. Hi,

    Greetings,

    Where to add this VM params

    ReplyDelete
    Replies
    1. Hi,

      Using Eclipse, you need to double clic on the server. A page specific to JBoss will open. Clic on "Open Launch Configuration" and their you will find VM arguments. Add the parameters at the end.

      Delete
  2. Hi

    I am again,

    Is there way , we can remove the apache log in standalone.xml? basically i am looking i need the log4j need to used not the jboss server log4j.

    Thanks in Adv

    ReplyDelete
    Replies
    1. In this post, it is about how to use the apache log4j, we are not using the jboss logging (we are excluding it). Have a look also to this post :
      http://mariemjabloun.blogspot.com/2014/05/resolved-logging-in-jboos-eap-6-spring.html

      Delete
  3. Hi Mariem,

    Could you please help on that error which I got a week ago and still I'm trying to fix it but no success.

    23:15:20,653 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC00001: Failed to start service jboss.deployment.unit."MyProject.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.unit."MyProject.war".POST_MODULE: Failed to process phase POST_MODULE of deployment "MyProject.war"
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [rt.jar:1.7.0_51]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.7.0_51]
    at java.lang.Thread.run(Unknown Source) [rt.jar:1.7.0_51]
    Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 0
    at java.lang.String.charAt(Unknown Source) [rt.jar:1.7.0_51]
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:460)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
    at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
    at org.jboss.as.jaxrs.deployment.JaxrsScanningProcessor.checkDeclaredApplicationClassAsServlet(JaxrsScanningProcessor.java:288)
    at org.jboss.as.jaxrs.deployment.JaxrsScanningProcessor.scanWebDeployment(JaxrsScanningProcessor.java:155)
    at org.jboss.as.jaxrs.deployment.JaxrsScanningProcessor.deploy(JaxrsScanningProcessor.java:104)
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
    ... 5 more

    Thanks in advanse.

    ReplyDelete
    Replies
    1. Hi Nguyen,

      Are you using in your code string.charAt( ) because according to the error it seems that the errors comes from that. So you are getting IndexOutOfBoundsException because either the index is negative or greater that the length of the String.

      Delete
  4. I don't have anywhere used charAt() or something related to indexes.

    The strangest thing is that on Windows my project is working properly but on Linux it is not.

    ReplyDelete

Articles les plus consultés