Java Interactive Profiler and OC4J

Help
Beldin108
2008-07-30
2013-04-17
  • Beldin108
    Beldin108
    2008-07-30

    I'm attempting to profile a web app running inside Oracle Containers for Java (oc4j). At start up I specify -javaagent:<location of the profile.jar> and -Dprofile.properties=<location>/webapp.profile.properties.

    Everything starts up fine, I run the app a couple of times to get everything loaded and then turn on the profiler. I run the test turn off the profiler a look at the log and the only methods that are getting profiled are oracle.oc4j.network.*. 

    Next run I turned on debug and it became clear why my app wasn't getting profiled. The log was filled with <Time stamp> Catch: java.lang.ClassNotFoundException
    <Time stamp> skip <my.app.class> [oracle.classloader.PolicyClassLoader]

    I guess my first question is does JIP work with oc4j? I suspect I'm missing something trivial here but I'm relatively new to profiling Java code. Heck, I'm relatively new to Java being an old C programmer learning a new bag of tricks.

    I've gotten this working just fine on standalone Java code and it's proved very useful. I'd like to do the same for a web app running in a container.

     
    • Andrew Wilcox
      Andrew Wilcox
      2008-07-31

      JIP instruments based on ClassLoaders, and unfortunately each container (i.e., Tomcat, JBoss, oc4j) uses a different ClassLoader hierarchy. In the JIP distribution, look in doc/readme.html for the section entitled "How can I control which classes and packages JIP profiles?". This should give you the information you need to get JIP working with oc4j. If you have any other questions or issues, just let me know.

      Thanks,

      Andrew.

       
      • Beldin108
        Beldin108
        2008-08-02

        A little playing around with the GenericClassLoadeFilter and accept-class-loader got me a long way towards getting this to work. There were some issues with oc4j itself notably that the
        profiler.jar file needed to be an api-ext subdirectory of j2ee/lib so various components of oc4j could see the methods in the profiler.

        There is another issue, see below. I am going to get the source code and try to figure out what's going on here this weekend. I suspect this is another issue with ocj4 but I figured I'd run this by you and see if you had any suggestions own where to start the search.

        java.lang.ExceptionInInitializerError
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                at java.lang.reflect.Method.invoke(Method.java:585)
                at oracle.classloader.util.MainClass.invoke(MainClass.java)
                at oracle.oc4j.loader.boot.BootStrap.main(BootStrap.java)
        Caused by: java.lang.NullPointerException
                at com.mentorgen.tools.profile.runtime.Profile.alloc(Unknown Source)
                at com.evermind.server.deployment.SecurityRole.<init>(SecurityRole.java)
                at com.evermind.server.ApplicationServer.<clinit>(ApplicationServer.java)

         
    • Andrew Wilcox
      Andrew Wilcox
      2008-08-02

      profile.jar must be loaded as part of the WAR you're profiling. Moving it to j2ee/lib means that it will be loaded by the extension classloader, which causes problems at runtime. For a semi-coherent discussion of this, see doc/classloader.html. As you observed, if profile.jar is loaded as part of your WAR, the oc4j classes will not be profiled. This is actually a "feature" of JIP. Not profiling extensions classes makes profiling super fast. Most profilers will profile extensions, but finding some performance issue in code you have no control over isn't helpful because there's notthing you can do to change close-sourced code. There are even good reasons for not changing OpenSource code since once you touch it, you have to maintain it. The bottom line is that inefficiencies in third party code will show themselves in the poor performing methods that call it.

      Andrew.

       
  • Hi!

    I try to implement my own ClassLoaderFilter  OC4JInternalClassLoaderFilter

    The code of the Loader:

    package com.mentorgen.tools.profile.instrument.clfilter;

    /**
    * OC4JInternalClassLoaderFilter
    * @author ricardo.rodriguez
    *
    */
    public class OC4JInternalClassLoaderFilter implements ClassLoaderFilter {
    private static final String CLASSLOADER= "oracle.classloader.PolicyClassLoader";

    public boolean canFilter() {
    return true;
    }

    public boolean accept(ClassLoader loader) {
    return loader.getClass().getName().equals(CLASSLOADER); }

    }

    The oupout launching oc4j whith the agent installed:

    ClassLoaderFilter.1: com.mentorgen.tools.profile.instrument.clfilter.OC4JInterna
    lClassLoaderFilter
    Java Interactive Profiler: starting


    22/05/2012 01:04:58 PM com.evermind.server.XMLDataSourcesConfig parseRootNode
    INFO: Legacy datasource detected…attempting to convert to new syntax.
    2012-05-22 13:05:00.312 ERROR J2EE RMI-00002 Error al iniciar el servidor de ORM
    I PC-007, puerto 23,943: Unable to intialize SSLConfig 'com.evermind.ssl.JSSESSL
    ServerSocketFactory':

              Falta la clase: com.mentorgen.tools.profile.runtime.Profile

            Clase Dependiente: com.sun.crypto.provider.SunJCE
                     Cargador: jre.extension:0.0.0
                Origen de C¾digo: /C:/Archivos de programa/Java/jdk1.5.0_22/jre/lib/
    ext/sunjce_provider.jar
              Configuraci¾n: system property java.ext.dirs

    La clase que falta estß disponible en las siguientes ubicaciones:

            1. Origen de C¾digo: /D:/oc4j_extended_101350/lib/profile.jar (from
    system property java.class.path)
               Este origen de c¾digo estß disponible en el cargador oc4j:10.1.3. Es
    un secundario del cargador dependiente jre.extension:0.0.0.

    2012-05-22 13:05:00.328 ERROR java.io.IOException: Unable to intialize SSLConfig
    'com.evermind.ssl.JSSESSLServerSocketFactory':

              Falta la clase: com.mentorgen.tools.profile.runtime.Profile

            Clase Dependiente: com.sun.crypto.provider.SunJCE
                     Cargador: jre.extension:0.0.0
                Origen de C¾digo: /C:/Archivos de programa/Java/jdk1.5.0_22/jre/lib/
    ext/sunjce_provider.jar
              Configuraci¾n: system property java.ext.dirs

    La clase que falta estß disponible en las siguientes ubicaciones:

            1. Origen de C¾digo: /D:/oc4j_extended_101350/lib/profile.jar (from
    system property java.class.path)
               Este origen de c¾digo estß disponible en el cargador oc4j:10.1.3. Es
    un secundario del cargador dependiente jre.extension:0.0.0.

            at com.evermind.ssl.SSLConfig.createServerSocket(Unknown Source)
            at com.evermind.server.rmi.RMIServer.createSslServerSocket(Unknown Sourc
    e)
            at com.evermind.server.rmi.RMIServer.createSslServerSocket(Unknown Sourc
    e)
            at com.evermind.server.rmi.RMIServer.createSecureSocket(Unknown Source)
            at com.evermind.server.rmi.RMIServer.setConfig(Unknown Source)
            at com.evermind.server.ApplicationServer.initializeRMI(Unknown Source)
            at com.evermind.server.ApplicationServer.setConfig(Unknown Source)
            at com.evermind.server.ApplicationServerLauncher.run(Unknown Source)
            at java.lang.Thread.run(Thread.java:595)

    12/05/22 13:05:00 Error al iniciar el servidor de ORMI PC-007, puerto 23,943: Un
    able to intialize SSLConfig 'com.evermind.ssl.JSSESSLServerSocketFactory':

              Falta la clase: com.mentorgen.tools.profile.runtime.Profile

            Clase Dependiente: com.sun.crypto.provider.SunJCE
                     Cargador: jre.extension:0.0.0
                Origen de C¾digo: /C:/Archivos de programa/Java/jdk1.5.0_22/jre/lib/
    ext/sunjce_provider.jar
              Configuraci¾n: system property java.ext.dirs

    La clase que falta estß disponible en las siguientes ubicaciones:

            1. Origen de C¾digo: /D:/oc4j_extended_101350/lib/profile.jar (from
    system property java.class.path)
               Este origen de c¾digo estß disponible en el cargador oc4j:10.1.3. Es
    un secundario del cargador dependiente jre.extension:0.0.0.

    12/05/22 13:05:00 Controller - shuttingdown12/05/22 13:05:00
    Shutting down OC4J…

    The launching process fail…

    Thanks!