java.lang.reflect.InvocationTargetException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • Liquibase has some logic that deals with classloaders, but doesn't handle the case where Class.getClassLoader() returns null. From the Javadoc of getClassLoader(): "Some implementations may use null to represent the bootstrap class loader. This method will return null in such implementations if this class was loaded by the bootstrap class loader." Attached is a simple Maven project to reproduce the issue. Unzip it and run mvn clean package java -javaagent:target\testagent-1.0.jar Which in my case gives this result: {noformat} Running premain Classloader of premain: null Exception in thread "main" java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(Unknown Source) at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(Unknown Source) Caused by: java.lang.ExceptionInInitializerError at com.example.Premain.premain(Premain.java:13) ... 6 more Caused by: java.lang.NullPointerException at liquibase.servicelocator.WebSpherePackageScanClassResolver.isWebSphereClassLoader(WebSpherePackageScanClassResolver.java:30) at liquibase.servicelocator.ServiceLocator.defaultClassLoader(ServiceLocator.java:67) at liquibase.servicelocator.ServiceLocator.<init>(ServiceLocator.java:39) at liquibase.servicelocator.ServiceLocator.<clinit>(ServiceLocator.java:27) ... 7 more FATAL ERROR in native method: processing of -javaagent failed {noformat} WebSpherePackageScanClassResolver.isWebSphereClassLoader() is the first point of failure, but this becomes an issue elsewhere as well, for example in ClassLoaderResourceAccessor. Note: The example is based on a real case where Liquibase was executed from code that runs in a Java agent. Our current workaround is to load Liquibase in a custom classloader, but this makes the application a lot more complex.
    via by Andres Kalle,
  • Liquibase has some logic that deals with classloaders, but doesn't handle the case where Class.getClassLoader() returns null. From the Javadoc of getClassLoader(): "Some implementations may use null to represent the bootstrap class loader. This method will return null in such implementations if this class was loaded by the bootstrap class loader." Attached is a simple Maven project to reproduce the issue. Unzip it and run mvn clean package java -javaagent:target\testagent-1.0.jar Which in my case gives this result: {noformat} Running premain Classloader of premain: null Exception in thread "main" java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(Unknown Source) at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(Unknown Source) Caused by: java.lang.ExceptionInInitializerError at com.example.Premain.premain(Premain.java:13) ... 6 more Caused by: java.lang.NullPointerException at liquibase.servicelocator.WebSpherePackageScanClassResolver.isWebSphereClassLoader(WebSpherePackageScanClassResolver.java:30) at liquibase.servicelocator.ServiceLocator.defaultClassLoader(ServiceLocator.java:67) at liquibase.servicelocator.ServiceLocator.<init>(ServiceLocator.java:39) at liquibase.servicelocator.ServiceLocator.<clinit>(ServiceLocator.java:27) ... 7 more FATAL ERROR in native method: processing of -javaagent failed {noformat} WebSpherePackageScanClassResolver.isWebSphereClassLoader() is the first point of failure, but this becomes an issue elsewhere as well, for example in ClassLoaderResourceAccessor. Note: The example is based on a real case where Liquibase was executed from code that runs in a Java agent. Our current workaround is to load Liquibase in a custom classloader, but this makes the application a lot more complex.
    via by Andres Kalle,
    • java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(Unknown Source) at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(Unknown Source) Caused by: java.lang.ExceptionInInitializerError at com.example.Premain.premain(Premain.java:13) ... 6 more Caused by: java.lang.NullPointerException at liquibase.servicelocator.WebSpherePackageScanClassResolver.isWebSphereClassLoader(WebSpherePackageScanClassResolver.java:30) at liquibase.servicelocator.ServiceLocator.defaultClassLoader(ServiceLocator.java:67) at liquibase.servicelocator.ServiceLocator.<init>(ServiceLocator.java:39) at liquibase.servicelocator.ServiceLocator.<clinit>(ServiceLocator.java:27) ... 7 more
    No Bugmate found.