Google对Websphere的反思 - 无法打开网址连接

时间:2015-04-23 07:40:48

标签: java websphere websphere-liberty google-reflections

我正在开展一个项目,我正在使用谷歌思考并在websphere liberty profile上部署项目。

我的项目有以下代码,Transformer.class是依赖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 个答案:

答案 0 :(得分:1)

  

无法从网址创建Vfs.Dir,找不到匹配的UrlType   [wsjar的:文件:

看起来Reflection似乎增加了对wsjar的支持:URL自2013年以来一直没有发布。

https://code.google.com/p/reflections/issues/detail?id=158 https://code.google.com/p/reflections/downloads/list

你需要补丁。