0

We are moving one web app from Tomcat 7.0 to Jboss 7.1. In this web app there is a possibility to upload documents by the users. These documents can be then downloaded or deleted by the users as well.

The documents have been stored within the web application (this is a requirement, so we cannot store the documents in a DB or in another folder outside of the app on the web container).

When using Tomcat I could have done smth. like the following in java code to get an existing absolute path to the directory where the files were stored:

    String catalinaHome = "";
    String dataPath = "";

    try {
        if (System.getenv("CATALINA_HOME") != null) {
            catalinaHome = System.getenv("CATALINA_HOME");
        } else if (System.getProperty("catalina.base") != null) {
            catalinaHome = System.getProperty("catalina.base");
        }

        dataPath = catalinaHome + "/webappsdata/" + APP_NAME + UPLOADED_FILES;

How can I achieve the same or similar goal when we I now use Jboss 7.1 instead of Tomcat?

Using smth. like System.getProperty("JBOSS_HOME") didn't work for me.

Thanx a lot in advance.

4

1 回答 1

0

我找到了以下解决方案,它可能并不优雅,但对我有用。使用System.getProperties()我有很多属性。我感兴趣的一个键是:“jboss.server.data.dir”“${project.artifactId}${project.version}”(第二个为您提供了已部署应用程序的绝对路径)。

希望它可以帮助某人。

于 2014-03-27T11:47:15.757 回答