You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by "James Baldassari (JIRA)" <ji...@apache.org> on 2012/07/03 00:56:57 UTC

[jira] [Created] (HBASE-6308) Coprocessors should be loaded in a custom ClassLoader to prevent dependency conflicts with HBase

James Baldassari created HBASE-6308:
---------------------------------------

             Summary: Coprocessors should be loaded in a custom ClassLoader to prevent dependency conflicts with HBase
                 Key: HBASE-6308
                 URL: https://issues.apache.org/jira/browse/HBASE-6308
             Project: HBase
          Issue Type: Improvement
          Components: coprocessors
    Affects Versions: 0.94.0, 0.92.1
            Reporter: James Baldassari


Currently each coprocessor is loaded with a URLClassLoader that puts the coprocessor's jar at the beginning of the classpath.  The URLClassLoader always tries to load classes from the parent ClassLoader first and only attempts to load from its own configured URLs if the class was not found by the parent.  This class loading behavior can be problematic for coprocessors that have common dependencies with HBase but whose versions are incompatible.  For example, I have a coprocessor that depends on a different version of Avro than the version used by HBase.  The current class loading behavior results in NoSuchMethodErrors in my coprocessor because some Avro classes have already been loaded by HBase, and the ClassLoader for my coprocessor picks up HBase's loaded classes first.

My proposed solution to this problem is to use a custom ClassLoader when instantiating coprocessor instances.  This custom ClassLoader would always attempt to load classes from the coprocessor's jar first and would only delegate to the parent ClassLoader if the class were not found in the coprocessor jar.  However, certain classes would need to be exempt from this behavior.  As an example, if the Copcoessor interface were loaded by both the region server's ClassLoader and the coprocessor's custom ClassLoader, then the region server would get a ClassCastException when attempting to cast the coprocessor instance to the Coprocessor interface.  This problem can be avoided by defining a set of class name prefixes that would be exempt from loading by the custom ClassLoader.  When loading a class, if the class starts with any of these prefixes (e.g. "org.apache.hadoop"), then the ClassLoader would delegate immediately to the parent ClassLoader.

I've already implemented a patch to provide this functionality which I'll attach shortly.


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (HBASE-6308) Coprocessors should be loaded in a custom ClassLoader to prevent dependency conflicts with HBase

Posted by "Zhihong Ted Yu (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HBASE-6308?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Zhihong Ted Yu updated HBASE-6308:
----------------------------------

    Fix Version/s: 0.96.0
     Hadoop Flags: Reviewed
           Status: Patch Available  (was: Open)
    
> Coprocessors should be loaded in a custom ClassLoader to prevent dependency conflicts with HBase
> ------------------------------------------------------------------------------------------------
>
>                 Key: HBASE-6308
>                 URL: https://issues.apache.org/jira/browse/HBASE-6308
>             Project: HBase
>          Issue Type: Improvement
>          Components: coprocessors
>    Affects Versions: 0.94.0, 0.92.1
>            Reporter: James Baldassari
>             Fix For: 0.96.0
>
>         Attachments: 6308-v2.txt, HBASE-6308-0.92.patch, HBASE-6308-trunk.patch
>
>
> Currently each coprocessor is loaded with a URLClassLoader that puts the coprocessor's jar at the beginning of the classpath.  The URLClassLoader always tries to load classes from the parent ClassLoader first and only attempts to load from its own configured URLs if the class was not found by the parent.  This class loading behavior can be problematic for coprocessors that have common dependencies with HBase but whose versions are incompatible.  For example, I have a coprocessor that depends on a different version of Avro than the version used by HBase.  The current class loading behavior results in NoSuchMethodErrors in my coprocessor because some Avro classes have already been loaded by HBase, and the ClassLoader for my coprocessor picks up HBase's loaded classes first.
> My proposed solution to this problem is to use a custom ClassLoader when instantiating coprocessor instances.  This custom ClassLoader would always attempt to load classes from the coprocessor's jar first and would only delegate to the parent ClassLoader if the class were not found in the coprocessor jar.  However, certain classes would need to be exempt from this behavior.  As an example, if the Copcoessor interface were loaded by both the region server's ClassLoader and the coprocessor's custom ClassLoader, then the region server would get a ClassCastException when attempting to cast the coprocessor instance to the Coprocessor interface.  This problem can be avoided by defining a set of class name prefixes that would be exempt from loading by the custom ClassLoader.  When loading a class, if the class starts with any of these prefixes (e.g. "org.apache.hadoop"), then the ClassLoader would delegate immediately to the parent ClassLoader.
> I've already implemented a patch to provide this functionality which I'll attach shortly.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (HBASE-6308) Coprocessors should be loaded in a custom ClassLoader to prevent dependency conflicts with HBase

Posted by "Andrew Purtell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-6308?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13405435#comment-13405435 ] 

Andrew Purtell commented on HBASE-6308:
---------------------------------------

+1 Nice work James, thanks for the contribution.

bq. I'm not sure if there is an easy way to unit test this change, but if anyone has any ideas I'll try to find some time to work on it.

We could at least add a new test to TestClassLoading that insures the coprocessor class loader is used. I.e. myCP.getClass().getClassLoader instanceof CoprocessorClassLoader. 
                
> Coprocessors should be loaded in a custom ClassLoader to prevent dependency conflicts with HBase
> ------------------------------------------------------------------------------------------------
>
>                 Key: HBASE-6308
>                 URL: https://issues.apache.org/jira/browse/HBASE-6308
>             Project: HBase
>          Issue Type: Improvement
>          Components: coprocessors
>    Affects Versions: 0.92.1, 0.94.0
>            Reporter: James Baldassari
>         Attachments: HBASE-6308-0.92.patch, HBASE-6308-trunk.patch
>
>
> Currently each coprocessor is loaded with a URLClassLoader that puts the coprocessor's jar at the beginning of the classpath.  The URLClassLoader always tries to load classes from the parent ClassLoader first and only attempts to load from its own configured URLs if the class was not found by the parent.  This class loading behavior can be problematic for coprocessors that have common dependencies with HBase but whose versions are incompatible.  For example, I have a coprocessor that depends on a different version of Avro than the version used by HBase.  The current class loading behavior results in NoSuchMethodErrors in my coprocessor because some Avro classes have already been loaded by HBase, and the ClassLoader for my coprocessor picks up HBase's loaded classes first.
> My proposed solution to this problem is to use a custom ClassLoader when instantiating coprocessor instances.  This custom ClassLoader would always attempt to load classes from the coprocessor's jar first and would only delegate to the parent ClassLoader if the class were not found in the coprocessor jar.  However, certain classes would need to be exempt from this behavior.  As an example, if the Copcoessor interface were loaded by both the region server's ClassLoader and the coprocessor's custom ClassLoader, then the region server would get a ClassCastException when attempting to cast the coprocessor instance to the Coprocessor interface.  This problem can be avoided by defining a set of class name prefixes that would be exempt from loading by the custom ClassLoader.  When loading a class, if the class starts with any of these prefixes (e.g. "org.apache.hadoop"), then the ClassLoader would delegate immediately to the parent ClassLoader.
> I've already implemented a patch to provide this functionality which I'll attach shortly.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (HBASE-6308) Coprocessors should be loaded in a custom ClassLoader to prevent dependency conflicts with HBase

Posted by "Hudson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-6308?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13433565#comment-13433565 ] 

Hudson commented on HBASE-6308:
-------------------------------

Integrated in HBase-0.94 #392 (See [https://builds.apache.org/job/HBase-0.94/392/])
    HBASE-6308. Coprocessors should be loaded in a custom ClassLoader (James Baldassari) (Revision 1372561)

     Result = FAILURE
apurtell : 
Files : 
* /hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/coprocessor/CoprocessorClassLoader.java
* /hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/coprocessor/CoprocessorHost.java
* /hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/coprocessor/TestClassLoading.java

                
> Coprocessors should be loaded in a custom ClassLoader to prevent dependency conflicts with HBase
> ------------------------------------------------------------------------------------------------
>
>                 Key: HBASE-6308
>                 URL: https://issues.apache.org/jira/browse/HBASE-6308
>             Project: HBase
>          Issue Type: Improvement
>          Components: coprocessors
>    Affects Versions: 0.92.1, 0.94.0
>            Reporter: James Baldassari
>            Assignee: Andrew Purtell
>             Fix For: 0.92.2, 0.96.0, 0.94.2
>
>         Attachments: 6308-v2.txt, HBASE-6308-0.92.patch, HBASE-6308-0.92-with-test.patch, HBASE-6308-0.94-with-test.patch, HBASE-6308-trunk.patch, HBASE-6308-trunk-with-test.patch
>
>
> Currently each coprocessor is loaded with a URLClassLoader that puts the coprocessor's jar at the beginning of the classpath.  The URLClassLoader always tries to load classes from the parent ClassLoader first and only attempts to load from its own configured URLs if the class was not found by the parent.  This class loading behavior can be problematic for coprocessors that have common dependencies with HBase but whose versions are incompatible.  For example, I have a coprocessor that depends on a different version of Avro than the version used by HBase.  The current class loading behavior results in NoSuchMethodErrors in my coprocessor because some Avro classes have already been loaded by HBase, and the ClassLoader for my coprocessor picks up HBase's loaded classes first.
> My proposed solution to this problem is to use a custom ClassLoader when instantiating coprocessor instances.  This custom ClassLoader would always attempt to load classes from the coprocessor's jar first and would only delegate to the parent ClassLoader if the class were not found in the coprocessor jar.  However, certain classes would need to be exempt from this behavior.  As an example, if the Copcoessor interface were loaded by both the region server's ClassLoader and the coprocessor's custom ClassLoader, then the region server would get a ClassCastException when attempting to cast the coprocessor instance to the Coprocessor interface.  This problem can be avoided by defining a set of class name prefixes that would be exempt from loading by the custom ClassLoader.  When loading a class, if the class starts with any of these prefixes (e.g. "org.apache.hadoop"), then the ClassLoader would delegate immediately to the parent ClassLoader.
> I've already implemented a patch to provide this functionality which I'll attach shortly.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (HBASE-6308) Coprocessors should be loaded in a custom ClassLoader to prevent dependency conflicts with HBase

