有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

Websphere上的java Google反射无法打开url连接

我正在进行一个项目,我正在使用google Reflections并在websphere liberty profile上部署该项目

我的项目有以下代码:Transformer。类是依赖项jar中的位置

private void bindTransformers(SimpleRegistry initialContext) throws Exception {
    Reflections reflections = new Reflections("no.mypackage.ntrouter");
    final Set<Class<?>> transformerClasses = reflections.getTypesAnnotatedWith(Transformer.class);
    for (Class<?> aClass : transformerClasses) {
        initialContext.put(aClass.getSimpleName(), aClass.newInstance());
    }
}

但反射不起作用,出现以下错误:

2015-04-23 09:34:29,817 [ecutor-thread-5] WARN  Reflections                    - could not create Vfs.Dir from url. ignoring the exception and continuing
org.reflections.ReflectionsException: Could not open url connection
    at org.reflections.vfs.JarInputDir$1$1.<init>(JarInputDir.java:36)
    at org.reflections.vfs.JarInputDir$1.iterator(JarInputDir.java:32)
    at org.reflections.Reflections.scan(Reflections.java:231)
    at org.reflections.Reflections.scan(Reflections.java:204)
    at org.reflections.Reflections.<init>(Reflections.java:129)
    at org.reflections.Reflections.<init>(Reflections.java:170)
    at org.reflections.Reflections.<init>(Reflections.java:143)
    at no.norsktipping.ntrouter.chain.MyServletContextListener.bindTransformers(MyServletContextListener.java:56)
    at no.norsktipping.ntrouter.chain.MyServletContextListener.contextInitialized(MyServletContextListener.java:29)
    at com.ibm.ws.webcontainer.webapp.WebApp.notifyServletContextCreated(WebApp.java:2388)
    at com.ibm.ws.webcontainer.webapp.WebApp.initialize(WebApp.java:1048)
    at com.ibm.ws.webcontainer.webapp.WebApp.initialize(WebApp.java:6404)
    at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost.startWebApp(DynamicVirtualHost.java:446)
    at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost.createRunnableHandler(DynamicVirtualHost.java:248)
    at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost.createRunnableHandler(DynamicVirtualHost.java:313)
    at com.ibm.ws.http.internal.VirtualHostImpl.discriminate(VirtualHostImpl.java:241)
    at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink.ready(HttpDispatcherLink.java:306)
    at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:449)
    at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.handleNewRequest(HttpInboundLink.java:383)
    at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.processRequest(HttpInboundLink.java:283)
    at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.ready(HttpInboundLink.java:254)
    at com.ibm.ws.tcpchannel.internal.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:174)
    at com.ibm.ws.tcpchannel.internal.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:83)
    at com.ibm.ws.tcpchannel.internal.WorkQueueManager.requestComplete(WorkQueueManager.java:504)
    at com.ibm.ws.tcpchannel.internal.WorkQueueManager.attemptIO(WorkQueueManager.java:574)
    at com.ibm.ws.tcpchannel.internal.WorkQueueManager.workerRun(WorkQueueManager.java:929)
    at com.ibm.ws.tcpchannel.internal.WorkQueueManager$Worker.run(WorkQueueManager.java:1018)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)
Caused by: java.io.FileNotFoundException: JAR entry  not found in <address>/usr/servers/chainrouter/workarea/org.eclipse.osgi/56/data/cache/com.ibm.ws.app.manager_7/.cache/WEB-INF/lib/RouterUtils-1.0-SNAPSHOT.jar
    at com.ibm.ws.artifact.url.internal.WSJarURLStreamHandler$WSJarURLConnectionImpl.getInputStreamInternal(WSJarURLStreamHandler.java:283)
    at com.ibm.ws.artifact.url.internal.WSJarURLStreamHandler$WSJarURLConnectionImpl.getInputStream(WSJarURLStreamHandler.java:264)
    at org.reflections.vfs.JarInputDir$1$1.<init>(JarInputDir.java:35)
    ... 29 more
2015-04-23 09:34:29,826 [ecutor-thread-5] WARN  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 [wsjar:file:<address2>/ChainRouter/target/ChainRouter-1.0-SNAPSHOT.war!/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:109)
    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)

共 (1) 个答案