Skip to content

Commit

Permalink
JAX-RS Application classloader set as context classloader (#214)
Browse files Browse the repository at this point in the history
  • Loading branch information
vojtechhabarta committed Feb 2, 2018
1 parent 7d99973 commit d08d86e
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
public class JaxrsApplicationScanner {

public static List<SourceType<Type>> scanJaxrsApplication(Class<?> jaxrsApplicationClass, Predicate<String> isClassNameExcluded) {
final ClassLoader originalContextClassLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(jaxrsApplicationClass.getClassLoader());
System.out.println("Scanning JAX-RS application: " + jaxrsApplicationClass.getName());
final Constructor<?> constructor = jaxrsApplicationClass.getDeclaredConstructor();
constructor.setAccessible(true);
Expand All @@ -27,6 +29,8 @@ public static List<SourceType<Type>> scanJaxrsApplication(Class<?> jaxrsApplicat
return new JaxrsApplicationScanner().scanJaxrsApplication(jaxrsApplicationClass, resourceClasses, isClassNameExcluded);
} catch (ReflectiveOperationException e) {
throw reportError(e);
} finally {
Thread.currentThread().setContextClassLoader(originalContextClassLoader);
}
}

Expand Down

0 comments on commit d08d86e

Please sign in to comment.