Posted by "Zhihong Ted Yu (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-6308?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13432871#comment-13432871 ] 

Zhihong Ted Yu commented on HBASE-6308:
---------------------------------------

Looks good. Minor comments below:
{code}
+ * Copyright 2010 The Apache Software Foundation
{code}
Year is not needed.
{code}
+    assertTrue("Class " + cpName5 + " was missing on a region", found_4);
+    assertTrue("Class " + cpName6 + " was missing on a region", found_5);
{code}
Should the numerals in cpNameX and found_Y match ?
                
> Coprocessors should be loaded in a custom ClassLoader to prevent dependency conflicts with HBase
> ------------------------------------------------------------------------------------------------
>
>                 Key: HBASE-6308
>                 URL: https://issues.apache.org/jira/browse/HBASE-6308
>             Project: HBase
>          Issue Type: Improvement
>          Components: coprocessors
>    Affects Versions: 0.92.1, 0.94.0
>            Reporter: James Baldassari
>            Assignee: Andrew Purtell
>             Fix For: 0.96.0
>
>         Attachments: 6308-v2.txt, HBASE-6308-0.92.patch, HBASE-6308-0.92-with-test.patch, HBASE-6308-0.94-with-test.patch, HBASE-6308-trunk.patch, HBASE-6308-trunk-with-test.patch
>
>
> Currently each coprocessor is loaded with a URLClassLoader that puts the coprocessor's jar at the beginning of the classpath.  The URLClassLoader always tries to load classes from the parent ClassLoader first and only attempts to load from its own configured URLs if the class was not found by the parent.  This class loading behavior can be problematic for coprocessors that have common dependencies with HBase but whose versions are incompatible.  For example, I have a coprocessor that depends on a different version of Avro than the version used by HBase.  The current class loading behavior results in NoSuchMethodErrors in my coprocessor because some Avro classes have already been loaded by HBase, and the ClassLoader for my coprocessor picks up HBase's loaded classes first.
> My proposed solution to this problem is to use a custom ClassLoader when instantiating coprocessor instances.  This custom ClassLoader would always attempt to load classes from the coprocessor's jar first and would only delegate to the parent ClassLoader if the class were not found in the coprocessor jar.  However, certain classes would need to be exempt from this behavior.  As an example, if the Copcoessor interface were loaded by both the region server's ClassLoader and the coprocessor's custom ClassLoader, then the region server would get a ClassCastException when attempting to cast the coprocessor instance to the Coprocessor interface.  This problem can be avoided by defining a set of class name prefixes that would be exempt from loading by the custom ClassLoader.  When loading a class, if the class starts with any of these prefixes (e.g. "org.apache.hadoop"), then the ClassLoader would delegate immediately to the parent ClassLoader.
> I've already implemented a patch to provide this functionality which I'll attach shortly.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (HBASE-6308) Coprocessors should be loaded in a custom ClassLoader to prevent dependency conflicts with HBase

Posted by "Andrew Purtell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-6308?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13432838#comment-13432838 ] 

Andrew Purtell commented on HBASE-6308:
---------------------------------------

Will commit shortly unless additional comment or objection.
                
> Coprocessors should be loaded in a custom ClassLoader to prevent dependency conflicts with HBase
> ------------------------------------------------------------------------------------------------
>
>                 Key: HBASE-6308
>                 URL: https://issues.apache.org/jira/browse/HBASE-6308
>             Project: HBase
>          Issue Type: Improvement
>          Components: coprocessors
>    Affects Versions: 0.92.1, 0.94.0
>            Reporter: James Baldassari
>            Assignee: Andrew Purtell
>             Fix For: 0.96.0
>
>         Attachments: 6308-v2.txt, HBASE-6308-0.92.patch, HBASE-6308-0.92-with-test.patch, HBASE-6308-0.94-with-test.patch, HBASE-6308-trunk.patch, HBASE-6308-trunk-with-test.patch
>
>
> Currently each coprocessor is loaded with a URLClassLoader that puts the coprocessor's jar at the beginning of the classpath.  The URLClassLoader always tries to load classes from the parent ClassLoader first and only attempts to load from its own configured URLs if the class was not found by the parent.  This class loading behavior can be problematic for coprocessors that have common dependencies with HBase but whose versions are incompatible.  For example, I have a coprocessor that depends on a different version of Avro than the version used by HBase.  The current class loading behavior results in NoSuchMethodErrors in my coprocessor because some Avro classes have already been loaded by HBase, and the ClassLoader for my coprocessor picks up HBase's loaded classes first.
> My proposed solution to this problem is to use a custom ClassLoader when instantiating coprocessor instances.  This custom ClassLoader would always attempt to load classes from the coprocessor's jar first and would only delegate to the parent ClassLoader if the class were not found in the coprocessor jar.  However, certain classes would need to be exempt from this behavior.  As an example, if the Copcoessor interface were loaded by both the region server's ClassLoader and the coprocessor's custom ClassLoader, then the region server would get a ClassCastException when attempting to cast the coprocessor instance to the Coprocessor interface.  This problem can be avoided by defining a set of class name prefixes that would be exempt from loading by the custom ClassLoader.  When loading a class, if the class starts with any of these prefixes (e.g. "org.apache.hadoop"), then the ClassLoader would delegate immediately to the parent ClassLoader.
> I've already implemented a patch to provide this functionality which I'll attach shortly.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (HBASE-6308) Coprocessors should be loaded in a custom ClassLoader to prevent dependency conflicts with HBase

Posted by "Andrew Purtell (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HBASE-6308?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andrew Purtell updated HBASE-6308:
----------------------------------

       Resolution: Fixed
    Fix Version/s: 0.94.2
                   0.92.2
           Status: Resolved  (was: Patch Available)

Committed to trunk, 0.94, and 0.92. TestClassLoading passes locally on all branches. Thanks for the patch James.
                
> Coprocessors should be loaded in a custom ClassLoader to prevent dependency conflicts with HBase
> ------------------------------------------------------------------------------------------------
>
>                 Key: HBASE-6308
>                 URL: https://issues.apache.org/jira/browse/HBASE-6308
>             Project: HBase
>          Issue Type: Improvement
>          Components: coprocessors
>    Affects Versions: 0.92.1, 0.94.0
>            Reporter: James Baldassari
>            Assignee: Andrew Purtell
>             Fix For: 0.92.2, 0.96.0, 0.94.2
>
>         Attachments: 6308-v2.txt, HBASE-6308-0.92.patch, HBASE-6308-0.92-with-test.patch, HBASE-6308-0.94-with-test.patch, HBASE-6308-trunk.patch, HBASE-6308-trunk-with-test.patch
>
>
> Currently each coprocessor is loaded with a URLClassLoader that puts the coprocessor's jar at the beginning of the classpath.  The URLClassLoader always tries to load classes from the parent ClassLoader first and only attempts to load from its own configured URLs if the class was not found by the parent.  This class loading behavior can be problematic for coprocessors that have common dependencies with HBase but whose versions are incompatible.  For example, I have a coprocessor that depends on a different version of Avro than the version used by HBase.  The current class loading behavior results in NoSuchMethodErrors in my coprocessor because some Avro classes have already been loaded by HBase, and the ClassLoader for my coprocessor picks up HBase's loaded classes first.
> My proposed solution to this problem is to use a custom ClassLoader when instantiating coprocessor instances.  This custom ClassLoader would always attempt to load classes from the coprocessor's jar first and would only delegate to the parent ClassLoader if the class were not found in the coprocessor jar.  However, certain classes would need to be exempt from this behavior.  As an example, if the Copcoessor interface were loaded by both the region server's ClassLoader and the coprocessor's custom ClassLoader, then the region server would get a ClassCastException when attempting to cast the coprocessor instance to the Coprocessor interface.  This problem can be avoided by defining a set of class name prefixes that would be exempt from loading by the custom ClassLoader.  When loading a class, if the class starts with any of these prefixes (e.g. "org.apache.hadoop"), then the ClassLoader would delegate immediately to the parent ClassLoader.
> I've already implemented a patch to provide this functionality which I'll attach shortly.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (HBASE-6308) Coprocessors should be loaded in a custom ClassLoader to prevent dependency conflicts with HBase

