How to set SysProperites.USER_HOME in Tomcat?

151 views
Skip to first unread message

Thomas Mauch

unread,
Mar 22, 2010, 4:15:30 PM3/22/10
to H2 Database
I deploy the H2 database with my web application which all works fine.
I would also like to deploy the H2 console for easy management, but I
have the problem that my home directory is not accessible from the web
application due to the security policy in use. So I get the following
error:

java.security.AccessControlException: access denied
(java.io.FilePermission /webs/web1179/.h2.server.properties read)

java.security.AccessControlContext.checkPermission(AccessControlContext.java:
323)
java.security.AccessController.checkPermission(AccessController.java:
546)
java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
java.lang.SecurityManager.checkRead(SecurityManager.java:871)
java.io.File.exists(File.java:731)
org.h2.store.fs.FileSystemDisk.exists(FileSystemDisk.java:134)
org.h2.util.FileUtils.exists(FileUtils.java:132)
org.h2.util.SortedProperties.loadProperties(SortedProperties.java:87)
org.h2.server.web.WebServer.loadProperties(WebServer.java:510)
org.h2.server.web.WebServer.init(WebServer.java:223)
org.h2.server.web.WebServlet.init(WebServlet.java:53)
javax.servlet.GenericServlet.init(GenericServlet.java:212)

After having looked at the source code, I understand that I must
somehow set to SysProperites.USER_HOME to a directory accessible from
my web application. I also understand that in a non web application, I
simply could pass "-Duser.home=/mydir" to the application, but is
there a way to achieve the same for a web application running in
Tomcat?

Thanks,
Thomas

Kerry Sainsbury

unread,
Mar 22, 2010, 4:26:47 PM3/22/10
to h2-da...@googlegroups.com
A Tomcat mailing list is probably a better source of answers, but Google told me this pretty quickly: http://stackoverflow.com/questions/372686/how-can-i-specify-system-properties-in-tomcat-configuration-on-startup

... it sounds good to me -- especially the last option at the bottom of the page.


--
You received this message because you are subscribed to the Google Groups "H2 Database" group.
To post to this group, send email to h2-da...@googlegroups.com.
To unsubscribe from this group, send email to h2-database...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/h2-database?hl=en.


Thomas Kellerer

unread,
Mar 22, 2010, 5:06:48 PM3/22/10
to H2 Database
You have two easy options:

Create a global environment variable named JAVA_OPTS and the contents
"-Duser.home=/path/to/your/home/dir"

or create a script setenv.bat (or setenv.sh) in $CATALINA_HOME/bin
that contains the above environment variable.

Thomas

Thomas Mauch

unread,
Mar 22, 2010, 5:58:23 PM3/22/10
to H2 Database
Thanks for your reply.
So I tried to add something like

<env-entry>
<env-entry-name>user.home</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>d:\config</env-entry-value>
</env-entry>

to my web.xml file, but System.getProperty("user.home") still returned
the old value.
Do you have any experience with that?


On 22 Mrz., 21:26, Kerry Sainsbury <ke...@fidelma.com> wrote:
> A Tomcat mailing list is probably a better source of answers, but Google

> told me this pretty quickly:http://stackoverflow.com/questions/372686/how-can-i-specify-system-pr...


>
> ... it sounds good to me -- especially the last option at the bottom of the
> page.
>

> > h2-database...@googlegroups.com<h2-database%2Bunsu...@googlegroups.com>

Thomas Mauch

unread,
Mar 22, 2010, 6:00:00 PM3/22/10
to H2 Database
Sorry, I forgot to mention that Tomcat is provided by my ISP and I do
not have the possibility to change theses.
So I was looking for a way to change this on the level of the web
application or on the level of H2.

On 22 Mrz., 22:06, Thomas Kellerer <google-gro...@sql-workbench.net>
wrote:

Kerry Sainsbury

unread,
Mar 22, 2010, 7:04:42 PM3/22/10
to h2-da...@googlegroups.com
I suggested that you look at "the last option at the bottom of the page". I still suggest that :-)


To unsubscribe from this group, send email to h2-database...@googlegroups.com.

Thomas Mueller

unread,
Mar 23, 2010, 1:42:13 PM3/23/10
to h2-da...@googlegroups.com
Hi,

I guess H2 should ignore the exception when trying to load load / safe
this properties file if it's not accessible. I will implement this.

Regards,
Thomas

Thomas Mauch

unread,
Mar 26, 2010, 10:17:40 AM3/26/10
to H2 Database
And yes it worked.
Thanks!


On 23 Mrz., 00:04, Kerry Sainsbury <ke...@fidelma.com> wrote:
> I suggested that you look at "the last option at the bottom of the page". I
> still suggest that :-)
>

> > <h2-database%2Bunsu...@googlegroups.com<h2-database%252Buns...@googlegroups.com>

Thomas Mauch

unread,
Mar 26, 2010, 10:18:34 AM3/26/10
to H2 Database
Agreed.
Thanks for your effort.

On 23 Mrz., 18:42, Thomas Mueller <thomas.tom.muel...@gmail.com>
wrote:

Reply all
Reply to author
Forward
0 new messages