JBoss wildfly 8.x 提供程序“vfs"使用 java nio Paths 时未安装 [英] JBoss wildfly 8.x Provider "vfs" not installed when using java nio Paths

查看:30
本文介绍了JBoss wildfly 8.x 提供程序“vfs"使用 java nio Paths 时未安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将我的 spring 应用程序从 glassfish 4 导出到 JBoss wildfly 8.x 或 9 alpha,但是当我的应用程序在我的代码的某些部分启动时抛出异常:

I'm trying to export my spring application from glassfish 4 to JBoss wildfly 8.x or 9 alpha, but when my application starts in some part of my code throws the exception:

Caused by: java.lang.RuntimeException: java.nio.file.FileSystemNotFoundException: Provider "vfs" not installed
    at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:218)
    at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:87)
    at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.start(UndertowDeploymentService.java:72)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
    ... 3 more
Caused by: java.nio.file.FileSystemNotFoundException: Provider "vfs" not installed
    at java.nio.file.Paths.get(Paths.java:147) [rt.jar:1.7.0_72]
    at com.springmvcangular.backend.utils.entity.BaseEntityInitializer.extendsEntities(BaseEntityInitializer.java:123)
    at com.springmvcangular.backend.utils.entity.BaseEntityInitializer.initializeBaseEntities(BaseEntityInitializer.java:88)
    at com.springmvcangular.backend.config.ApplicationInitializer.onStartup(ApplicationInitializer.java:60)
    at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:175)
    at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:178)
    ... 7 more

在我的班级 BaseEntityInitializer 中,我有:

in my class BaseEntityInitializer in that exception line i have:

packagepath = Paths.get(this.getClass().getClassLoader()
                            .getResource(path.replace('.', '/')).toURI());

where path 它是一个像 com.something.model 这样的包路径,那么为什么在我的 glassfish 4 服务器中它可以完美运行,而我需要在 Wildfly 中使用它呢?我不知道wildfly 缺少什么,或者我是否需要包含一些库.

where path its a package path like com.something.model, so why in my glassfish 4 server this works perfectly and what i need for use it in wildfly? i don't know what is missing in wildfly or if i need to include some library.

推荐答案

它碰巧在 GlassFish 中起作用.ClassLoader 合同(或 Java EE 平台规范)中没有任何地方指定您返回的 URL 类型.在 GlassFish ClasLoder 中,它可能恰好是一个 jar://file:// URL,恰好有一个 FileSystemProvider (jar:// 只是偶然 BTW).在 WildFly 中,URL 恰好是一个 JBoss VFS URL.您可以应用各种技巧来使其暂时工作,但它们都无法掩盖您依赖不可移植行为的事实.你最好使用类似 URL#openStream() 的东西,而不是它是可移植的,因此应该可以在任何地方工作.

It happens to work by chance in GlassFish. Nowhere in the ClassLoader contract (or the Java EE platform specification) is it specified what kind of URL you get back. In the GlassFish ClasLoder it probably happens to be a jar:// or file:// URL for which there happens to be a FileSystemProvider (jar:// only by accident BTW). In WildFly the URL happens to be a JBoss VFS URL. There are various hacks that you can apply to make it work for now but they all can't hide the fact that you're relying on not portable behavior. You're better off using something like URL#openStream() instead which is portable and should therefore work everywhere.

更新

您可以尝试做的是在编译时做更多的事情.选项包括:

What you can try to do is doing more at compile time. Options include:

  • 在编译时使用 Javassist 进行转换.这也减少了 Javassist 与 WildFly 发布冲突的可能性.
  • 在编译时收集有关资源的信息,并将其存储在已知位置的文件中.您可以在多个 JAR 中使用相同的文件名,因为 ClassLoader#getResources(String) 可以返回多个结果.
  • Do the transformation with Javassist at compile time. This also reduces the chances of conflicts with the Javassist shipping with WildFly.
  • Gather the information about the resources at compile time and store it in a file at a well known location. You can have the same file name in multiple JARs as ClassLoader#getResources(String) can return multiple results.

如果您提供有关您要解决的问题的更具体的信息,我可能会给出更具体的答案.

If you provide more specific information about the problem you're trying to solve I may be able to give more specific answers.

这篇关于JBoss wildfly 8.x 提供程序“vfs"使用 java nio Paths 时未安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