Posted by "Hadoop QA (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-6308?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13408437#comment-13408437 ] 

Hadoop QA commented on HBASE-6308:
----------------------------------

-1 overall.  Here are the results of testing the latest attachment 
  http://issues.apache.org/jira/secure/attachment/12535401/6308-v2.txt
  against trunk revision .

    +1 @author.  The patch does not contain any @author tags.

    -1 tests included.  The patch doesn't appear to include any new or modified tests.
                        Please justify why no new tests are needed for this patch.
                        Also please list what manual steps were performed to verify this patch.

    +1 hadoop2.0.  The patch compiles against the hadoop 2.0 profile.

    +1 javadoc.  The javadoc tool did not generate any warning messages.

    -1 javac.  The applied patch generated 5 javac compiler warnings (more than the trunk's current 4 warnings).

    -1 findbugs.  The patch appears to introduce 7 new Findbugs (version 1.3.9) warnings.

    +1 release audit.  The applied patch does not increase the total number of release audit warnings.

     -1 core tests.  The patch failed these unit tests:
                       org.apache.hadoop.hbase.coprocessor.TestRegionServerCoprocessorExceptionWithAbort

Test results: https://builds.apache.org/job/PreCommit-HBASE-Build/2337//testReport/
Findbugs warnings: https://builds.apache.org/job/PreCommit-HBASE-Build/2337//artifact/trunk/patchprocess/newPatchFindbugsWarningshbase-server.html
Findbugs warnings: https://builds.apache.org/job/PreCommit-HBASE-Build/2337//artifact/trunk/patchprocess/newPatchFindbugsWarningshbase-common.html
Console output: https://builds.apache.org/job/PreCommit-HBASE-Build/2337//console

This message is automatically generated.
                
> Coprocessors should be loaded in a custom ClassLoader to prevent dependency conflicts with HBase
> ------------------------------------------------------------------------------------------------
>
>                 Key: HBASE-6308
>                 URL: https://issues.apache.org/jira/browse/HBASE-6308
>             Project: HBase
>          Issue Type: Improvement
>          Components: coprocessors
>    Affects Versions: 0.92.1, 0.94.0
>            Reporter: James Baldassari
>             Fix For: 0.96.0
>
>         Attachments: 6308-v2.txt, HBASE-6308-0.92.patch, HBASE-6308-trunk.patch
>
>
> Currently each coprocessor is loaded with a URLClassLoader that puts the coprocessor's jar at the beginning of the classpath.  The URLClassLoader always tries to load classes from the parent ClassLoader first and only attempts to load from its own configured URLs if the class was not found by the parent.  This class loading behavior can be problematic for coprocessors that have common dependencies with HBase but whose versions are incompatible.  For example, I have a coprocessor that depends on a different version of Avro than the version used by HBase.  The current class loading behavior results in NoSuchMethodErrors in my coprocessor because some Avro classes have already been loaded by HBase, and the ClassLoader for my coprocessor picks up HBase's loaded classes first.
> My proposed solution to this problem is to use a custom ClassLoader when instantiating coprocessor instances.  This custom ClassLoader would always attempt to load classes from the coprocessor's jar first and would only delegate to the parent ClassLoader if the class were not found in the coprocessor jar.  However, certain classes would need to be exempt from this behavior.  As an example, if the Copcoessor interface were loaded by both the region server's ClassLoader and the coprocessor's custom ClassLoader, then the region server would get a ClassCastException when attempting to cast the coprocessor instance to the Coprocessor interface.  This problem can be avoided by defining a set of class name prefixes that would be exempt from loading by the custom ClassLoader.  When loading a class, if the class starts with any of these prefixes (e.g. "org.apache.hadoop"), then the ClassLoader would delegate immediately to the parent ClassLoader.
> I've already implemented a patch to provide this functionality which I'll attach shortly.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (HBASE-6308) Coprocessors should be loaded in a custom ClassLoader to prevent dependency conflicts with HBase

Posted by "Andrew Purtell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-6308?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13405438#comment-13405438 ] 

Andrew Purtell commented on HBASE-6308:
---------------------------------------

I'm going to try out your patch on a test cluster that loads AccessController.
                
> Coprocessors should be loaded in a custom ClassLoader to prevent dependency conflicts with HBase
> ------------------------------------------------------------------------------------------------
>
>                 Key: HBASE-6308
>                 URL: https://issues.apache.org/jira/browse/HBASE-6308
>             Project: HBase
>          Issue Type: Improvement
>          Components: coprocessors
>    Affects Versions: 0.92.1, 0.94.0
>            Reporter: James Baldassari
>         Attachments: HBASE-6308-0.92.patch, HBASE-6308-trunk.patch
>
>
> Currently each coprocessor is loaded with a URLClassLoader that puts the coprocessor's jar at the beginning of the classpath.  The URLClassLoader always tries to load classes from the parent ClassLoader first and only attempts to load from its own configured URLs if the class was not found by the parent.  This class loading behavior can be problematic for coprocessors that have common dependencies with HBase but whose versions are incompatible.  For example, I have a coprocessor that depends on a different version of Avro than the version used by HBase.  The current class loading behavior results in NoSuchMethodErrors in my coprocessor because some Avro classes have already been loaded by HBase, and the ClassLoader for my coprocessor picks up HBase's loaded classes first.
> My proposed solution to this problem is to use a custom ClassLoader when instantiating coprocessor instances.  This custom ClassLoader would always attempt to load classes from the coprocessor's jar first and would only delegate to the parent ClassLoader if the class were not found in the coprocessor jar.  However, certain classes would need to be exempt from this behavior.  As an example, if the Copcoessor interface were loaded by both the region server's ClassLoader and the coprocessor's custom ClassLoader, then the region server would get a ClassCastException when attempting to cast the coprocessor instance to the Coprocessor interface.  This problem can be avoided by defining a set of class name prefixes that would be exempt from loading by the custom ClassLoader.  When loading a class, if the class starts with any of these prefixes (e.g. "org.apache.hadoop"), then the ClassLoader would delegate immediately to the parent ClassLoader.
> I've already implemented a patch to provide this functionality which I'll attach shortly.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (HBASE-6308) Coprocessors should be loaded in a custom ClassLoader to prevent dependency conflicts with HBase

Posted by "Hudson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-6308?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13440144#comment-13440144 ] 

Hudson commented on HBASE-6308:
-------------------------------

Integrated in HBase-0.92-security #116 (See [https://builds.apache.org/job/HBase-0.92-security/116/])
    HBASE-6308. Coprocessors should be loaded in a custom ClassLoader (James Baldassari) (Revision 1372562)

     Result = FAILURE
apurtell : 
Files : 
* /hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/coprocessor/CoprocessorClassLoader.java
* /hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/coprocessor/CoprocessorHost.java
* /hbase/branches/0.92/src/test/java/org/apache/hadoop/hbase/coprocessor/TestClassLoading.java

                
> Coprocessors should be loaded in a custom ClassLoader to prevent dependency conflicts with HBase
> ------------------------------------------------------------------------------------------------
>
>                 Key: HBASE-6308
>                 URL: https://issues.apache.org/jira/browse/HBASE-6308
>             Project: HBase
>          Issue Type: Improvement
>          Components: coprocessors
>    Affects Versions: 0.92.1, 0.94.0
>            Reporter: James Baldassari
>            Assignee: Andrew Purtell
>             Fix For: 0.92.2, 0.96.0, 0.94.2
>
>         Attachments: 6308-v2.txt, HBASE-6308-0.92.patch, HBASE-6308-0.92-with-test.patch, HBASE-6308-0.94-with-test.patch, HBASE-6308-trunk.patch, HBASE-6308-trunk-with-test.patch
>
>
> Currently each coprocessor is loaded with a URLClassLoader that puts the coprocessor's jar at the beginning of the classpath.  The URLClassLoader always tries to load classes from the parent ClassLoader first and only attempts to load from its own configured URLs if the class was not found by the parent.  This class loading behavior can be problematic for coprocessors that have common dependencies with HBase but whose versions are incompatible.  For example, I have a coprocessor that depends on a different version of Avro than the version used by HBase.  The current class loading behavior results in NoSuchMethodErrors in my coprocessor because some Avro classes have already been loaded by HBase, and the ClassLoader for my coprocessor picks up HBase's loaded classes first.
> My proposed solution to this problem is to use a custom ClassLoader when instantiating coprocessor instances.  This custom ClassLoader would always attempt to load classes from the coprocessor's jar first and would only delegate to the parent ClassLoader if the class were not found in the coprocessor jar.  However, certain classes would need to be exempt from this behavior.  As an example, if the Copcoessor interface were loaded by both the region server's ClassLoader and the coprocessor's custom ClassLoader, then the region server would get a ClassCastException when attempting to cast the coprocessor instance to the Coprocessor interface.  This problem can be avoided by defining a set of class name prefixes that would be exempt from loading by the custom ClassLoader.  When loading a class, if the class starts with any of these prefixes (e.g. "org.apache.hadoop"), then the ClassLoader would delegate immediately to the parent ClassLoader.
> I've already implemented a patch to provide this functionality which I'll attach shortly.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (HBASE-6308) Coprocessors should be loaded in a custom ClassLoader to prevent dependency conflicts with HBase

Posted by "Andrew Purtell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-6308?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13431936#comment-13431936 ] 

Andrew Purtell commented on HBASE-6308:
---------------------------------------

I'll take this. Will add a simple test and commit.
                
> Coprocessors should be loaded in a custom ClassLoader to prevent dependency conflicts with HBase
> ------------------------------------------------------------------------------------------------
>
>                 Key: HBASE-6308
>                 URL: https://issues.apache.org/jira/browse/HBASE-6308
>             Project: HBase
>          Issue Type: Improvement
>          Components: coprocessors
>    Affects Versions: 0.92.1, 0.94.0
>            Reporter: James Baldassari
>            Assignee: Andrew Purtell
>             Fix For: 0.96.0
>
>         Attachments: 6308-v2.txt, HBASE-6308-0.92.patch, HBASE-6308-trunk.patch
>
>
> Currently each coprocessor is loaded with a URLClassLoader that puts the coprocessor's jar at the beginning of the classpath.  The URLClassLoader always tries to load classes from the parent ClassLoader first and only attempts to load from its own configured URLs if the class was not found by the parent.  This class loading behavior can be problematic for coprocessors that have common dependencies with HBase but whose versions are incompatible.  For example, I have a coprocessor that depends on a different version of Avro than the version used by HBase.  The current class loading behavior results in NoSuchMethodErrors in my coprocessor because some Avro classes have already been loaded by HBase, and the ClassLoader for my coprocessor picks up HBase's loaded classes first.
> My proposed solution to this problem is to use a custom ClassLoader when instantiating coprocessor instances.  This custom ClassLoader would always attempt to load classes from the coprocessor's jar first and would only delegate to the parent ClassLoader if the class were not found in the coprocessor jar.  However, certain classes would need to be exempt from this behavior.  As an example, if the Copcoessor interface were loaded by both the region server's ClassLoader and the coprocessor's custom ClassLoader, then the region server would get a ClassCastException when attempting to cast the coprocessor instance to the Coprocessor interface.  This problem can be avoided by defining a set of class name prefixes that would be exempt from loading by the custom ClassLoader.  When loading a class, if the class starts with any of these prefixes (e.g. "org.apache.hadoop"), then the ClassLoader would delegate immediately to the parent ClassLoader.
> I've already implemented a patch to provide this functionality which I'll attach shortly.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (HBASE-6308) Coprocessors should be loaded in a custom ClassLoader to prevent dependency conflicts with HBase

Posted by "Andrew Purtell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-6308?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13410638#comment-13410638 ] 

Andrew Purtell commented on HBASE-6308:
---------------------------------------

bq. Also, one of the reasons I didn't write a test in the original patch was that I couldn't seem to get the unit tests to run even without my changes. Most of the tests (including TestClassLoading) seem to fail with a NullPointerException in MiniDFSCluster.startDataNodes(), line 422. 

'umask 022' in the shell you have open for running tests, then run the suite again, James.
                
> Coprocessors should be loaded in a custom ClassLoader to prevent dependency conflicts with HBase
> ------------------------------------------------------------------------------------------------
>
>                 Key: HBASE-6308
>                 URL: https://issues.apache.org/jira/browse/HBASE-6308
>             Project: HBase
>          Issue Type: Improvement
>          Components: coprocessors
>    Affects Versions: 0.92.1, 0.94.0
>            Reporter: James Baldassari
>             Fix For: 0.96.0
>
>         Attachments: 6308-v2.txt, HBASE-6308-0.92.patch, HBASE-6308-trunk.patch
>
>
> Currently each coprocessor is loaded with a URLClassLoader that puts the coprocessor's jar at the beginning of the classpath.  The URLClassLoader always tries to load classes from the parent ClassLoader first and only attempts to load from its own configured URLs if the class was not found by the parent.  This class loading behavior can be problematic for coprocessors that have common dependencies with HBase but whose versions are incompatible.  For example, I have a coprocessor that depends on a different version of Avro than the version used by HBase.  The current class loading behavior results in NoSuchMethodErrors in my coprocessor because some Avro classes have already been loaded by HBase, and the ClassLoader for my coprocessor picks up HBase's loaded classes first.
> My proposed solution to this problem is to use a custom ClassLoader when instantiating coprocessor instances.  This custom ClassLoader would always attempt to load classes from the coprocessor's jar first and would only delegate to the parent ClassLoader if the class were not found in the coprocessor jar.  However, certain classes would need to be exempt from this behavior.  As an example, if the Copcoessor interface were loaded by both the region server's ClassLoader and the coprocessor's custom ClassLoader, then the region server would get a ClassCastException when attempting to cast the coprocessor instance to the Coprocessor interface.  This problem can be avoided by defining a set of class name prefixes that would be exempt from loading by the custom ClassLoader.  When loading a class, if the class starts with any of these prefixes (e.g. "org.apache.hadoop"), then the ClassLoader would delegate immediately to the parent ClassLoader.
> I've already implemented a patch to provide this functionality which I'll attach shortly.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (HBASE-6308) Coprocessors should be loaded in a custom ClassLoader to prevent dependency conflicts with HBase

Posted by "Hadoop QA (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-6308?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13432840#comment-13432840 ] 

Hadoop QA commented on HBASE-6308:
----------------------------------

-1 overall.  Here are the results of testing the latest attachment 
  http://issues.apache.org/jira/secure/attachment/12540581/HBASE-6308-0.92-with-test.patch
  against trunk revision .

    +1 @author.  The patch does not contain any @author tags.

    +1 tests included.  The patch appears to include 3 new or modified tests.

    -1 patch.  The patch command could not apply the patch.

Console output: https://builds.apache.org/job/PreCommit-HBASE-Build/2549//console

This message is automatically generated.
                
> Coprocessors should be loaded in a custom ClassLoader to prevent dependency conflicts with HBase
> ------------------------------------------------------------------------------------------------
>
>                 Key: HBASE-6308
>                 URL: https://issues.apache.org/jira/browse/HBASE-6308
>             Project: HBase
>          Issue Type: Improvement
>          Components: coprocessors
>    Affects Versions: 0.92.1, 0.94.0
>            Reporter: James Baldassari
>            Assignee: Andrew Purtell
>             Fix For: 0.96.0
>
>         Attachments: 6308-v2.txt, HBASE-6308-0.92.patch, HBASE-6308-0.92-with-test.patch, HBASE-6308-0.94-with-test.patch, HBASE-6308-trunk.patch, HBASE-6308-trunk-with-test.patch
>
>
> Currently each coprocessor is loaded with a URLClassLoader that puts the coprocessor's jar at the beginning of the classpath.  The URLClassLoader always tries to load classes from the parent ClassLoader first and only attempts to load from its own configured URLs if the class was not found by the parent.  This class loading behavior can be problematic for coprocessors that have common dependencies with HBase but whose versions are incompatible.  For example, I have a coprocessor that depends on a different version of Avro than the version used by HBase.  The current class loading behavior results in NoSuchMethodErrors in my coprocessor because some Avro classes have already been loaded by HBase, and the ClassLoader for my coprocessor picks up HBase's loaded classes first.
> My proposed solution to this problem is to use a custom ClassLoader when instantiating coprocessor instances.  This custom ClassLoader would always attempt to load classes from the coprocessor's jar first and would only delegate to the parent ClassLoader if the class were not found in the coprocessor jar.  However, certain classes would need to be exempt from this behavior.  As an example, if the Copcoessor interface were loaded by both the region server's ClassLoader and the coprocessor's custom ClassLoader, then the region server would get a ClassCastException when attempting to cast the coprocessor instance to the Coprocessor interface.  This problem can be avoided by defining a set of class name prefixes that would be exempt from loading by the custom ClassLoader.  When loading a class, if the class starts with any of these prefixes (e.g. "org.apache.hadoop"), then the ClassLoader would delegate immediately to the parent ClassLoader.
> I've already implemented a patch to provide this functionality which I'll attach shortly.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (HBASE-6308) Coprocessors should be loaded in a custom ClassLoader to prevent dependency conflicts with HBase

Posted by "James Baldassari (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-6308?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13410490#comment-13410490 ] 

James Baldassari commented on HBASE-6308:
-----------------------------------------

I'm hoping to find some time to work on a simple test this week, but if anyone else wants to work on one feel free.  Also, one of the reasons I didn't write a test in the original patch was that I couldn't seem to get the unit tests to run even without my changes.  Most of the tests (including TestClassLoading) seem to fail with a NullPointerException in MiniDFSCluster.startDataNodes(), line 422.  Is there some special property or profile I need to set to get them to run?
                
> Coprocessors should be loaded in a custom ClassLoader to prevent dependency conflicts with HBase
> ------------------------------------------------------------------------------------------------
>
>                 Key: HBASE-6308
>                 URL: https://issues.apache.org/jira/browse/HBASE-6308
>             Project: HBase
>          Issue Type: Improvement
>          Components: coprocessors
>    Affects Versions: 0.92.1, 0.94.0
>            Reporter: James Baldassari
>             Fix For: 0.96.0
>
>         Attachments: 6308-v2.txt, HBASE-6308-0.92.patch, HBASE-6308-trunk.patch
>
>
> Currently each coprocessor is loaded with a URLClassLoader that puts the coprocessor's jar at the beginning of the classpath.  The URLClassLoader always tries to load classes from the parent ClassLoader first and only attempts to load from its own configured URLs if the class was not found by the parent.  This class loading behavior can be problematic for coprocessors that have common dependencies with HBase but whose versions are incompatible.  For example, I have a coprocessor that depends on a different version of Avro than the version used by HBase.  The current class loading behavior results in NoSuchMethodErrors in my coprocessor because some Avro classes have already been loaded by HBase, and the ClassLoader for my coprocessor picks up HBase's loaded classes first.
> My proposed solution to this problem is to use a custom ClassLoader when instantiating coprocessor instances.  This custom ClassLoader would always attempt to load classes from the coprocessor's jar first and would only delegate to the parent ClassLoader if the class were not found in the coprocessor jar.  However, certain classes would need to be exempt from this behavior.  As an example, if the Copcoessor interface were loaded by both the region server's ClassLoader and the coprocessor's custom ClassLoader, then the region server would get a ClassCastException when attempting to cast the coprocessor instance to the Coprocessor interface.  This problem can be avoided by defining a set of class name prefixes that would be exempt from loading by the custom ClassLoader.  When loading a class, if the class starts with any of these prefixes (e.g. "org.apache.hadoop"), then the ClassLoader would delegate immediately to the parent ClassLoader.
> I've already implemented a patch to provide this functionality which I'll attach shortly.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (HBASE-6308) Coprocessors should be loaded in a custom ClassLoader to prevent dependency conflicts with HBase

Posted by "Hudson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-6308?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13439522#comment-13439522 ] 

Hudson commented on HBASE-6308:
-------------------------------

Integrated in HBase-0.94-security #48 (See [https://builds.apache.org/job/HBase-0.94-security/48/])
    HBASE-6308. Coprocessors should be loaded in a custom ClassLoader (James Baldassari) (Revision 1372561)

     Result = FAILURE
apurtell : 
Files : 
* /hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/coprocessor/CoprocessorClassLoader.java
* /hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/coprocessor/CoprocessorHost.java
* /hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/coprocessor/TestClassLoading.java

                
> Coprocessors should be loaded in a custom ClassLoader to prevent dependency conflicts with HBase
> ------------------------------------------------------------------------------------------------
>
>                 Key: HBASE-6308
>                 URL: https://issues.apache.org/jira/browse/HBASE-6308
>             Project: HBase
>          Issue Type: Improvement
>          Components: coprocessors
>    Affects Versions: 0.92.1, 0.94.0
>            Reporter: James Baldassari
>            Assignee: Andrew Purtell
>             Fix For: 0.92.2, 0.96.0, 0.94.2
>
>         Attachments: 6308-v2.txt, HBASE-6308-0.92.patch, HBASE-6308-0.92-with-test.patch, HBASE-6308-0.94-with-test.patch, HBASE-6308-trunk.patch, HBASE-6308-trunk-with-test.patch
>
>
> Currently each coprocessor is loaded with a URLClassLoader that puts the coprocessor's jar at the beginning of the classpath.  The URLClassLoader always tries to load classes from the parent ClassLoader first and only attempts to load from its own configured URLs if the class was not found by the parent.  This class loading behavior can be problematic for coprocessors that have common dependencies with HBase but whose versions are incompatible.  For example, I have a coprocessor that depends on a different version of Avro than the version used by HBase.  The current class loading behavior results in NoSuchMethodErrors in my coprocessor because some Avro classes have already been loaded by HBase, and the ClassLoader for my coprocessor picks up HBase's loaded classes first.
> My proposed solution to this problem is to use a custom ClassLoader when instantiating coprocessor instances.  This custom ClassLoader would always attempt to load classes from the coprocessor's jar first and would only delegate to the parent ClassLoader if the class were not found in the coprocessor jar.  However, certain classes would need to be exempt from this behavior.  As an example, if the Copcoessor interface were loaded by both the region server's ClassLoader and the coprocessor's custom ClassLoader, then the region server would get a ClassCastException when attempting to cast the coprocessor instance to the Coprocessor interface.  This problem can be avoided by defining a set of class name prefixes that would be exempt from loading by the custom ClassLoader.  When loading a class, if the class starts with any of these prefixes (e.g. "org.apache.hadoop"), then the ClassLoader would delegate immediately to the parent ClassLoader.
> I've already implemented a patch to provide this functionality which I'll attach shortly.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (HBASE-6308) Coprocessors should be loaded in a custom ClassLoader to prevent dependency conflicts with HBase

Posted by "Hudson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-6308?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13448344#comment-13448344 ] 

Hudson commented on HBASE-6308:
-------------------------------

Integrated in HBase-0.94-security-on-Hadoop-23 #7 (See [https://builds.apache.org/job/HBase-0.94-security-on-Hadoop-23/7/])
    HBASE-6308. Coprocessors should be loaded in a custom ClassLoader (James Baldassari) (Revision 1372561)

     Result = FAILURE
apurtell : 
Files : 
* /hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/coprocessor/CoprocessorClassLoader.java
* /hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/coprocessor/CoprocessorHost.java
* /hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/coprocessor/TestClassLoading.java

                
> Coprocessors should be loaded in a custom ClassLoader to prevent dependency conflicts with HBase
> ------------------------------------------------------------------------------------------------
>
>                 Key: HBASE-6308
>                 URL: https://issues.apache.org/jira/browse/HBASE-6308
>             Project: HBase
>          Issue Type: Improvement
>          Components: coprocessors
>    Affects Versions: 0.92.1, 0.94.0
>            Reporter: James Baldassari
>            Assignee: Andrew Purtell
>             Fix For: 0.92.2, 0.96.0, 0.94.2
>
>         Attachments: 6308-v2.txt, HBASE-6308-0.92.patch, HBASE-6308-0.92-with-test.patch, HBASE-6308-0.94-with-test.patch, HBASE-6308-trunk.patch, HBASE-6308-trunk-with-test.patch
>
>
> Currently each coprocessor is loaded with a URLClassLoader that puts the coprocessor's jar at the beginning of the classpath.  The URLClassLoader always tries to load classes from the parent ClassLoader first and only attempts to load from its own configured URLs if the class was not found by the parent.  This class loading behavior can be problematic for coprocessors that have common dependencies with HBase but whose versions are incompatible.  For example, I have a coprocessor that depends on a different version of Avro than the version used by HBase.  The current class loading behavior results in NoSuchMethodErrors in my coprocessor because some Avro classes have already been loaded by HBase, and the ClassLoader for my coprocessor picks up HBase's loaded classes first.
> My proposed solution to this problem is to use a custom ClassLoader when instantiating coprocessor instances.  This custom ClassLoader would always attempt to load classes from the coprocessor's jar first and would only delegate to the parent ClassLoader if the class were not found in the coprocessor jar.  However, certain classes would need to be exempt from this behavior.  As an example, if the Copcoessor interface were loaded by both the region server's ClassLoader and the coprocessor's custom ClassLoader, then the region server would get a ClassCastException when attempting to cast the coprocessor instance to the Coprocessor interface.  This problem can be avoided by defining a set of class name prefixes that would be exempt from loading by the custom ClassLoader.  When loading a class, if the class starts with any of these prefixes (e.g. "org.apache.hadoop"), then the ClassLoader would delegate immediately to the parent ClassLoader.
> I've already implemented a patch to provide this functionality which I'll attach shortly.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (HBASE-6308) Coprocessors should be loaded in a custom ClassLoader to prevent dependency conflicts with HBase

Posted by "Hudson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-6308?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13434666#comment-13434666 ] 

Hudson commented on HBASE-6308:
-------------------------------

Integrated in HBase-TRUNK-on-Hadoop-2.0.0 #130 (See [https://builds.apache.org/job/HBase-TRUNK-on-Hadoop-2.0.0/130/])
    HBASE-6308. Coprocessors should be loaded in a custom ClassLoader (James Baldassari) (Revision 1372558)

     Result = FAILURE
apurtell : 
Files : 
* /hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/CoprocessorClassLoader.java
* /hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/CoprocessorHost.java
* /hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestClassLoading.java

                
> Coprocessors should be loaded in a custom ClassLoader to prevent dependency conflicts with HBase
> ------------------------------------------------------------------------------------------------
>
>                 Key: HBASE-6308
>                 URL: https://issues.apache.org/jira/browse/HBASE-6308
>             Project: HBase
>          Issue Type: Improvement
>          Components: coprocessors
>    Affects Versions: 0.92.1, 0.94.0
>            Reporter: James Baldassari
>            Assignee: Andrew Purtell
>             Fix For: 0.92.2, 0.96.0, 0.94.2
>
>         Attachments: 6308-v2.txt, HBASE-6308-0.92.patch, HBASE-6308-0.92-with-test.patch, HBASE-6308-0.94-with-test.patch, HBASE-6308-trunk.patch, HBASE-6308-trunk-with-test.patch
>
>
> Currently each coprocessor is loaded with a URLClassLoader that puts the coprocessor's jar at the beginning of the classpath.  The URLClassLoader always tries to load classes from the parent ClassLoader first and only attempts to load from its own configured URLs if the class was not found by the parent.  This class loading behavior can be problematic for coprocessors that have common dependencies with HBase but whose versions are incompatible.  For example, I have a coprocessor that depends on a different version of Avro than the version used by HBase.  The current class loading behavior results in NoSuchMethodErrors in my coprocessor because some Avro classes have already been loaded by HBase, and the ClassLoader for my coprocessor picks up HBase's loaded classes first.
> My proposed solution to this problem is to use a custom ClassLoader when instantiating coprocessor instances.  This custom ClassLoader would always attempt to load classes from the coprocessor's jar first and would only delegate to the parent ClassLoader if the class were not found in the coprocessor jar.  However, certain classes would need to be exempt from this behavior.  As an example, if the Copcoessor interface were loaded by both the region server's ClassLoader and the coprocessor's custom ClassLoader, then the region server would get a ClassCastException when attempting to cast the coprocessor instance to the Coprocessor interface.  This problem can be avoided by defining a set of class name prefixes that would be exempt from loading by the custom ClassLoader.  When loading a class, if the class starts with any of these prefixes (e.g. "org.apache.hadoop"), then the ClassLoader would delegate immediately to the parent ClassLoader.
> I've already implemented a patch to provide this functionality which I'll attach shortly.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (HBASE-6308) Coprocessors should be loaded in a custom ClassLoader to prevent dependency conflicts with HBase

Posted by "Andrew Purtell (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HBASE-6308?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andrew Purtell updated HBASE-6308:
----------------------------------

    Attachment: HBASE-6308-0.92-with-test.patch
                HBASE-6308-0.94-with-test.patch
                HBASE-6308-trunk-with-test.patch

Added test case to TestClassLoading that verifies coprocessors are loaded by the new CoprocessorClassloader. New test passes locally. All CP tests pass locally.
                
> Coprocessors should be loaded in a custom ClassLoader to prevent dependency conflicts with HBase
> ------------------------------------------------------------------------------------------------
>
>                 Key: HBASE-6308
>                 URL: https://issues.apache.org/jira/browse/HBASE-6308
>             Project: HBase
>          Issue Type: Improvement
>          Components: coprocessors
>    Affects Versions: 0.92.1, 0.94.0
>            Reporter: James Baldassari
>            Assignee: Andrew Purtell
>             Fix For: 0.96.0
>
>         Attachments: 6308-v2.txt, HBASE-6308-0.92.patch, HBASE-6308-0.92-with-test.patch, HBASE-6308-0.94-with-test.patch, HBASE-6308-trunk.patch, HBASE-6308-trunk-with-test.patch
>
>
> Currently each coprocessor is loaded with a URLClassLoader that puts the coprocessor's jar at the beginning of the classpath.  The URLClassLoader always tries to load classes from the parent ClassLoader first and only attempts to load from its own configured URLs if the class was not found by the parent.  This class loading behavior can be problematic for coprocessors that have common dependencies with HBase but whose versions are incompatible.  For example, I have a coprocessor that depends on a different version of Avro than the version used by HBase.  The current class loading behavior results in NoSuchMethodErrors in my coprocessor because some Avro classes have already been loaded by HBase, and the ClassLoader for my coprocessor picks up HBase's loaded classes first.
> My proposed solution to this problem is to use a custom ClassLoader when instantiating coprocessor instances.  This custom ClassLoader would always attempt to load classes from the coprocessor's jar first and would only delegate to the parent ClassLoader if the class were not found in the coprocessor jar.  However, certain classes would need to be exempt from this behavior.  As an example, if the Copcoessor interface were loaded by both the region server's ClassLoader and the coprocessor's custom ClassLoader, then the region server would get a ClassCastException when attempting to cast the coprocessor instance to the Coprocessor interface.  This problem can be avoided by defining a set of class name prefixes that would be exempt from loading by the custom ClassLoader.  When loading a class, if the class starts with any of these prefixes (e.g. "org.apache.hadoop"), then the ClassLoader would delegate immediately to the parent ClassLoader.
> I've already implemented a patch to provide this functionality which I'll attach shortly.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (HBASE-6308) Coprocessors should be loaded in a custom ClassLoader to prevent dependency conflicts with HBase

Posted by "Andrew Purtell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-6308?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13408214#comment-13408214 ] 

Andrew Purtell commented on HBASE-6308:
---------------------------------------

This needs a test before commit. I plan to get to that next week unless James comes in with one first.
                
> Coprocessors should be loaded in a custom ClassLoader to prevent dependency conflicts with HBase
> ------------------------------------------------------------------------------------------------
>
>                 Key: HBASE-6308
>                 URL: https://issues.apache.org/jira/browse/HBASE-6308
>             Project: HBase
>          Issue Type: Improvement
>          Components: coprocessors
>    Affects Versions: 0.92.1, 0.94.0
>            Reporter: James Baldassari
>             Fix For: 0.96.0
>
>         Attachments: 6308-v2.txt, HBASE-6308-0.92.patch, HBASE-6308-trunk.patch
>
>
> Currently each coprocessor is loaded with a URLClassLoader that puts the coprocessor's jar at the beginning of the classpath.  The URLClassLoader always tries to load classes from the parent ClassLoader first and only attempts to load from its own configured URLs if the class was not found by the parent.  This class loading behavior can be problematic for coprocessors that have common dependencies with HBase but whose versions are incompatible.  For example, I have a coprocessor that depends on a different version of Avro than the version used by HBase.  The current class loading behavior results in NoSuchMethodErrors in my coprocessor because some Avro classes have already been loaded by HBase, and the ClassLoader for my coprocessor picks up HBase's loaded classes first.
> My proposed solution to this problem is to use a custom ClassLoader when instantiating coprocessor instances.  This custom ClassLoader would always attempt to load classes from the coprocessor's jar first and would only delegate to the parent ClassLoader if the class were not found in the coprocessor jar.  However, certain classes would need to be exempt from this behavior.  As an example, if the Copcoessor interface were loaded by both the region server's ClassLoader and the coprocessor's custom ClassLoader, then the region server would get a ClassCastException when attempting to cast the coprocessor instance to the Coprocessor interface.  This problem can be avoided by defining a set of class name prefixes that would be exempt from loading by the custom ClassLoader.  When loading a class, if the class starts with any of these prefixes (e.g. "org.apache.hadoop"), then the ClassLoader would delegate immediately to the parent ClassLoader.
> I've already implemented a patch to provide this functionality which I'll attach shortly.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Assigned] (HBASE-6308) Coprocessors should be loaded in a custom ClassLoader to prevent dependency conflicts with HBase

