org.reflections.Reflections - 无法使用url中的jarFile创建Dir

时间:2018-06-06 08:57:50

标签: java nullpointerexception google-reflections

我使用Reflections'lib扫描我传入args的包到我的方法中,以便创建它包含的所有类的实例列表:

private List<Condition> createAllConditions(String packageName) {
    List<Condition> conditions = Lists.newArrayList();
    //Reflections reflections = new Reflections(packageName);
    Reflections reflections = new Reflections(new ConfigurationBuilder().setUrls(ClasspathHelper.forPackage(packageName)).useParallelExecutor();
    Set<Class<? extends Condition>> allClasses = reflections.getSubTypesOf(Condition.class);
    for (Class conditionClass : allClasses) {
        try {
            Class<?> clazz = Class.forName(conditionClass.getName());
            conditions.add((Condition) clazz.getConstructor().newInstance());
        } catch (Exception ex) {
            log.error("Exception", ex);
        }
    }
    return conditions;
}

当我看到日志时,我收到此警告:

2018/06/06 10:04:19.449 [WebContainer : 3] [] [INFO ] org.reflections.Reflections - Reflections took 112 ms to scan 38 urls, producing 0 keys and 0 values 
2018/06/06 10:04:19.546 [WebContainer : 3] [] [WARN ] org.reflections.Reflections - could not create Dir using jarFile from url file:/wasintg/produits/websphere/8.5.5.10.64b/lib/jsf-nls.jar. skipping.
java.lang.NullPointerException: null
    at java.util.zip.ZipFile.<init>(ZipFile.java:223)
    at java.util.zip.ZipFile.<init>(ZipFile.java:165)
    at java.util.jar.JarFile.<init>(JarFile.java:179)
    at java.util.jar.JarFile.<init>(JarFile.java:143)
    at org.reflections.vfs.Vfs$DefaultUrlTypes$1.createDir(Vfs.java:216)
    at org.reflections.vfs.Vfs.fromURL(Vfs.java:99)
    at org.reflections.vfs.Vfs.fromURL(Vfs.java:91)
    at org.reflections.Reflections.scan(Reflections.java:240)
    at org.reflections.Reflections.scan(Reflections.java:202)
    at org.reflections.Reflections.<init>(Reflections.java:123)
    at org.reflections.Reflections.<init>(Reflections.java:168)
    at org.reflections.Reflections.<init>(Reflections.java:141)
    at fr.all.d.d.business.transco.TranscoService.createAllConditions(TranscoService.java:267)
    at fr.all.d.d.business.transco.TranscoService.getAllMvtDetail(TranscoService.java:208)
    at fr.all.d.d.business.transco.TranscoService.lambda$extractCSouscMovement$3(TranscoService.java:168)
    at fr.all.d.d.business.transco.TranscoService$$Lambda$728.000000003605B0F0.accept(Unknown Source)
    at java.util.Optional.ifPresent(Optional.java:170)
    at fr.all.d.d.business.transco.TranscoService.extractCSouscMovement(TranscoService.java:165)
    at fr.all.d.d.business.transco.TranscoService.extractDocumentProperties(TranscoService.java:139)
    at fr.all.d.d.business.transco.TranscoService.createDomFlux(TranscoService.java:540)
    at fr.all.d.d.business.ws.client.dom.ondemand.DomOnDemandDocumentService.callWsOnDemandDocument(DomOnDemandDocumentService.java:65)
    at fr.all.d.d.web.rest.DomController.generatePdf(DomController.java:73)

但是NullPointerException阻止了我的代码的执行和实例的创建!

0 个答案:

没有答案