cailin186 / reflections

Automatically exported from code.google.com/p/reflections
Do What The F*ck You Want To Public License
0 stars 0 forks source link

cannot use dir null #148

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Error:
cannot use dir null
 at org.reflections.vfs.SystemDir.<init>(SystemDir.java:20)
 at org.reflections.vfs.Vfs$DefaultUrlTypes$3.createDir(Vfs.java:237)
 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:231)
 at org.reflections.Reflections.scan(Reflections.java:204)
 at org.reflections.Reflections.<init>(Reflections.java:129)

Code:
            List<ClassLoader> classLoadersList = new LinkedList<ClassLoader>();
            classLoadersList.add(ClasspathHelper.contextClassLoader());
            classLoadersList.add(ClasspathHelper.staticClassLoader());

            FilterBuilder filter = new FilterBuilder();
            filter.include(FilterBuilder.prefix("com.business"));
            filter.exclude(FilterBuilder.prefix("com.business.utils.file.BemaSign"));

            ConfigurationBuilder conf = new ConfigurationBuilder();
            conf.setScanners(new SubTypesScanner(false), new ResourcesScanner());
            conf.setUrls(ClasspathHelper.forClassLoader(classLoadersList.toArray(new ClassLoader[0])));
            conf.filterInputsBy(filter);

            Reflections reflections = new Reflections(conf);//error here

the error occurs in Glassfish 3.1.2.2 on OS: CentoOS 6.3

Original issue reported on code.google.com by rodrigo....@gmail.com on 12 Jun 2013 at 12:06

GoogleCodeExporter commented 9 years ago
This is be caused by the classpath containing a filing system directory that 
does not exist. This seems to be quite common, as I've seen it on a Mac and on 
a linux server.

I worked around it by adding a UrlType ahead of the existing ones which returns 
a Dir handler for an empty directory.

See 
https://github.com/OpenGamma/OG-Platform/commit/164df45373e9e5ebbd343c878d8b1349
63ccf877

The correct fix in Reflections would be to not complain about null/not existing 
at the start of SystemDir, and just return an empty iterator.

Original comment by jodastep...@gmail.com on 13 Jul 2013 at 3:47

GoogleCodeExporter commented 9 years ago
I am facing this same issue while trying to use

reflection.getSubTypesOf(com.google.protobuf.GeneratedMessage.class)

it fails with this stack trace:

[main] ERROR org.reflections.Reflections - could not create Vfs.Dir from url. 
ignoring the exception and continuing
org.reflections.ReflectionsException: could not create Vfs.Dir from url, no 
matching UrlType was found 
[file:/Users/DD025968/Documents/kepler-util-OneMore/kepler-util/kepler-console/2
]
either use fromURL(final URL url, final List<UrlType> urlTypes) or use the 
static setDefaultURLTypes(final List<UrlType> urlTypes) or 
addDefaultURLTypes(UrlType urlType) with your specialized UrlType.
    at org.reflections.vfs.Vfs.fromURL(Vfs.java:108)
    at org.reflections.vfs.Vfs.fromURL(Vfs.java:90)
    at org.reflections.Reflections.scan(Reflections.java:165)
    at org.reflections.Reflections.<init>(Reflections.java:94)
    at com.abc.kepler.console.util.KeplerTableUtil.addUrlsToRef(KeplerTableUtil.java:995)
    at com.abc.kepler.console.util.KeplerTableUtil.findSubclasses(KeplerTableUtil.java:935)
    at com.abc.kepler.console.util.KeplerTableUtil.displaySerializers(KeplerTableUtil.java:796)
    at com.abc.kepler.console.util.KeplerTableUtil.handleWildcardEntry(KeplerTableUtil.java:1018)
    at com.abc.kepler.console.util.KeplerTableUtil.queryClassName(KeplerTableUtil.java:589)
    at com.abc.kepler.console.CreateKeplerTable.createTableInteractively(CreateKeplerTable.java:301)
    at com.abc.kepler.console.CreateKeplerTable.run(CreateKeplerTable.java:198)
    at com.abc.kepler.commands.Command.run(Command.java:112)
    at com.abc.kepler.console.CreateKeplerTableTest.simplifiedCreateKeplerTableCommandTest_KEPLER1583(CreateKeplerTableTest.java:1407)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
    at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55)
    at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:48)
    at org.junit.rules.RunRules.evaluate(RunRules.java:20)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:249)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:142)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:113)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
    at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
    at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:104)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
[main] INFO  org.reflections.Reflections - Reflections took 39 ms to scan 2 
urls, producing 35 keys and 172 values 
Could not find any associated serializers. 
Please provide one or more jars enclosing serializers, separated by 
commas>2013-08-13 12:05:44,233 [main] WARN  org.reflections.Reflections - could 
not create Dir using directory from url 
file:/Users/DD025968/Documents/kepler-util-OneMore/kepler-util/kepler-console/n.
 skipping.
java.lang.RuntimeException: cannot use dir null
    at org.reflections.vfs.SystemDir.<init>(SystemDir.java:20)
    at org.reflections.vfs.Vfs$DefaultUrlTypes$3.createDir(Vfs.java:229)
    at org.reflections.vfs.Vfs.fromURL(Vfs.java:98)
    at org.reflections.vfs.Vfs.fromURL(Vfs.java:90)
    at org.reflections.Reflections.scan(Reflections.java:165)
    at org.reflections.Reflections.<init>(Reflections.java:94)
    at com.abc.kepler.console.util.KeplerTableUtil.addUrlsToRef(KeplerTableUtil.java:995)
    at com.abc.kepler.console.util.KeplerTableUtil.findSubclasses(KeplerTableUtil.java:935)
    at com.abc.kepler.console.util.KeplerTableUtil.displaySerializers(KeplerTableUtil.java:796)
    at com.abc.kepler.console.util.KeplerTableUtil.displaySerializers(KeplerTableUtil.java:802)
    at com.abc.kepler.console.util.KeplerTableUtil.handleWildcardEntry(KeplerTableUtil.java:1018)
    at com.abc.kepler.console.util.KeplerTableUtil.queryClassName(KeplerTableUtil.java:589)
    at com.abc.kepler.console.CreateKeplerTable.createTableInteractively(CreateKeplerTable.java:301)
    at com.abc.kepler.console.CreateKeplerTable.run(CreateKeplerTable.java:198)
    at com.abc.kepler.commands.Command.run(Command.java:112)
    at com.abc.kepler.console.CreateKeplerTableTest.simplifiedCreateKeplerTableCommandTest_KEPLER1583(CreateKeplerTableTest.java:1407)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
    at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55)
    at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:48)
    at org.junit.rules.RunRules.evaluate(RunRules.java:20)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:249)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:142)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:113)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
    at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
    at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:104)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)

Is there a work-around on the client side? also, when is this expected to be 
fixed in a reflections release?

Original comment by desai.di...@gmail.com on 13 Aug 2013 at 5:43

GoogleCodeExporter commented 9 years ago
I forgot to mention earlier: 
I am on a mac and using reflections-0.9.8

Original comment by desai.di...@gmail.com on 13 Aug 2013 at 5:45

GoogleCodeExporter commented 9 years ago

Original comment by ronm...@gmail.com on 21 Dec 2013 at 9:33