Posted by "Andrew Purtell (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HBASE-6308?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andrew Purtell reassigned HBASE-6308:
-------------------------------------

    Assignee: Andrew Purtell
    
> Coprocessors should be loaded in a custom ClassLoader to prevent dependency conflicts with HBase
> ------------------------------------------------------------------------------------------------
>
>                 Key: HBASE-6308
>                 URL: https://issues.apache.org/jira/browse/HBASE-6308
>             Project: HBase
>          Issue Type: Improvement
>          Components: coprocessors
>    Affects Versions: 0.92.1, 0.94.0
>            Reporter: James Baldassari
>            Assignee: Andrew Purtell
>             Fix For: 0.96.0
>
>         Attachments: 6308-v2.txt, HBASE-6308-0.92.patch, HBASE-6308-trunk.patch
>
>
> Currently each coprocessor is loaded with a URLClassLoader that puts the coprocessor's jar at the beginning of the classpath.  The URLClassLoader always tries to load classes from the parent ClassLoader first and only attempts to load from its own configured URLs if the class was not found by the parent.  This class loading behavior can be problematic for coprocessors that have common dependencies with HBase but whose versions are incompatible.  For example, I have a coprocessor that depends on a different version of Avro than the version used by HBase.  The current class loading behavior results in NoSuchMethodErrors in my coprocessor because some Avro classes have already been loaded by HBase, and the ClassLoader for my coprocessor picks up HBase's loaded classes first.
> My proposed solution to this problem is to use a custom ClassLoader when instantiating coprocessor instances.  This custom ClassLoader would always attempt to load classes from the coprocessor's jar first and would only delegate to the parent ClassLoader if the class were not found in the coprocessor jar.  However, certain classes would need to be exempt from this behavior.  As an example, if the Copcoessor interface were loaded by both the region server's ClassLoader and the coprocessor's custom ClassLoader, then the region server would get a ClassCastException when attempting to cast the coprocessor instance to the Coprocessor interface.  This problem can be avoided by defining a set of class name prefixes that would be exempt from loading by the custom ClassLoader.  When loading a class, if the class starts with any of these prefixes (e.g. "org.apache.hadoop"), then the ClassLoader would delegate immediately to the parent ClassLoader.
> I've already implemented a patch to provide this functionality which I'll attach shortly.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (HBASE-6308) Coprocessors should be loaded in a custom ClassLoader to prevent dependency conflicts with HBase

