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

Path with Dots causes Error #46

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a Path with a Folder which starts with a Dot (.tomcat)
2. pass as URL to Reflections-API
3. Try to search for something

What is the expected output? What do you see instead?
It should find my annotated classes. (works in a normal path)

What version of the product are you using? On what operating system?
0.9.5.rc1

Please provide any additional information below.

Code-Snippet:

<snip>
    public void contextInitialized(ServletContextEvent event) {
        try {
            List<URL> urls = 
ClasspathHelper.getUrlsForCurrentClasspath();
            for (URL url : urls) {
                System.out.println("URL: " + url);
            }
            //D:/Workspace/Prototyp-
Taskforce/forge/.metadata/.me_tcat/webapps/push/WEB-INF/classes/
            urls = Arrays.asList(new 
URL("file:/D:/Workspace/Prototyp-
Taskforce/forge/.metadata/.me_tcat/webapps/push/WEB-INF/classes/"));
            Reflections reflections = new Reflections(new 
ConfigurationBuilder()
                .setScanners(new TypeAnnotationsScanner())
                .setUrls(urls)
                .setExecutorServiceSupplier(new 
Supplier<ExecutorService>() {
                    public ExecutorService get() {
                        return 
Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
                    }
                }));
            Set<Class<?>> clazzez = 
reflections.getTypesAnnotatedWith(ConfigurationInitializer.class);
            for (Class<?> clazz : clazzez) {
                System.out.println("Found: " + 
clazz.getName());
                Object instance = clazz.newInstance();

((ProcessorConfigurationInitializer)instance).initialize();             
            }
        }catch (Exception e) {
            e.printStackTrace();
        }
    }
</snip>

<stacktrace>
org.reflections.ReflectionsException: could not create Dir from url, no 
matching UrlType was found [file:/D:/Workspace/Prototyp-
Taskforce/forge/.metadata/.me_tcat/webapps/push/WEB-INF/classes/]
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:79)
    at org.reflections.vfs.Vfs.fromURL(Vfs.java:64)
    at org.reflections.Reflections.scan(Reflections.java:132)
    at org.reflections.Reflections.<init>(Reflections.java:89)
    at 
com.saperion.components.configuration.web.AnnotationScanner.contextInitiali
zed(AnnotationScanner.java:42)
    at 
org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java
:3827)
    at 
org.apache.catalina.core.StandardContext.start(StandardContext.java:4334)
    at 
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:
791)
    at 
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
    at 
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
    at 
org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920)
    at 
org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:88
3)
    at 
org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
    at 
org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
    at 
org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
    at 
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSuppo
rt.java:117)
    at 
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
    at 
org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
    at 
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    at 
org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
    at 
org.apache.catalina.core.StandardService.start(StandardService.java:516)
    at 
org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:566)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:3
9)
    at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImp
l.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
</stacktrace>

Original issue reported on code.google.com by daniel.m...@googlemail.com on 5 Apr 2010 at 6:43

GoogleCodeExporter commented 9 years ago
Tested the Code in a Java Application -> Works
Using this Code in a Servlet Filter -> Fail

Original comment by daniel.m...@googlemail.com on 5 Apr 2010 at 8:45

GoogleCodeExporter commented 9 years ago
Using the latest version in trunk worked.

Original comment by daniel.m...@googlemail.com on 5 Apr 2010 at 9:43

GoogleCodeExporter commented 9 years ago

Original comment by ronm...@gmail.com on 17 May 2010 at 4:21