4

我们有一些与Java,VB. 中Joss 4.X,我们习惯放在 Application Server 下的 bin 目录下。

我们迁移到JBOSS 7.1.1当我从 bin 目录中删除并将它们放在 .lib 下的库文件夹中时C:\jboss-as-7.1.1.Final\modules\com\correction\main\libraries

我得到了这个例外

java.lang.UnsatisfiedLinkError: no xxxJavaWrapper in java.library.path
java.library.path = C:\Program Files\Java\jdk1.6.0_24\bin;.;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\apache-maven-3.0.4;C:\apache-maven-3.0.4\bin;C:\Python27;C:\Program Files\Java\jdk1.6.0_24;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem
java.lang.UnsatisfiedLinkError: com.xxxJavaWrapperJNI.new_xxx()J

模块.xml

<?xml version="1.0" encoding="UTF-8"?>
    <module xmlns="urn:jboss:module:1.0" name="com.correction">
        <resources>
            <resource-root path="xxx.jar"/>
            <resource-root path="xyz.jar"/>
            <resource-root path="libraries"/>
        </resources>
        <dependencies>
            <system export="true">
                <paths>
                    <path name="libraries"/>
                </paths>
                <exports>
                    <include-set>
                        <path name="libraries"/>
                    </include-set>
                </exports>
            </system>
        </dependencies>
    </module>

但是我将相同的dll放在bin文件夹中,它工作正常。我想将它们放在模块文件夹中并从那里设置路径而不是 bin,以便我可以将所有与应用程序相关的 jar、属性和 dll 文件放在一个地方,以便于维护。

另外我想知道如何在 jboss 7.1.1 中设置 txt 和属性文件的路径

问候斯里尼

4

1 回答 1

5

Configure module.xml as below:

<module xmlns="urn:jboss:module:1.1" name="com.correction">
    <resources>
        <resource-root path="xxx.jar"/>
        <resource-root path="xyz.jar"/>
        <resource-root path="lib/win-x86_64"/>
    </resources>

   <dependencies>
       <module name="sun.jdk"/>
    </dependencies>
</module>

Put the DLLs into the directory lib/win-x86_64. Check the another dependencies of your project.

In WEB-INF of your application creating the file jboss-deployment-structure.xml and put the content below:

<jboss-deployment-structure>
  <deployment>
     <dependencies>
        <module name="com.correction"/>
     </dependencies>
  </deployment>
</jboss-deployment-structure>

That's all.

Another Question: How can you make these properties files accessible to applications deployed on JBoss 7?

create a custom module where you put your properties files and put jboss-deployment-structure.xml to your application archive (WAR/EAR) to use that custom module.

Create the new module directory under $JBOSS_HOME/modules(using app/conf in this example)

mkdir -p $JBOSS_HOME/modules/app/conf/main/properties/

Put your properties files in $JBOSS_HOME/modules/app/conf/main/properties/

Create a module.xmlhere $JBOSS_HOME/modules/app/conf/main/module.xml

<module xmlns="urn:jboss:module:1.1" name="app.conf">
   <resources>
      <resource-root path="properties"/>
   </resources>
</module>

put the following jboss-deployment-structure.xml in WEB-INF:

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
   <deployment>
      <dependencies>
            <module name="app.conf" />
   </dependencies>
   </deployment>
</jboss-deployment-structure>

Then you can access your properties files using thecode below (example assumes you have a example.propertiesfile in $JBOSS_HOME/modules/app/conf/main/properties/)

Thread.currentThread().getContextClassLoader().getResource("example.properties");

Ps: I used JBoss AS 7.1.2 ( JBoss EAP 6 )

Regards Mauricio Magnani

于 2012-10-09T04:36:29.283 回答