Posted by "Andrew Purtell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-6308?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13433435#comment-13433435 ] 

Andrew Purtell commented on HBASE-6308:
---------------------------------------

bq. Should the numerals in cpNameX and found_Y match ? 

Sure, the cpName variables were updated by search and replace. Will fix up the found_* ones too on commit.

                
> Coprocessors should be loaded in a custom ClassLoader to prevent dependency conflicts with HBase
> ------------------------------------------------------------------------------------------------
>
>                 Key: HBASE-6308
>                 URL: https://issues.apache.org/jira/browse/HBASE-6308
>             Project: HBase
>          Issue Type: Improvement
>          Components: coprocessors
>    Affects Versions: 0.92.1, 0.94.0
>            Reporter: James Baldassari
>            Assignee: Andrew Purtell
>             Fix For: 0.96.0
>
>         Attachments: 6308-v2.txt, HBASE-6308-0.92.patch, HBASE-6308-0.92-with-test.patch, HBASE-6308-0.94-with-test.patch, HBASE-6308-trunk.patch, HBASE-6308-trunk-with-test.patch
>
>
> Currently each coprocessor is loaded with a URLClassLoader that puts the coprocessor's jar at the beginning of the classpath.  The URLClassLoader always tries to load classes from the parent ClassLoader first and only attempts to load from its own configured URLs if the class was not found by the parent.  This class loading behavior can be problematic for coprocessors that have common dependencies with HBase but whose versions are incompatible.  For example, I have a coprocessor that depends on a different version of Avro than the version used by HBase.  The current class loading behavior results in NoSuchMethodErrors in my coprocessor because some Avro classes have already been loaded by HBase, and the ClassLoader for my coprocessor picks up HBase's loaded classes first.
> My proposed solution to this problem is to use a custom ClassLoader when instantiating coprocessor instances.  This custom ClassLoader would always attempt to load classes from the coprocessor's jar first and would only delegate to the parent ClassLoader if the class were not found in the coprocessor jar.  However, certain classes would need to be exempt from this behavior.  As an example, if the Copcoessor interface were loaded by both the region server's ClassLoader and the coprocessor's custom ClassLoader, then the region server would get a ClassCastException when attempting to cast the coprocessor instance to the Coprocessor interface.  This problem can be avoided by defining a set of class name prefixes that would be exempt from loading by the custom ClassLoader.  When loading a class, if the class starts with any of these prefixes (e.g. "org.apache.hadoop"), then the ClassLoader would delegate immediately to the parent ClassLoader.
> I've already implemented a patch to provide this functionality which I'll attach shortly.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (HBASE-6308) Coprocessors should be loaded in a custom ClassLoader to prevent dependency conflicts with HBase

