1 Reply Latest reply on Sep 19, 2012 7:37 PM by Marco Battaglia

    How to manage instrumentation in application deployed on JBoss?

    adesanctis Newbie

      Hello everybody,

       

      I'm trying to instrument classes in JBoss Enterprise application on JBoss EA5.0

       

      Using this code:

       

      public byte[] transform(ClassLoader loader,
              String className,
              Class classBeingRedefined,
              ProtectionDomain protectionDomain,
              byte[] classfileBuffer) throws IllegalClassFormatException {
          // The class name contains slashes instead of periods, so use transform those to
          // dots for readability within the trace
          String dotClassName = className.replace('/', '.');

       

       

          if (className.startsWith("$")) {
              return null;
          }

       

          // Only instrument a class once
          if (instrumentedClasses.contains(className)) {
              return null;
          }
          instrumentedClasses.add(className);

       

          // Skip in the list of class prefixes to skip
          for (MethodSelector classToSkip : classesToSkip) {
              if (dotClassName.startsWith(classToSkip.getPackageName())) {
                  return null;
              }
          }

       

          if (logger.isInfoEnabled()) {
              logger.info("Checking class: " + className);
          }
         
          try {
              classPool.insertClassPath(new ByteArrayClassPath(className, classfileBuffer));
      //        classPool.insertClassPath(new ClassClassPath(this.getClass()));
             
      //        classPool.insertClassPath(new ClassClassPath(classBeingRedefined.getClass()));
              CtClass cc = classPool.get(dotClassName);
      //        CtClass cc = classPool.makeClass(new ByteArrayInputStream(classfileBuffer));       

      //

       

      In bold line where exception is raised.

      I suppose that arror is related to specific class loader used for load class.

      The question is: how to manage classes independently from class loader used? Is there a way to manage all possible case when working on JBoss?

       

      Thank you

       

      Alessandro

       

      09:37:59,040 ERROR [STDERR] javassist.NotFoundException: com.arjuna.ats.internal.jta.recovery.arjunacore.RecoveryXids

      09:37:59,040 ERROR [STDERR]     at javassist.ClassPool.get(ClassPool.java:436)

      09:37:59,040 ERROR [STDERR]     at by.concept.applicationtracer.AdvancedTransformer.transform(AdvancedTransformer.java:163)

      09:37:59,040 ERROR [STDERR]     at sun.instrument.TransformerManager.transform(TransformerManager.java:169)

      09:37:59,040 ERROR [STDERR]     at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:365)

      09:37:59,040 ERROR [STDERR]     at java.lang.ClassLoader.defineClass1(Native Method)

      09:37:59,040 ERROR [STDERR]     at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)

      09:37:59,040 ERROR [STDERR]     at java.lang.ClassLoader.defineClass(ClassLoader.java:615)

      09:37:59,040 ERROR [STDERR]     at org.jboss.classloader.spi.base.BaseClassLoader.access$200(BaseClassLoader.java:67)

      09:37:59,040 ERROR [STDERR]     at org.jboss.classloader.spi.base.BaseClassLoader$2.run(BaseClassLoader.java:633)

      09:37:59,040 ERROR [STDERR]     at org.jboss.classloader.spi.base.BaseClassLoader$2.run(BaseClassLoader.java:592)

      09:37:59,040 ERROR [STDERR]     at java.security.AccessController.doPrivileged(Native Method)

      09:37:59,040 ERROR [STDERR]     at org.jboss.classloader.spi.base.BaseClassLoader.loadClassLocally(BaseClassLoader.java:591)

      09:37:59,040 ERROR [STDERR]     at org.jboss.classloader.spi.base.BaseClassLoader.loadClassLocally(BaseClassLoader.java:568)

      09:37:59,040 ERROR [STDERR]     at org.jboss.classloader.spi.base.BaseDelegateLoader.loadClass(BaseDelegateLoader.java:135)

      09:37:59,040 ERROR [STDERR]     at org.jboss.classloader.spi.filter.FilteredDelegateLoader.loadClass(FilteredDelegateLoader.java:131)

      09:37:59,040 ERROR [STDERR]     at org.jboss.classloader.spi.base.ClassLoadingTask$ThreadTask.run(ClassLoadingTask.java:455)

      09:37:59,040 ERROR [STDERR]     at org.jboss.classloader.spi.base.ClassLoaderManager.nextTask(ClassLoaderManager.java:267)

      09:37:59,040 ERROR [STDERR]     at org.jboss.classloader.spi.base.ClassLoaderManager.process(ClassLoaderManager.java:166)

      09:37:59,040 ERROR [STDERR]     at org.jboss.classloader.spi.base.BaseClassLoaderDomain.loadClass(BaseClassLoaderDomain.java:276)

      09:37:59,040 ERROR [STDERR]     at org.jboss.classloader.spi.base.BaseClassLoaderDomain.loadClass(BaseClassLoaderDomain.java:1138)

      09:37:59,040 ERROR [STDERR]     at org.jboss.classloader.spi.base.BaseClassLoader.loadClassFromDomain(BaseClassLoader.java:862)

      09:37:59,040 ERROR [STDERR]     at org.jboss.classloader.spi.base.BaseClassLoader.doLoadClass(BaseClassLoader.java:502)

      09:37:59,040 ERROR [STDERR]     at org.jboss.classloader.spi.base.BaseClassLoader.loadClass(BaseClassLoader.java:447)