Attached is a message I sent a few weeks ago with a workaround I came up
with.

    Erik


----- Original Message -----
From: "Age Mooy" <[EMAIL PROTECTED]>
To: "Turbine-User" <[EMAIL PROTECTED]>
Sent: Monday, March 11, 2002 9:05 PM
Subject: Using ${applicationRoot} in Torque.properties (Torque-3.0-dev)


> Hi,
>
> I'm using turbine-2 with the decoupled Torque from the latest tdk snapshot
and I'm running into some problems
> with Hypersonic jdbc urls. In 2.1 apps I am a happy user of the
${applicationRoot} helper variable to keep my
> database urls relative, but that var is not the same in the decoupled
Torque.
>
> The Torque.properties file has the following line:
>
> torque.applicationRoot = .
>
> But at runtime that points to the tomcat/bin directory. The torque.log
file ends up in tomcat/bin/logs and all
> my database calls fail with Hypersonic IO errors because the database
can't be found. The url in
> Torque.properties is:
>
> jdbc:hsqldb:${applicationRoot}/WEB-INF/db/hsqldb-local
>
> With this behaviour I'm forced back to hardcoding the absolute path to the
database, which makes my apps
> harder to move.
>
> Is there any way to make Torque deal with this in a cleaner way ?
>
> Age
>
>
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
>
>
--- Begin Message ---
I saw a message in the archives that says you can use ${webappRoot} in the
JDBC URL to have it map to an absolute path at runtime for hsqldb.
<http://www.mail-archive.com/[email protected]/msg03720.html>

This did not work for me, and I don't see any strings "webappRoot" in the
Torque codebase.  Am I missing something?  Or is this feature no longer
available?  I hacked it this way though:

            Configuration c = (Configuration)new
PropertiesConfiguration(getServletContext().getRealPath("/WEB-INF/torque.pro
perties"));
            String url =
(String)c.getProperty("torque.database.default.url");
            int start = url.indexOf("$");
            int finish = url.indexOf("}") + 1;
            url = url.substring(0,start) +
getServletContext().getRealPath("/") + url.substring(finish);
            c.setProperty("torque.database.default.url", url);
            Torque.init(c);

Of course this is a quick and dirty thing, but it works for me.

    Erik



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>


--- End Message ---
--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to