Posted by "James Baldassari (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HBASE-6308?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

James Baldassari updated HBASE-6308:
------------------------------------

    Status: Patch Available  (was: Open)
    
> Coprocessors should be loaded in a custom ClassLoader to prevent dependency conflicts with HBase
> ------------------------------------------------------------------------------------------------
>
>                 Key: HBASE-6308
>                 URL: https://issues.apache.org/jira/browse/HBASE-6308
>             Project: HBase
>          Issue Type: Improvement
>          Components: coprocessors
>    Affects Versions: 0.94.0, 0.92.1
>            Reporter: James Baldassari
>         Attachments: HBASE-6308-0.92.patch, HBASE-6308-trunk.patch
>
>
> Currently each coprocessor is loaded with a URLClassLoader that puts the coprocessor's jar at the beginning of the classpath.  The URLClassLoader always tries to load classes from the parent ClassLoader first and only attempts to load from its own configured URLs if the class was not found by the parent.  This class loading behavior can be problematic for coprocessors that have common dependencies with HBase but whose versions are incompatible.  For example, I have a coprocessor that depends on a different version of Avro than the version used by HBase.  The current class loading behavior results in NoSuchMethodErrors in my coprocessor because some Avro classes have already been loaded by HBase, and the ClassLoader for my coprocessor picks up HBase's loaded classes first.
> My proposed solution to this problem is to use a custom ClassLoader when instantiating coprocessor instances.  This custom ClassLoader would always attempt to load classes from the coprocessor's jar first and would only delegate to the parent ClassLoader if the class were not found in the coprocessor jar.  However, certain classes would need to be exempt from this behavior.  As an example, if the Copcoessor interface were loaded by both the region server's ClassLoader and the coprocessor's custom ClassLoader, then the region server would get a ClassCastException when attempting to cast the coprocessor instance to the Coprocessor interface.  This problem can be avoided by defining a set of class name prefixes that would be exempt from loading by the custom ClassLoader.  When loading a class, if the class starts with any of these prefixes (e.g. "org.apache.hadoop"), then the ClassLoader would delegate immediately to the parent ClassLoader.
> I've already implemented a patch to provide this functionality which I'll attach shortly.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (HBASE-6308) Coprocessors should be loaded in a custom ClassLoader to prevent dependency conflicts with HBase

