River
  1. River
  2. RIVER-336

Jini should support platforms other than those with RMIClassLoader as the classloading control point. IDEs inparticular need help.

    Details

    • Type: New Feature New Feature
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: River_2.2.0
    • Fix Version/s: None
    • Component/s: net_jini_loader
    • Labels:
      None

      Description

      The RMIClassLoader class and RMIClassLoaderSPI is currently the control point for managing the "platform" view of how classes are loaded. In IDEs and other different environments, the "parent" classloader view, is not always the "system class loader". There are some other variations on class loading that seem to indicate that while RMIClassLoaderSPI can be plugged into, it doesn't always provide quite the right facilities because even plugging into the system class loader to override it might not be possible.

      The diffs included here show some preliminary work that I did investigating this issue to try and make it possible to discover and load Jini servers within the netbeans IDE.

      Refinement and some rework will be needed, and some other investigation into other platforms such as JEE and other IDEs would be helpful in making sure we understand what is really needed. Even OSGi would be something to look at.

      1. rmicl.diff.txt
        69 kB
        Gregg Wonderly
      2. Greggs_Mods.patch
        42 kB
        Peter Firmstone
      3. PreferredClassProvider.java.rej
        2 kB
        Peter Firmstone
      4. Greggs_Mods-with-some-minor-changes.patch
        42 kB
        Peter Firmstone
      5. PreferredClassProvider.java
        61 kB
        Gregg Wonderly
      6. CBAClassLoaderBUILD.patch
        0.9 kB
        Peter Firmstone
      7. CBAClassLoaderQA.patch
        117 kB
        Peter Firmstone
      8. CBAClassLoaderSRC_dir.patch
        41 kB
        Peter Firmstone

        Issue Links

          Activity

          Hide
          Hudson added a comment -

          Integrated in River-trunk-jdk7 #109 (See https://builds.apache.org/job/River-trunk-jdk7/109/)
          RIVER-336 additional logging (Revision 1402772)

          Result = SUCCESS
          sijskes : http://svn.apache.org/viewvc/?view=rev&rev=1402772
          Files :

          • /river/jtsk/trunk/src/net/jini/loader/RiverClassLoader.java
          Show
          Hudson added a comment - Integrated in River-trunk-jdk7 #109 (See https://builds.apache.org/job/River-trunk-jdk7/109/ ) RIVER-336 additional logging (Revision 1402772) Result = SUCCESS sijskes : http://svn.apache.org/viewvc/?view=rev&rev=1402772 Files : /river/jtsk/trunk/src/net/jini/loader/RiverClassLoader.java
          Hide
          Hudson added a comment -

          Integrated in River-trunk-jdk7 #108 (See https://builds.apache.org/job/River-trunk-jdk7/108/)
          RIVER-336 (Revision 1402759)
          RIVER-336 (Revision 1402758)
          RIVER-336 (Revision 1402757)
          RIVER-336 (Revision 1402756)
          RIVER-336 (Revision 1402755)
          RIVER-336 (Revision 1402754)
          RIVER-336 related. (Revision 1402753)
          RIVER-336 related. (Revision 1402752)

          Result = SUCCESS
          sijskes : http://svn.apache.org/viewvc/?view=rev&rev=1402759
          Files :

          • /river/jtsk/trunk/src/com/sun/jini/discovery/Discovery.java
          • /river/jtsk/trunk/src/com/sun/jini/discovery/UnicastDiscoveryClient.java
          • /river/jtsk/trunk/src/com/sun/jini/norm/NormServerBaseImpl.java
          • /river/jtsk/trunk/src/com/sun/jini/outrigger/EntryRep.java
          • /river/jtsk/trunk/src/com/sun/jini/phoenix/ActivationGroupImpl.java
          • /river/jtsk/trunk/src/com/sun/jini/phoenix/ActivationGroupInit.java

          sijskes : http://svn.apache.org/viewvc/?view=rev&rev=1402758
          Files :

          • /river/jtsk/trunk/src/com/sun/jini/reggie/EntryClassBase.java
          • /river/jtsk/trunk/src/com/sun/jini/reggie/ServiceTypeBase.java

          sijskes : http://svn.apache.org/viewvc/?view=rev&rev=1402757
          Files :

          • /river/jtsk/trunk/src/net/jini/activation/ActivationGroup.java

          sijskes : http://svn.apache.org/viewvc/?view=rev&rev=1402756
          Files :

          • /river/jtsk/trunk/src/net/jini/io/MarshalInputStream.java
          • /river/jtsk/trunk/src/net/jini/io/MarshalOutputStream.java
          • /river/jtsk/trunk/src/net/jini/io/MarshalledInstance.java

          sijskes : http://svn.apache.org/viewvc/?view=rev&rev=1402755
          Files :

          • /river/jtsk/trunk/src/net/jini/security/proxytrust/ProxyTrustVerifier.java

          sijskes : http://svn.apache.org/viewvc/?view=rev&rev=1402754
          Files :

          • /river/jtsk/trunk/src/net/jini/loader/pref/RequireDlPermProvider.java

          sijskes : http://svn.apache.org/viewvc/?view=rev&rev=1402753
          Files :

          • /river/jtsk/trunk/src/net/jini/loader/ClassAnnotation.java
          • /river/jtsk/trunk/src/net/jini/loader/ClassLoading.java
          • /river/jtsk/trunk/src/net/jini/loader/DownloadPermission.java

          sijskes : http://svn.apache.org/viewvc/?view=rev&rev=1402752
          Files :

          • /river/jtsk/trunk/src/net/jini/loader/RiverClassLoader.java
          • /river/jtsk/trunk/src/net/jini/loader/RiverClassLoaderSpi.java
          Show
          Hudson added a comment - Integrated in River-trunk-jdk7 #108 (See https://builds.apache.org/job/River-trunk-jdk7/108/ ) RIVER-336 (Revision 1402759) RIVER-336 (Revision 1402758) RIVER-336 (Revision 1402757) RIVER-336 (Revision 1402756) RIVER-336 (Revision 1402755) RIVER-336 (Revision 1402754) RIVER-336 related. (Revision 1402753) RIVER-336 related. (Revision 1402752) Result = SUCCESS sijskes : http://svn.apache.org/viewvc/?view=rev&rev=1402759 Files : /river/jtsk/trunk/src/com/sun/jini/discovery/Discovery.java /river/jtsk/trunk/src/com/sun/jini/discovery/UnicastDiscoveryClient.java /river/jtsk/trunk/src/com/sun/jini/norm/NormServerBaseImpl.java /river/jtsk/trunk/src/com/sun/jini/outrigger/EntryRep.java /river/jtsk/trunk/src/com/sun/jini/phoenix/ActivationGroupImpl.java /river/jtsk/trunk/src/com/sun/jini/phoenix/ActivationGroupInit.java sijskes : http://svn.apache.org/viewvc/?view=rev&rev=1402758 Files : /river/jtsk/trunk/src/com/sun/jini/reggie/EntryClassBase.java /river/jtsk/trunk/src/com/sun/jini/reggie/ServiceTypeBase.java sijskes : http://svn.apache.org/viewvc/?view=rev&rev=1402757 Files : /river/jtsk/trunk/src/net/jini/activation/ActivationGroup.java sijskes : http://svn.apache.org/viewvc/?view=rev&rev=1402756 Files : /river/jtsk/trunk/src/net/jini/io/MarshalInputStream.java /river/jtsk/trunk/src/net/jini/io/MarshalOutputStream.java /river/jtsk/trunk/src/net/jini/io/MarshalledInstance.java sijskes : http://svn.apache.org/viewvc/?view=rev&rev=1402755 Files : /river/jtsk/trunk/src/net/jini/security/proxytrust/ProxyTrustVerifier.java sijskes : http://svn.apache.org/viewvc/?view=rev&rev=1402754 Files : /river/jtsk/trunk/src/net/jini/loader/pref/RequireDlPermProvider.java sijskes : http://svn.apache.org/viewvc/?view=rev&rev=1402753 Files : /river/jtsk/trunk/src/net/jini/loader/ClassAnnotation.java /river/jtsk/trunk/src/net/jini/loader/ClassLoading.java /river/jtsk/trunk/src/net/jini/loader/DownloadPermission.java sijskes : http://svn.apache.org/viewvc/?view=rev&rev=1402752 Files : /river/jtsk/trunk/src/net/jini/loader/RiverClassLoader.java /river/jtsk/trunk/src/net/jini/loader/RiverClassLoaderSpi.java
          Hide
          Peter Firmstone added a comment -

          Patches against most recent trunk, incorporates Greggs mods as well as converting QA tests to use CodebaseAccessClassLoader instead of RMIClassLoader

          Show
          Peter Firmstone added a comment - Patches against most recent trunk, incorporates Greggs mods as well as converting QA tests to use CodebaseAccessClassLoader instead of RMIClassLoader
          Hide
          Gregg Wonderly added a comment -

          christopher.dolan@avid.com commented on the river-dev list:

          For others going down this same road, here's a bit of acquired wisdom:
          it's important that you do NOT set the system property
          java.rmi.server.RMIClassLoaderSpi because if you do then you'll get
          NoClassDefFoundError when com.sun.jini.lookup.entry.LookupAttributes
          calls the java.rmi.MarshalledObject constructor and
          java.rmi.server.RMIClassLoader crashes on class initialization trying to
          find your custom SPI.

          In my code, I do this during bootstrap:

          String myLoaderSPI =
          System.getProperty("java.rmi.server.RMIClassLoaderSpi");
          if (null != myLoaderSPI && null ==
          ClassLoader.getSystemResource(myLoaderSPI))

          { // HACK! We can't force our SPI into the system class loader, so we // need to back it out because otherwise it breaks MarshalledObject // usage in the com.sun.jini.lookup.entry.LookupAttributes class. System.setProperty("java.rmi.server.RMIClassLoaderSpi", "default"); }

          Another big gotcha is that you may not be able to talk to older Reggie
          instances because of the hardcoded RMIClassLoader reference in
          ServiceTypeBase in reggie-dl.jar. I worked around this via a custom
          URLStreamHandlerFactory that detects an out-of-date reggie-dl.jar and
          substitutes a newer version invisibly at runtime. This is a very
          unpleasant hack, but I could find no alternative. I suppose this could
          also be solved via a preferred class...

          Chris

          Show
          Gregg Wonderly added a comment - christopher.dolan@avid.com commented on the river-dev list: For others going down this same road, here's a bit of acquired wisdom: it's important that you do NOT set the system property java.rmi.server.RMIClassLoaderSpi because if you do then you'll get NoClassDefFoundError when com.sun.jini.lookup.entry.LookupAttributes calls the java.rmi.MarshalledObject constructor and java.rmi.server.RMIClassLoader crashes on class initialization trying to find your custom SPI. In my code, I do this during bootstrap: String myLoaderSPI = System.getProperty("java.rmi.server.RMIClassLoaderSpi"); if (null != myLoaderSPI && null == ClassLoader.getSystemResource(myLoaderSPI)) { // HACK! We can't force our SPI into the system class loader, so we // need to back it out because otherwise it breaks MarshalledObject // usage in the com.sun.jini.lookup.entry.LookupAttributes class. System.setProperty("java.rmi.server.RMIClassLoaderSpi", "default"); } Another big gotcha is that you may not be able to talk to older Reggie instances because of the hardcoded RMIClassLoader reference in ServiceTypeBase in reggie-dl.jar. I worked around this via a custom URLStreamHandlerFactory that detects an out-of-date reggie-dl.jar and substitutes a newer version invisibly at runtime. This is a very unpleasant hack, but I could find no alternative. I suppose this could also be solved via a preferred class... Chris
          Hide
          Gregg Wonderly added a comment -

          Here is the full PreferredClassProvider that I am currently using. Note that there are some other various changes in this code, including some attempts at optimizing concurrency through the cache of PreferredClassLoader instances. Those changes have been discussed on the web in different places, including at artima.com on my blog there. I'm not convinced that these changes are the "best" way to do this, I just wired some things together and made some changes after testing.

          Show
          Gregg Wonderly added a comment - Here is the full PreferredClassProvider that I am currently using. Note that there are some other various changes in this code, including some attempts at optimizing concurrency through the cache of PreferredClassLoader instances. Those changes have been discussed on the web in different places, including at artima.com on my blog there. I'm not convinced that these changes are the "best" way to do this, I just wired some things together and made some changes after testing.
          Hide
          Peter Firmstone added a comment -

          Some very minor changes, so it builds.

          Show
          Peter Firmstone added a comment - Some very minor changes, so it builds.
          Hide
          Peter Firmstone added a comment -

          Gregg,

          The attached patch is your patch applied to the current River trunk. I've also attached the part that didn't successfully patch, it was PreferredClassProvider.

          Cheers,

          Peter.

          Show
          Peter Firmstone added a comment - Gregg, The attached patch is your patch applied to the current River trunk. I've also attached the part that didn't successfully patch, it was PreferredClassProvider. Cheers, Peter.
          Hide
          Gregg Wonderly added a comment -

          This is a diff out of my perforce node for the affected classes that I've been using for some time. The changes shown here are preliminary and should be considered experimental.

          Show
          Gregg Wonderly added a comment - This is a diff out of my perforce node for the affected classes that I've been using for some time. The changes shown here are preliminary and should be considered experimental.

            People

            • Assignee:
              Unassigned
              Reporter:
              Gregg Wonderly
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development