java.lang.RuntimeException: java.lang.reflect.InvocationTargetException

Apache's JIRA Issue Tracker | Ratandeep Ratti | 1 year ago
  1. 0

    When we register a jar on the Hive console. Hive creates a fresh URL classloader which includes the path of the current jar to be registered and all the jar paths of the parent classloader. The parent classlaoder is the current ThreadContextClassLoader. Once the URLClassloader is created Hive sets that as the current ThreadContextClassloader. So if we register multiple jars in Hive, there will be multiple URLClassLoaders created, each classloader including the jars from its parent and the one extra jar to be registered. The last URLClassLoader created will end up as the current ThreadContextClassLoader. (See details: org.apache.hadoop.hive.ql.exec.Utilities#addToClassPath) Now here's an example in which the above strategy can lead to a CNF exception. We register 2 jars *j1* and *j2* in Hive console. *j1* contains the UDF class *c1* and internally relies on class *c2* in jar *j2*. We register *j1* first, the URLClassLoader *u1* is created and also set as the ThreadContextClassLoader. We register *j2* next, the new URLClassLoader created will be *u2* with *u1* as parent and *u2* becomes the new ThreadContextClassLoader. Note *u2* includes paths to both jars *j1* and *j2* whereas *u1* only has paths to *j1* (For details see: org.apache.hadoop.hive.ql.exec.Utilities#addToClassPath). Now when we register class *c1* under a temporary function in Hive, we load the class using {code} class.forName("c1", true, Thread.currentThread().getContextClassLoader()) {code} . The currentThreadContext class-loader is *u2*, and it has the path to the class *c1*, but note that Class-loaders work by delegating to parent class-loader first. In this case class *c1* will be found and *defined* by class-loader *u1*. Now *c1* from jar *j1* has *u1* as its class-loader. If a method (say initialize) is called in *c1*, which references the class *c2*, *c2* will not be found since the class-loader used to search for *c2* will be *u1* (Since the caller's class-loader is used to load a class) I've added a qtest to explain the problem. Please see the attached patch

    Apache's JIRA Issue Tracker | 1 year ago | Ratandeep Ratti
    java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
  2. 0

    When we register a jar on the Hive console. Hive creates a fresh URL classloader which includes the path of the current jar to be registered and all the jar paths of the parent classloader. The parent classlaoder is the current ThreadContextClassLoader. Once the URLClassloader is created Hive sets that as the current ThreadContextClassloader. So if we register multiple jars in Hive, there will be multiple URLClassLoaders created, each classloader including the jars from its parent and the one extra jar to be registered. The last URLClassLoader created will end up as the current ThreadContextClassLoader. (See details: org.apache.hadoop.hive.ql.exec.Utilities#addToClassPath) Now here's an example in which the above strategy can lead to a CNF exception. We register 2 jars *j1* and *j2* in Hive console. *j1* contains the UDF class *c1* and internally relies on class *c2* in jar *j2*. We register *j1* first, the URLClassLoader *u1* is created and also set as the ThreadContextClassLoader. We register *j2* next, the new URLClassLoader created will be *u2* with *u1* as parent and *u2* becomes the new ThreadContextClassLoader. Note *u2* includes paths to both jars *j1* and *j2* whereas *u1* only has paths to *j1* (For details see: org.apache.hadoop.hive.ql.exec.Utilities#addToClassPath). Now when we register class *c1* under a temporary function in Hive, we load the class using {code} class.forName("c1", true, Thread.currentThread().getContextClassLoader()) {code} . The currentThreadContext class-loader is *u2*, and it has the path to the class *c1*, but note that Class-loaders work by delegating to parent class-loader first. In this case class *c1* will be found and *defined* by class-loader *u1*. Now *c1* from jar *j1* has *u1* as its class-loader. If a method (say initialize) is called in *c1*, which references the class *c2*, *c2* will not be found since the class-loader used to search for *c2* will be *u1* (Since the caller's class-loader is used to load a class) I've added a qtest to explain the problem. Please see the attached patch

    Apache's JIRA Issue Tracker | 1 year ago | Ratandeep Ratti
    java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
  3. 0

    Java program that uses pptx4j throws org/apache/commons/lang/NotImplementedException

    Stack Overflow | 2 years ago
    java.lang.NoClassDefFoundError: org/apache/commons/lang/NotImplementedException
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    java.lang.NoClassDefFoundError: javax/el/PropertyNotFoundException

    Google Groups | 2 years ago | Lunen de Lange
    java.lang.ClassNotFoundException: javax.el.PropertyNotFoundException*
  6. 0

    Designing an API - troubles with class loading (Groovy)

    Stack Overflow | 4 months ago | Alexiy
    java.lang.reflect.InvocationTargetException

  1. andyglick 2 times, last 4 days ago
  2. richard77 1 times, last 1 week ago
  3. musketyr 2 times, last 1 week ago
  4. michallos 2 times, last 1 week ago
  5. batwalrus76 2 times, last 1 week ago
67 more registered users
28 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.lang.ClassNotFoundException

    TestClClassA

    at java.net.URLClassLoader$1.run()
  2. Java RT
    ClassLoader.loadClass
    1. java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    2. java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    3. java.security.AccessController.doPrivileged(Native Method)
    4. java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    5. java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    6. java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    6 frames
  3. Unknown
    TestClUDF1.<init>
    1. TestClUDF1.<init>(TestClUDF1.java:29)
    1 frame
  4. Java RT
    Constructor.newInstance
    1. sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    2. sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    3. sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    4. java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    4 frames
  5. Hadoop
    ReflectionUtils.newInstance
    1. org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:129)
    1 frame
  6. Hive Query Language
    Driver.run
    1. org.apache.hadoop.hive.ql.exec.Registry.registerGenericUDF(Registry.java:144)
    2. org.apache.hadoop.hive.ql.exec.Registry.registerFunction(Registry.java:105)
    3. org.apache.hadoop.hive.ql.exec.FunctionRegistry.registerTemporaryUDF(FunctionRegistry.java:1536)
    4. org.apache.hadoop.hive.ql.exec.FunctionTask.createTemporaryFunction(FunctionTask.java:166)
    5. org.apache.hadoop.hive.ql.exec.FunctionTask.execute(FunctionTask.java:72)
    6. org.apache.hadoop.hive.ql.exec.Task.executeTask(Task.java:160)
    7. org.apache.hadoop.hive.ql.exec.TaskRunner.runSequential(TaskRunner.java:89)
    8. org.apache.hadoop.hive.ql.Driver.launchTask(Driver.java:1747)
    9. org.apache.hadoop.hive.ql.Driver.execute(Driver.java:1506)
    10. org.apache.hadoop.hive.ql.Driver.runInternal(Driver.java:1263)
    11. org.apache.hadoop.hive.ql.Driver.run(Driver.java:1079)
    12. org.apache.hadoop.hive.ql.Driver.run(Driver.java:1069)
    12 frames
  7. org.apache.hadoop
    CliDriver.processLine
    1. org.apache.hadoop.hive.cli.CliDriver.processLocalCmd(CliDriver.java:213)
    2. org.apache.hadoop.hive.cli.CliDriver.processCmd(CliDriver.java:165)
    3. org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:376)
    4. org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:311)
    4 frames
  8. Hive Query Language
    QTestUtil.executeClient
    1. org.apache.hadoop.hive.ql.QTestUtil.executeClientInternal(QTestUtil.java:1033)
    2. org.apache.hadoop.hive.ql.QTestUtil.executeClient(QTestUtil.java:1007)
    2 frames
  9. org.apache.hadoop
    TestCliDriver.testCliDriver_test_classloader
    1. org.apache.hadoop.hive.cli.TestCliDriver.runTest(TestCliDriver.java:146)
    2. org.apache.hadoop.hive.cli.TestCliDriver.testCliDriver_test_classloader(TestCliDriver.java:130)
    2 frames
  10. Java RT
    Method.invoke
    1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    4. java.lang.reflect.Method.invoke(Method.java:606)
    4 frames
  11. JUnit
    JUnit38ClassRunner.run
    1. junit.framework.TestCase.runTest(TestCase.java:176)
    2. junit.framework.TestCase.runBare(TestCase.java:141)
    3. junit.framework.TestResult$1.protect(TestResult.java:122)
    4. junit.framework.TestResult.runProtected(TestResult.java:142)
    5. junit.framework.TestResult.run(TestResult.java:125)
    6. junit.framework.TestCase.run(TestCase.java:129)
    7. junit.framework.TestSuite.runTest(TestSuite.java:255)
    8. junit.framework.TestSuite.run(TestSuite.java:250)
    9. org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:84)
    9 frames
  12. JUnit4 Provider
    JUnit4Provider.invoke
    1. org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:264)
    2. org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
    3. org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:124)
    3 frames
  13. SureFire
    ForkedBooter.main
    1. org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200)
    2. org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153)
    3. org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
    3 frames