Posted by "James Baldassari (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HBASE-6308?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

James Baldassari updated HBASE-6308:
------------------------------------

    Attachment: HBASE-6308-trunk.patch
                HBASE-6308-0.92.patch

Here's the patch with versions for trunk and the 0.92 branch.  I've successfully tested these changes on a test cluster.  I no longer see any NoSuchMethodErrors or other ClassLoader problems in my coprocessor.  I'm not sure if there is an easy way to unit test this change, but if anyone has any ideas I'll try to find some time to work on it.
                
> Coprocessors should be loaded in a custom ClassLoader to prevent dependency conflicts with HBase
> ------------------------------------------------------------------------------------------------
>
>                 Key: HBASE-6308
>                 URL: https://issues.apache.org/jira/browse/HBASE-6308
>             Project: HBase
>          Issue Type: Improvement
>          Components: coprocessors
>    Affects Versions: 0.92.1, 0.94.0
>            Reporter: James Baldassari
>         Attachments: HBASE-6308-0.92.patch, HBASE-6308-trunk.patch
>
>
> Currently each coprocessor is loaded with a URLClassLoader that puts the coprocessor's jar at the beginning of the classpath.  The URLClassLoader always tries to load classes from the parent ClassLoader first and only attempts to load from its own configured URLs if the class was not found by the parent.  This class loading behavior can be problematic for coprocessors that have common dependencies with HBase but whose versions are incompatible.  For example, I have a coprocessor that depends on a different version of Avro than the version used by HBase.  The current class loading behavior results in NoSuchMethodErrors in my coprocessor because some Avro classes have already been loaded by HBase, and the ClassLoader for my coprocessor picks up HBase's loaded classes first.
> My proposed solution to this problem is to use a custom ClassLoader when instantiating coprocessor instances.  This custom ClassLoader would always attempt to load classes from the coprocessor's jar first and would only delegate to the parent ClassLoader if the class were not found in the coprocessor jar.  However, certain classes would need to be exempt from this behavior.  As an example, if the Copcoessor interface were loaded by both the region server's ClassLoader and the coprocessor's custom ClassLoader, then the region server would get a ClassCastException when attempting to cast the coprocessor instance to the Coprocessor interface.  This problem can be avoided by defining a set of class name prefixes that would be exempt from loading by the custom ClassLoader.  When loading a class, if the class starts with any of these prefixes (e.g. "org.apache.hadoop"), then the ClassLoader would delegate immediately to the parent ClassLoader.
> I've already implemented a patch to provide this functionality which I'll attach shortly.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (HBASE-6308) Coprocessors should be loaded in a custom ClassLoader to prevent dependency conflicts with HBase

Posted by "Hudson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-6308?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13433535#comment-13433535 ] 

Hudson commented on HBASE-6308:
-------------------------------

Integrated in HBase-TRUNK #3214 (See [https://builds.apache.org/job/HBase-TRUNK/3214/])
    HBASE-6308. Coprocessors should be loaded in a custom ClassLoader (James Baldassari) (Revision 1372558)

     Result = FAILURE
