VisualVM
  1. VisualVM
  2. VISUALVM-545

Loading profiler for OC4J fails with NullPointerException - easy fix

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.3.5
    • Fix Version/s: 1.3.6
    • Component/s: code
    • Labels:
      None
    • Environment:

      Oracle OC4J and any other environment where agent is loaded by bootstrap class loader.

      Description

      Class ProfilerActivate15 uses SystemClassLoader to access the jar it was loaded from. This use asumes that the agent (and thus ProfilerActivate15) was loaded by SystemClassLoader, which is not always the case. For instance, OC4J does not load the agent in SystemClassLoader. If visualvm is used to profile OC4J, loading of the agent fails with NullPointerException in ProfilerActivate15:78, since url=null. I recommend that the method ProfilerActivate15.activate be modified to support these cases.

      Modifiy this code:
      98 URL classUrl = ClassLoader.getSystemClassLoader().getResource("org/netbeans/lib/profiler/server/ProfilerActivate15.class");
      99 File jar = getArchiveFile(classUrl);
      to
      98 URL classUrl = classLoader.getSystemClassLoader().getResource("org/netbeans/lib/profiler/server/ProfilerActivate15.class");
      if (classUrl == null)
      classUrl = Thread.currentThread().getContextClassLoader().getResource("org/netbeans/lib/profiler/server/ProfilerActivate15.class");
      99 File jar = getArchiveFile(classUrl);

        Activity

        Hide
        thurka added a comment -

        In normal circumstances "boot class loader" is parent classloader of "system class loader" and therefore everything works fine. I don't know, why this is not true for OC4J.

        Show
        thurka added a comment - In normal circumstances "boot class loader" is parent classloader of "system class loader" and therefore everything works fine. I don't know, why this is not true for OC4J.
        Hide
        cuteredstorm added a comment -

        I have done some more research. ClassLoader.getSystemClassLoader() returns an oracle.classloader.PolicyClassLoader instance named oc4j:10.1.3. Although this is a child of bootstrap classloader, by J2EE standards (as I understand them), classes loaded by bootstrap are not always visible by child classloader. So this is indeed a bug in netbeans. Can you file it?

        I used http://www.objectsource.com/j2eechapters/Ch21-ClassLoaders_and_J2EE.htm 21.1 and 21.3 for the research.

        Show
        cuteredstorm added a comment - I have done some more research. ClassLoader.getSystemClassLoader() returns an oracle.classloader.PolicyClassLoader instance named oc4j:10.1.3. Although this is a child of bootstrap classloader, by J2EE standards (as I understand them), classes loaded by bootstrap are not always visible by child classloader. So this is indeed a bug in netbeans. Can you file it? I used http://www.objectsource.com/j2eechapters/Ch21-ClassLoaders_and_J2EE.htm 21.1 and 21.3 for the research.
        Hide
        thurka added a comment -

        system class loader has nothing to do with J2EE specification. It should delegate to bootstrap class loader.

        Show
        thurka added a comment - system class loader has nothing to do with J2EE specification. It should delegate to bootstrap class loader.
        Hide
        thurka added a comment -

        The problem is now tracked as NetBeans Profiler issue: https://netbeans.org/bugzilla/show_bug.cgi?id=231027

        Show
        thurka added a comment - The problem is now tracked as NetBeans Profiler issue: https://netbeans.org/bugzilla/show_bug.cgi?id=231027
        Hide
        thurka added a comment -

        Fixed in NetBeans Profiler. The fix was transplanted to profiler-release73 branch <http://hg.netbeans.org/releases/rev/2206ed2aaf9d> and will be available in the next VisualVM release.

        Show
        thurka added a comment - Fixed in NetBeans Profiler. The fix was transplanted to profiler-release73 branch < http://hg.netbeans.org/releases/rev/2206ed2aaf9d > and will be available in the next VisualVM release.

          People

          • Assignee:
            thurka
            Reporter:
            cuteredstorm
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 15 minutes
              15m
              Remaining:
              Remaining Estimate - 15 minutes
              15m
              Logged:
              Time Spent - Not Specified
              Not Specified