X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=src%2Fdolda%2Fjsvc%2Fj2ee%2FTomcatContext.java;h=db535505b9ca7f821d332a2ec8bc3c2bad8c24f2;hb=c39ae6d24864244eab704dea7307f769f2f2e9da;hp=5511820abd2ed6bfdc3cf024a3b96d4aa7ec579d;hpb=762009abaf3acc38003c9635115c721c602bdaa5;p=jsvc.git diff --git a/src/dolda/jsvc/j2ee/TomcatContext.java b/src/dolda/jsvc/j2ee/TomcatContext.java index 5511820..db53550 100644 --- a/src/dolda/jsvc/j2ee/TomcatContext.java +++ b/src/dolda/jsvc/j2ee/TomcatContext.java @@ -6,14 +6,17 @@ import javax.servlet.*; import java.lang.reflect.*; import java.util.*; import java.io.*; +import java.util.logging.*; public class TomcatContext extends J2eeContext { private final String name; + private static final Logger logger = Logger.getLogger("dolda.jsvc.context"); TomcatContext(ServletConfig sc) { super(sc); ServletContext ctx = j2eeconfig().getServletContext(); Class cclass = ctx.getClass(); + String name; try { Method cpm = cclass.getMethod("getContextPath"); name = Misc.stripslashes((String)cpm.invoke(ctx), true, true); @@ -23,7 +26,11 @@ public class TomcatContext extends J2eeContext { throw(new RuntimeException("Could not fetch context path from Tomcat", e)); } catch(InvocationTargetException e) { throw(new RuntimeException("Could not fetch context path from Tomcat", e)); + } catch(SecurityException e) { + logger.log(Level.WARNING, "no permissions to fetch context name from Tomcat", e); + name = null; } + this.name = name; readconfig(); } @@ -43,11 +50,24 @@ public class TomcatContext extends J2eeContext { } private void readconfig() { - String basename = System.getProperty("catalina.base"); - File base = new File(basename); - config.put("jsvc.storage", "file:" + new File(new File(base, "work"), "jsvc").getPath()); + File base; + try { + String basename = System.getProperty("catalina.base"); + base = new File(basename); + } catch(SecurityException e) { + logger.log(Level.WARNING, "no permissions to fetch Tomcat base directory while reading configuration", e); + return; + } + File sroot = new File(new File(base, "work"), "jsvc"); + if(name != null) + sroot = new File(sroot, name()); + sysconfig.put("jsvc.storage", "file:" + sroot.getPath()); File cdir = new File(base, "conf"); - loadprops(config, new File(cdir, "jsvc.properties")); + try { + loadprops(sysconfig, new File(cdir, "jsvc.properties")); + } catch(SecurityException e) { + logger.log(Level.WARNING, "no permssions to read from Tomcat conf directory while reading configuration", e); + } } public static boolean tomcatp(ServletConfig sc) {