Domanda

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.

È stato utile?

Soluzione

I have found the following solution, which might not be elegant, but works for me. Using System.getProperties() I have got a loads of properties. The one keys that were interesting for me were: "jboss.server.data.dir" and "${project.artifactId}${project.version}" (the 2nd one gives you an absolute path to the deployed app).

Hope it helps somebody.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top