5 Replies Latest reply on Oct 31, 2014 12:05 PM by mcclane

    ClassCastException: org.jboss.logmanager.log4j.BridgeLogger

    sjain24

      How do I fix this error? One of my classes calls a esapi class that gets this logger from the LoggerFactory. I want to have org.apache.log4j logger which is also implicit to AS7.

      I've tried :

      1. Exclusions in jboss-deployment-structure.xml -

      <deployment>

           <exclusions>

             <module name="org.jboss.logmanager" />

             <module name="org.jboss.logmanager.log4j" />      

           </exclusions>

           <dependencies>

            <module name="org.apache.log4j"/>

           </dependencies>

         </deployment>

       

      2. I've also tried the exclusion at sub-deployment level.

      3. I've tried adding org.apache.log4j dependency in manifest for my ear.

      4. I've tried a few dependency settings in my master pom for ear too.

       

      This issue is a major blocker. Does anyone has any insights into this persistent error?

        • 1. Re: ClassCastException: org.jboss.logmanager.log4j.BridgeLogger
          alex.alvarez.

          Are you using a LoggerFactory?  I have filed a bug  (https://issues.jboss.org/browse/LOGMGR-60) related to this.

          • 2. Re: ClassCastException: org.jboss.logmanager.log4j.BridgeLogger
            jamezp

            The best way is to exclude the org.apache.log4j module and include a log4j.jar in your deployment.

             

            --

            James R. Perkins

            • 3. Re: ClassCastException: org.jboss.logmanager.log4j.BridgeLogger
              mcclane

              Hi, I've got exactly the same problem.

              I've tried to solve by excluding the deployment of org.apache.log4j whitout any results.

               

              But there are more things I don't understand.

               

              First is, how can I be sure that the jboss-deplyment-structure.xml is well formed and in the right place (and readed)?

              I made a test, including a "malformed" xml structure inside, and I didn't have any log warn or anything in the console, so I'm not sure if I'm doing well.

               

              Finally, how can I search for this thread inside developer.jboss.org ? the only way I can find this one, is by searching an specific key in google from outside, but once logged, even using the same title of th thread, the platform sais there aren't coincidences.... what I am doing wrong?

               

              Sorry cause I'm noob in JBOSS ... and maybe the answers are obvious.

               

              EDITED: seems to me that the jboss-deplyment-structure.xm file is being loaded at META-INF level in the RAR, not in the JAR or WAR inside the RAR. Anyway, not really sure of that point.

              • 4. Re: ClassCastException: org.jboss.logmanager.log4j.BridgeLogger
                mcclane

                I'd like to include additional information.

                I've tested the same EAR on JBOSS 6.1 and was deployed Ok.

                So whatever is the problem, it's on JBOSS 7.1

                I've also tested the sources of our looger component on JBOSS developer studio, and worked fine, so as we can't debug, we can't find out why are not deployed on runtime.

                We were ready to implement whatever the interface needed to let jboss do the cast, but we can't because we can´t debug it...

                Pleas, that is locking our project... any help will be apreciated.

                • 5. Re: ClassCastException: org.jboss.logmanager.log4j.BridgeLogger
                  mcclane

                  Ok we did it.

                   

                  We deploy like this:

                   

                  <?xml version="1.0" encoding="UTF-8"?>

                  <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.1">

                      <deployment>

                          <exclusions>

                              <module name="org.jboss.logmanager"/>

                              <module name="org.jboss.logmanager.log4j"/>

                              <module name="org.apache.log4j"/>

                              <module name="org.apache.commons.logging"/>

                          </exclusions>

                          <dependencies>

                              <module name="com.ourown.mylog4j"/>

                          </dependencies>

                      </deployment>

                      <sub-deployment name="LevelEJB.jar">

                          <exclusions>

                              <module name="org.jboss.logmanager"/>

                              <module name="org.jboss.logmanager.log4j"/>

                              <module name="org.apache.log4j"/>

                              <module name="org.apache.commons.logging"/>

                          </exclusions>

                          <dependencies>

                              <module name="com.ourown.mylog4j"/>

                          </dependencies>

                      </sub-deployment>

                      <sub-deployment  name="LevelWeb.war">

                          <exclusions>

                              <module name="org.jboss.logmanager"/>

                              <module name="org.jboss.logmanager.log4j"/>

                              <module name="org.apache.log4j"/>

                              <module name="org.apache.commons.logging"/>

                          </exclusions>

                          <dependencies>

                              <module name="com.ourown.mylog4j"/>

                          </dependencies>

                      </sub-deployment>   

                  </jboss-deployment-structure>

                   

                  And we add a new module com.ourown.mylog4j in the modules of JBOSS, copying the original log4j.jar like this:

                  <?xml version="1.0" encoding="UTF-8"?>

                   

                  <module xmlns="urn:jboss:module:1.1" name="com.ourown.mylog4j">

                      <resources>

                          <resource-root path="log4j.jar"/>

                      </resources>

                      <dependencies>

                          <module name="javax.api"/>

                      </dependencies>

                  </module>

                   

                  We had to make all these steps to make it work.