apurtell : 
Files : 
* /hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/CoprocessorClassLoader.java
* /hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/CoprocessorHost.java
* /hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestClassLoading.java

                
> Coprocessors should be loaded in a custom ClassLoader to prevent dependency conflicts with HBase
> ------------------------------------------------------------------------------------------------
>
>                 Key: HBASE-6308
>                 URL: https://issues.apache.org/jira/browse/HBASE-6308
>             Project: HBase
>          Issue Type: Improvement
>          Components: coprocessors
>    Affects Versions: 0.92.1, 0.94.0
>            Reporter: James Baldassari
>            Assignee: Andrew Purtell
>             Fix For: 0.92.2, 0.96.0, 0.94.2
>
>         Attachments: 6308-v2.txt, HBASE-6308-0.92.patch, HBASE-6308-0.92-with-test.patch, HBASE-6308-0.94-with-test.patch, HBASE-6308-trunk.patch, HBASE-6308-trunk-with-test.patch
>
>
> Currently each coprocessor is loaded with a URLClassLoader that puts the coprocessor's jar at the beginning of the classpath.  The URLClassLoader always tries to load classes from the parent ClassLoader first and only attempts to load from its own configured URLs if the class was not found by the parent.  This class loading behavior can be problematic for coprocessors that have common dependencies with HBase but whose versions are incompatible.  For example, I have a coprocessor that depends on a different version of Avro than the version used by HBase.  The current class loading behavior results in NoSuchMethodErrors in my coprocessor because some Avro classes have already been loaded by HBase, and the ClassLoader for my coprocessor picks up HBase's loaded classes first.
> My proposed solution to this problem is to use a custom ClassLoader when instantiating coprocessor instances.  This custom ClassLoader would always attempt to load classes from the coprocessor's jar first and would only delegate to the parent ClassLoader if the class were not found in the coprocessor jar.  However, certain classes would need to be exempt from this behavior.  As an example, if the Copcoessor interface were loaded by both the region server's ClassLoader and the coprocessor's custom ClassLoader, then the region server would get a ClassCastException when attempting to cast the coprocessor instance to the Coprocessor interface.  This problem can be avoided by defining a set of class name prefixes that would be exempt from loading by the custom ClassLoader.  When loading a class, if the class starts with any of these prefixes (e.g. "org.apache.hadoop"), then the ClassLoader would delegate immediately to the parent ClassLoader.
> I've already implemented a patch to provide this functionality which I'll attach shortly.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (HBASE-6308) Coprocessors should be loaded in a custom ClassLoader to prevent dependency conflicts with HBase

Posted by "Andrew Purtell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-6308?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13407552#comment-13407552 ] 

Andrew Purtell commented on HBASE-6308:
---------------------------------------

No issues found running this patch on a secure cluster using AccessController and TokenProvider.
                
> Coprocessors should be loaded in a custom ClassLoader to prevent dependency conflicts with HBase
> ------------------------------------------------------------------------------------------------
>
>                 Key: HBASE-6308
>                 URL: https://issues.apache.org/jira/browse/HBASE-6308
>             Project: HBase
>          Issue Type: Improvement
>          Components: coprocessors
>    Affects Versions: 0.92.1, 0.94.0
>            Reporter: James Baldassari
>         Attachments: HBASE-6308-0.92.patch, HBASE-6308-trunk.patch
>
>
> Currently each coprocessor is loaded with a URLClassLoader that puts the coprocessor's jar at the beginning of the classpath.  The URLClassLoader always tries to load classes from the parent ClassLoader first and only attempts to load from its own configured URLs if the class was not found by the parent.  This class loading behavior can be problematic for coprocessors that have common dependencies with HBase but whose versions are incompatible.  For example, I have a coprocessor that depends on a different version of Avro than the version used by HBase.  The current class loading behavior results in NoSuchMethodErrors in my coprocessor because some Avro classes have already been loaded by HBase, and the ClassLoader for my coprocessor picks up HBase's loaded classes first.
> My proposed solution to this problem is to use a custom ClassLoader when instantiating coprocessor instances.  This custom ClassLoader would always attempt to load classes from the coprocessor's jar first and would only delegate to the parent ClassLoader if the class were not found in the coprocessor jar.  However, certain classes would need to be exempt from this behavior.  As an example, if the Copcoessor interface were loaded by both the region server's ClassLoader and the coprocessor's custom ClassLoader, then the region server would get a ClassCastException when attempting to cast the coprocessor instance to the Coprocessor interface.  This problem can be avoided by defining a set of class name prefixes that would be exempt from loading by the custom ClassLoader.  When loading a class, if the class starts with any of these prefixes (e.g. "org.apache.hadoop"), then the ClassLoader would delegate immediately to the parent ClassLoader.
> I've already implemented a patch to provide this functionality which I'll attach shortly.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (HBASE-6308) Coprocessors should be loaded in a custom ClassLoader to prevent dependency conflicts with HBase

Posted by "Zhihong Ted Yu (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HBASE-6308?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Zhihong Ted Yu updated HBASE-6308:
----------------------------------

    Status: Open  (was: Patch Available)
    
> Coprocessors should be loaded in a custom ClassLoader to prevent dependency conflicts with HBase
> ------------------------------------------------------------------------------------------------
>
>                 Key: HBASE-6308
>                 URL: https://issues.apache.org/jira/browse/HBASE-6308
>             Project: HBase
>          Issue Type: Improvement
>          Components: coprocessors
>    Affects Versions: 0.94.0, 0.92.1
>            Reporter: James Baldassari
>         Attachments: HBASE-6308-0.92.patch, HBASE-6308-trunk.patch
>
>
> Currently each coprocessor is loaded with a URLClassLoader that puts the coprocessor's jar at the beginning of the classpath.  The URLClassLoader always tries to load classes from the parent ClassLoader first and only attempts to load from its own configured URLs if the class was not found by the parent.  This class loading behavior can be problematic for coprocessors that have common dependencies with HBase but whose versions are incompatible.  For example, I have a coprocessor that depends on a different version of Avro than the version used by HBase.  The current class loading behavior results in NoSuchMethodErrors in my coprocessor because some Avro classes have already been loaded by HBase, and the ClassLoader for my coprocessor picks up HBase's loaded classes first.
> My proposed solution to this problem is to use a custom ClassLoader when instantiating coprocessor instances.  This custom ClassLoader would always attempt to load classes from the coprocessor's jar first and would only delegate to the parent ClassLoader if the class were not found in the coprocessor jar.  However, certain classes would need to be exempt from this behavior.  As an example, if the Copcoessor interface were loaded by both the region server's ClassLoader and the coprocessor's custom ClassLoader, then the region server would get a ClassCastException when attempting to cast the coprocessor instance to the Coprocessor interface.  This problem can be avoided by defining a set of class name prefixes that would be exempt from loading by the custom ClassLoader.  When loading a class, if the class starts with any of these prefixes (e.g. "org.apache.hadoop"), then the ClassLoader would delegate immediately to the parent ClassLoader.
> I've already implemented a patch to provide this functionality which I'll attach shortly.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (HBASE-6308) Coprocessors should be loaded in a custom ClassLoader to prevent dependency conflicts with HBase

Posted by "Zhihong Ted Yu (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HBASE-6308?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Zhihong Ted Yu updated HBASE-6308:
----------------------------------

    Attachment: 6308-v2.txt

Patch v2 removes year from header of CoprocessorClassLoader.java
                
> Coprocessors should be loaded in a custom ClassLoader to prevent dependency conflicts with HBase
> ------------------------------------------------------------------------------------------------
>
>                 Key: HBASE-6308
>                 URL: https://issues.apache.org/jira/browse/HBASE-6308
>             Project: HBase
>          Issue Type: Improvement
>          Components: coprocessors
>    Affects Versions: 0.92.1, 0.94.0
>            Reporter: James Baldassari
>             Fix For: 0.96.0
>
>         Attachments: 6308-v2.txt, HBASE-6308-0.92.patch, HBASE-6308-trunk.patch
>
>
> Currently each coprocessor is loaded with a URLClassLoader that puts the coprocessor's jar at the beginning of the classpath.  The URLClassLoader always tries to load classes from the parent ClassLoader first and only attempts to load from its own configured URLs if the class was not found by the parent.  This class loading behavior can be problematic for coprocessors that have common dependencies with HBase but whose versions are incompatible.  For example, I have a coprocessor that depends on a different version of Avro than the version used by HBase.  The current class loading behavior results in NoSuchMethodErrors in my coprocessor because some Avro classes have already been loaded by HBase, and the ClassLoader for my coprocessor picks up HBase's loaded classes first.
> My proposed solution to this problem is to use a custom ClassLoader when instantiating coprocessor instances.  This custom ClassLoader would always attempt to load classes from the coprocessor's jar first and would only delegate to the parent ClassLoader if the class were not found in the coprocessor jar.  However, certain classes would need to be exempt from this behavior.  As an example, if the Copcoessor interface were loaded by both the region server's ClassLoader and the coprocessor's custom ClassLoader, then the region server would get a ClassCastException when attempting to cast the coprocessor instance to the Coprocessor interface.  This problem can be avoided by defining a set of class name prefixes that would be exempt from loading by the custom ClassLoader.  When loading a class, if the class starts with any of these prefixes (e.g. "org.apache.hadoop"), then the ClassLoader would delegate immediately to the parent ClassLoader.
> I've already implemented a patch to provide this functionality which I'll attach shortly.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira