简体   繁体   English

将文件从WEB-INF / wsdl / Schemas / Messages /目录加载到jboss eap 6.4中的类路径

[英]Load files from WEB-INF/wsdl/Schemas/Messages/ directory to class path in jboss eap 6.4

I am migrating my application from jboss eap 5.1 to 6.4. 我正在将我的应用程序从jboss eap 5.1迁移到6.4。 There are some xsd files I have kept in WEB-INF/wsdl/Schemas/Messages/ folder. 我在WEB-INF/wsdl/Schemas/Messages/文件夹中保留了一些xsd文件。 and in my code I am trying to retrieve the file using following logic: 在我的代码中,我尝试使用以下逻辑来检索文件:

this.getClass().getClassLoader().getResource("/../wsdl/Schemas/Messages/MsgSearchDetails.xsd").

In jboss eap 5.1 it works fine but in 6.4 I am not able to get the file on this path. 在jboss eap 5.1中,它可以正常工作,但在6.4中,我无法在此路径上获取文件。 I know that jboss eap 6.4 loads file from WEB-INF/classes and WEB_INF/lib directory in classpath. 我知道jboss eap 6.4从WEB-INF/classes路径中的WEB-INF/classesWEB_INF/lib目录加载文件。

So how can I read xsd files from WEB-INF/wsdl/Schemas/Messages/ folder in jboss eap 6.4? 那么,如何从jboss eap 6.4中的WEB-INF/wsdl/Schemas/Messages/文件夹中读取xsd文件?

You can add all xsd files in a module folder in JBOSS_HOME/modules/system/layers/base/your-module/main and define a module.xml here like this: 您可以将所有xsd文件添加到JBOSS_HOME/modules/system/layers/base/your-module/main的module文件夹中,并在此处定义module.xml,如下所示:

<?xml version="1.0" encoding="UTF-8"?>
 <module xmlns="urn:jboss:module:1.1" name="your-module">
 <resources>
<!-- Modules -->
<resource-root path="."/>
</resources>
</module>

Add this module as a dependency to your WAR in a jboss-deployment-structure.xml and get it like this then: jboss-deployment-structure.xml将此模块作为对WAR的依赖项添加,然后按以下方式获取它:

Thread.currentThread().getContextClassLoader().getResourceAsStream("MsgSearchDetails.xsd") Thread.currentThread()。getContextClassLoader()。getResourceAsStream(“ MsgSearchDetails.xsd”)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM