Uploaded image for project: 'Application Server 3  4  5 and 6'
  1. Application Server 3 4 5 and 6
  2. JBAS-9407

Setting up of application specific logging context leads to IllegalArgumentException

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: 6.1.0
    • Component/s: Logging
    • Labels:
      None
    • Environment:

      JBoss AS 6.0.0.Final

    • Workaround:
      Workaround Exists
    • Workaround Description:
      Hide

      1) Open the JBOSS_HOME/server/<servername>/deployers/jboss-logging.deployer/META-INF/logmanager-jboss-beans.xml in a text editor
      2) Comment out (or remove) the following section from the xml:

       <bean name="JBossLogManagerClassLoaderContextSelector" class="org.jboss.logmanager.ClassLoaderLogContextSelector"/>
       
         <bean name="JBossLogManagerContextSelectorService" class="org.jboss.logmanager.LogContextSelectorService" mode="On Demand">
            <property name="selector">
               <inject bean="JBossLogManagerClassLoaderContextSelector"/>
            </property>
         </bean>
      

      3) Now add the following section in that place:

      <!-- Workaround for JBoss Logging bug http://community.jboss.org/message/587287#587287 -->
      <bean name="JBossLogManagerContextSelectorService" class="org.jboss.logmanager.ClassLoaderLogContextSelector"/>
       
         <bean name="OnDemandJBossLogManagerContextSelectorService" class="org.jboss.logmanager.LogContextSelectorService" mode="On Demand">
            <property name="selector">
               <inject bean="JBossLogManagerClassLoaderContextSelectorService"/>
            </property>
         </bean>
      

      Show
      1) Open the JBOSS_HOME/server/<servername>/deployers/jboss-logging.deployer/META-INF/logmanager-jboss-beans.xml in a text editor 2) Comment out (or remove) the following section from the xml: < bean name = "JBossLogManagerClassLoaderContextSelector" class = "org.jboss.logmanager.ClassLoaderLogContextSelector" />   < bean name = "JBossLogManagerContextSelectorService" class = "org.jboss.logmanager.LogContextSelectorService" mode = "On Demand" > < property name = "selector" > < inject bean = "JBossLogManagerClassLoaderContextSelector" /> </ property > </ bean > 3) Now add the following section in that place: <!-- Workaround for JBoss Logging bug http://community.jboss.org/message/587287#587287 --> < bean name = "JBossLogManagerContextSelectorService" class = "org.jboss.logmanager.ClassLoaderLogContextSelector" />   < bean name = "OnDemandJBossLogManagerContextSelectorService" class = "org.jboss.logmanager.LogContextSelectorService" mode = "On Demand" > < property name = "selector" > < inject bean = "JBossLogManagerClassLoaderContextSelectorService" /> </ property > </ bean >

      Description

      Many users have reported that trying to setup application specific logging context leads to IllegalArgumentException in JBoss AS 6.0.0.Final (please see the referenced forum thread for one such example). I tried a simple application (.war file with jboss-logging.xml in WEB-INF) with the following jboss-logging.xml file:

      <?xml version="1.0" encoding="UTF-8"?>
       
      <!-- ===================================================================== -->
      <!--                                                                       -->
      <!--  Logging System Configuration                                         -->
      <!--                                                                       -->
      <!-- ===================================================================== -->
       
      <logging xmlns="urn:jboss:logging:6.0" xmlns:b="urn:jboss:bean-deployer:2.0" context="first">
       
      	<!-- Define our logging context -->
      		
      	<define-context name="first"/>
       
         <!-- A time/date based rolling handler -->
       
         <periodic-rotating-file-handler
               file-name="${jboss.server.log.dir}/first-app.log"
               name="FILE"
               autoflush="true"
               append="false"
               suffix=".yyyy-MM-dd">  <!-- To roll over at the top of each hour, use ".yyyy-MM-dd-HH" instead -->
       
            <error-manager>
               <only-once/>
            </error-manager>
       
            <formatter>
               <!-- To revert back to simple stack traces without JAR versions, change "%E" to "%e" below. -->
               <!-- Uncomment this to get the class name in the log as well as the category
               <pattern-formatter pattern="%d %-5p [%c] %C{1} (%t) %s%E%n"/>
               -->
               <!-- Uncomment this to log without the class name in the log -->
               <pattern-formatter pattern="%d %-5p [%c] (%t) %s%E%n"/>
            </formatter>
         </periodic-rotating-file-handler>
       
         
         
       
         <!-- =============================================== -->
         <!-- Limit categories                                -->
         <!-- =============================================== -->
       
         <!-- Limit the org.jboss category to DEBUG -->
         <logger category="org.jboss">
            <level name="TRACE"/>
         </logger>
       
         <logger category="org.myapp">
            <level name="TRACE"/>
         </logger>
       
         
         <!-- ======================= -->
         <!-- Setup the Root category -->
         <!-- ======================= -->
       
         <root-logger>
            <!-- Set the root logger priority via a system property, with a default value. -->
            <level name="${jboss.server.log.threshold:INFO}"/>
            <handlers>
               <handler-ref name="FILE"/>
            </handlers>
         </root-logger>
       
      </logging>
      
      

      There's nothing special about this jboss-logging.xml, except that it defines a application specific logging context. During deployment of this application, the server throws the following exception and the deployment fails:

      17:39:35,465 ERROR [AbstractKernelController] Error installing to Configured: name=Logging:REGISTRATION:first:Anonymous-0 state=Instantiated: java.lang.RuntimeException: Error configuring property: selector for Logging:REGISTRATION:first:Anonymous-0
      	at org.jboss.kernel.plugins.dependency.ConfigureAction.dispatchSetProperty(ConfigureAction.java:112) [jboss-kernel.jar:2.2.0.GA]
      	at org.jboss.kernel.plugins.dependency.ConfigureAction.setAttributes(ConfigureAction.java:85) [jboss-kernel.jar:2.2.0.GA]
      	at org.jboss.kernel.plugins.dependency.ConfigureAction.installActionInternal(ConfigureAction.java:44) [jboss-kernel.jar:2.2.0.GA]
      	at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:54) [jboss-kernel.jar:2.2.0.GA]
      	at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:42) [jboss-kernel.jar:2.2.0.GA]
      	at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62) [jboss-dependency.jar:2.2.0.GA]
      	at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71) [jboss-dependency.jar:2.2.0.GA]
      	at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51) [jboss-dependency.jar:2.2.0.GA]
      	at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:379) [jboss-dependency.jar:2.2.0.GA]
      	at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:2044) [jboss-dependency.jar:2.2.0.GA]
      	at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:1083) [jboss-dependency.jar:2.2.0.GA]
      	at org.jboss.dependency.plugins.AbstractController.executeOrIncrementStateDirectly(AbstractController.java:1322) [jboss-dependency.jar:2.2.0.GA]
      	at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1246) [jboss-dependency.jar:2.2.0.GA]
      	at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1139) [jboss-dependency.jar:2.2.0.GA]
      	at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:894) [jboss-dependency.jar:2.2.0.GA]
      	at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:641) [jboss-dependency.jar:2.2.0.GA]
      	at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer.deploy(BeanMetaDataDeployer.java:182) [:2.2.0.GA]
      	at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer.deploy(BeanMetaDataDeployer.java:58) [:2.2.0.GA]
      	at org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalDeploy(AbstractSimpleRealDeployer.java:62) [:2.2.0.GA]
      	at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:55) [:2.2.0.GA]
      	at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:179) [:2.2.0.GA]
      	at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1832) [:2.2.0.GA]
      	at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1550) [:2.2.0.GA]
      	at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1571) [:2.2.0.GA]
      	at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1491) [:2.2.0.GA]
      	at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:379) [jboss-dependency.jar:2.2.0.GA]
      	at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:2044) [jboss-dependency.jar:2.2.0.GA]
      	at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:1083) [jboss-dependency.jar:2.2.0.GA]
      	at org.jboss.dependency.plugins.AbstractController.executeOrIncrementStateDirectly(AbstractController.java:1322) [jboss-dependency.jar:2.2.0.GA]
      	at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1246) [jboss-dependency.jar:2.2.0.GA]
      	at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1139) [jboss-dependency.jar:2.2.0.GA]
      	at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:939) [jboss-dependency.jar:2.2.0.GA]
      	at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:654) [jboss-dependency.jar:2.2.0.GA]
      	at org.jboss.deployers.plugins.deployers.DeployersImpl.change(DeployersImpl.java:1983) [:2.2.0.GA]
      	at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:1076) [:2.2.0.GA]
      	at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:679) [:2.2.0.GA]
      	at org.jboss.system.server.profileservice.deployers.MainDeployerPlugin.process(MainDeployerPlugin.java:106) [:6.0.0.Final]
      	at org.jboss.profileservice.dependency.ProfileControllerContext$DelegateDeployer.process(ProfileControllerContext.java:143) [:0.2.2]
      	at org.jboss.profileservice.dependency.ProfileDeployAction.deploy(ProfileDeployAction.java:151) [:0.2.2]
      	at org.jboss.profileservice.dependency.ProfileDeployAction.installActionInternal(ProfileDeployAction.java:94) [:0.2.2]
      	at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:54) [jboss-kernel.jar:2.2.0.GA]
      	at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:42) [jboss-kernel.jar:2.2.0.GA]
      	at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62) [jboss-dependency.jar:2.2.0.GA]
      	at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71) [jboss-dependency.jar:2.2.0.GA]
      	at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51) [jboss-dependency.jar:2.2.0.GA]
      	at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:379) [jboss-dependency.jar:2.2.0.GA]
      	at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:2044) [jboss-dependency.jar:2.2.0.GA]
      	at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:1083) [jboss-dependency.jar:2.2.0.GA]
      	at org.jboss.dependency.plugins.AbstractController.executeOrIncrementStateDirectly(AbstractController.java:1322) [jboss-dependency.jar:2.2.0.GA]
      	at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1246) [jboss-dependency.jar:2.2.0.GA]
      	at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1139) [jboss-dependency.jar:2.2.0.GA]
      	at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:939) [jboss-dependency.jar:2.2.0.GA]
      	at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:654) [jboss-dependency.jar:2.2.0.GA]
      	at org.jboss.profileservice.dependency.ProfileActivationWrapper$BasicProfileActivation.start(ProfileActivationWrapper.java:190) [:0.2.2]
      	at org.jboss.profileservice.dependency.ProfileActivationWrapper.start(ProfileActivationWrapper.java:87) [:0.2.2]
      	at org.jboss.profileservice.dependency.ProfileActivationService.activateProfile(ProfileActivationService.java:215) [:0.2.2]
      	at org.jboss.profileservice.dependency.ProfileActivationService.activate(ProfileActivationService.java:159) [:0.2.2]
      	at org.jboss.profileservice.bootstrap.AbstractProfileServiceBootstrap.activate(AbstractProfileServiceBootstrap.java:112) [:0.2.2]
      	at org.jboss.profileservice.resolver.BasicResolverFactory$ProfileResolverFacade.deploy(BasicResolverFactory.java:87) [:0.2.2]
      	at org.jboss.profileservice.bootstrap.AbstractProfileServiceBootstrap.start(AbstractProfileServiceBootstrap.java:91) [:0.2.2]
      	at org.jboss.system.server.profileservice.bootstrap.BasicProfileServiceBootstrap.start(BasicProfileServiceBootstrap.java:132) [:6.0.0.Final]
      	at org.jboss.system.server.profileservice.bootstrap.BasicProfileServiceBootstrap.start(BasicProfileServiceBootstrap.java:56) [:6.0.0.Final]
      	at org.jboss.bootstrap.impl.base.server.AbstractServer.startBootstraps(AbstractServer.java:827) [jboss-bootstrap-impl-base.jar:2.1.0-alpha-5]
      	at org.jboss.bootstrap.impl.base.server.AbstractServer$StartServerTask.run(AbstractServer.java:417) [jboss-bootstrap-impl-base.jar:2.1.0-alpha-5]
      	at java.lang.Thread.run(Thread.java:619) [:1.6.0_21]
      Caused by: java.lang.IllegalArgumentException: Wrong arguments. setSelector for target org.jboss.logging.metadata.ClassLoaderRegistrationHelper@111fce expected=[org.jboss.logmanager.ClassLoaderLogContextSelector] actual=[org.jboss.logmanager.LogContextSelectorService]
      	at org.jboss.reflect.plugins.introspection.ReflectionUtils.handleErrors(ReflectionUtils.java:404) [jboss-reflect.jar:2.2.0.GA]
      	at org.jboss.reflect.plugins.introspection.ReflectionUtils.invoke(ReflectionUtils.java:74) [jboss-reflect.jar:2.2.0.GA]
      	at org.jboss.reflect.plugins.introspection.ReflectMethodInfoImpl.invoke(ReflectMethodInfoImpl.java:168) [jboss-reflect.jar:2.2.0.GA]
      	at org.jboss.beans.info.plugins.DefaultPropertyInfo.set(DefaultPropertyInfo.java:143) [jboss-reflect.jar:2.2.0.GA]
      	at org.jboss.beans.info.plugins.BeanInfoUtil.set(BeanInfoUtil.java:177) [jboss-reflect.jar:2.2.0.GA]
      	at org.jboss.beans.info.plugins.AbstractBeanInfo.setProperty(AbstractBeanInfo.java:289) [jboss-reflect.jar:2.2.0.GA]
      	at org.jboss.kernel.plugins.dependency.PropertyDispatchWrapper.execute(PropertyDispatchWrapper.java:114) [jboss-kernel.jar:2.2.0.GA]
      	at org.jboss.kernel.plugins.dependency.ExecutionWrapper.execute(ExecutionWrapper.java:47) [jboss-kernel.jar:2.2.0.GA]
      	at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchExecutionWrapper(KernelControllerContextAction.java:125) [jboss-kernel.jar:2.2.0.GA]
      	at org.jboss.kernel.plugins.dependency.ConfigureAction.dispatchSetProperty(ConfigureAction.java:107) [jboss-kernel.jar:2.2.0.GA]
      	... 64 more
      

      Looking at the JBoss Logging code, this appears to be a bug. The LoggingMetaDataHelper has this piece of code:

      if (! context.equals("system")) {
                  // if it's "system", then nothing special needs to be done.
                  // Otherwise create a bean representing the registration of the deployment unit's classloader with a new log context.
                  final BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(new GetClassLoaderBeanMetaData(getAnonymousName(context, Kind.REGISTRATION), ClassLoaderRegistrationHelper.class.getName()));
                  builder.addPropertyMetaData("logContext", builder.createInject(getContextName(context)));
                  builder.addPropertyMetaData("selector", builder.createInject("JBossLogManagerContextSelectorService"));
                  beanMetaDataList.add(builder.getBeanMetaData());
              }
      

      As can be seen, a BeanMetaData is being constructed and a bean named "JBossLogManagerContextSelectorService" is being injected into a field of type LogContextSelector. However, the xml which defines this "JBossLogManagerContextSelectorService" sets up the JBossLogManagerContextSelectorService to be of a different "type":

      <!--
           ~ These two beans define the per-classloader log context selector which allows per-deployment logging.  Since
           ~ enabling this feature may have a performance impact in certain cases, it's started up lazily (on demand)
           ~ when a separate log context is defined in a user deployment.
           -->
         <bean name="JBossLogManagerClassLoaderContextSelector" class="org.jboss.logmanager.ClassLoaderLogContextSelector"/>
       
         <bean name="JBossLogManagerContextSelectorService" class="org.jboss.logmanager.LogContextSelectorService" mode="On Demand">
            <property name="selector">
               <inject bean="JBossLogManagerClassLoaderContextSelector"/>
            </property>
         </bean>
      

      There are 2 ways to fix this, either fix the code to refer to the "selector" field of JBossLogManagerContextSelectorService (I guess the right approach) or rename the beans in the logmanager-jboss-beans.xml to make sure JBossLogManagerContextSelectorService is of type LogContextSelector (I consider this a workaround).

        Gliffy Diagrams

          Issue Links

            Activity

            Hide
            tamias Earl Hickey added a comment -

            Hi,
            the workaround didn't work for me...
            How soon until this issue might be fixed ?

            Show
            tamias Earl Hickey added a comment - Hi, the workaround didn't work for me... How soon until this issue might be fixed ?
            Hide
            jaikiran jaikiran pai added a comment -

            r111767 contains the fix.

            Show
            jaikiran jaikiran pai added a comment - r111767 contains the fix.

              People

              • Assignee:
                jaikiran jaikiran pai
                Reporter:
                jaikiran jaikiran pai
              • Votes:
                7 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Development