Hi there, After running XWiki fine in my local server, I'm trying to run it on my hosting provider. Acces to WebHome yelds the error: javax.servlet.ServletException: Error number 3 in 0: Could not initialize main XWiki context Wrapped Exception: access denied (java.io.FilePermission /WEB-INF/xwiki.cfg read) I tried changing web.xml to <env-entry> <env-entry-name>XWikiConfig</env-entry-name> <!-- <env-entry-value>/WEB-INF/xwiki.cfg</env-entry-value> --> <env-entry-value>/virtual/lozano.eti.br/www/xwiki/WEB-INF/xwiki.cfg</env -entry-value> <env-entry-type>java.lang.String</env-entry-type> </env-entry> That is, I tried cofiguring the real phisical path to the xwiki.cfg file, But still get the same error. My ISP tells me Xwiki is trying to get /WEB-INF/xwiki.cfg as an absolute file system path, not as a context-relative path, and it looks like changing the <env-entry> has no effect. What should I do? []s, Fernando Lozano
On Thursday 26 July 2007 17:06, Fernando Lozano wrote:
Hi there,
After running XWiki fine in my local server, I'm trying to run it on my hosting provider. Acces to WebHome yelds the error:
javax.servlet.ServletException: Error number 3 in 0: Could not initialize main XWiki context Wrapped Exception: access denied (java.io.FilePermission /WEB-INF/xwiki.cfg read)
What should I do?
I suspect your host is on a *nix server. Have a look at the file permissions and make sure that it is readable. I suggest the following: chmod 664 xwiki.cfg ...when in the WEB-INF directory of course. -- Brian D. Switzer --> herkamur [at] canada [dot] com trains: http://railphotos.herkamur.ca/ ships: http://www.herkamur.ca/canal/
Hi Fernando, This is indeed a bug. Here's what we do: InputStream xwikicfgis = null; // first try to load the file pointed by the given path // if it does not exist, look for it relative to the classpath File f = new File(xwikicfg); if (f.exists()) { xwikicfgis = new FileInputStream(f); } else { xwikicfgis = econtext.getResourceAsStream (xwikicfg); ... The pb is that f.exists() will return true and new FileInputStream will throw an exception and thus the else will not get executed. I have opened an issue: http://jira.xwiki.org/jira/browse/XWIKI-1539 Thanks -Vincent On Jul 26, 2007, at 11:06 PM, Fernando Lozano wrote:
Hi there,
After running XWiki fine in my local server, I'm trying to run it on my hosting provider. Acces to WebHome yelds the error:
javax.servlet.ServletException: Error number 3 in 0: Could not initialize main XWiki context Wrapped Exception: access denied (java.io.FilePermission /WEB-INF/ xwiki.cfg read)
I tried changing web.xml to
<env-entry> <env-entry-name>XWikiConfig</env-entry-name> <!-- <env-entry-value>/WEB-INF/xwiki.cfg</env-entry-value> --> <env-entry-value>/virtual/lozano.eti.br/www/xwiki/WEB-INF/ xwiki.cfg</env -entry-value> <env-entry-type>java.lang.String</env-entry-type> </env-entry>
That is, I tried cofiguring the real phisical path to the xwiki.cfg file, But still get the same error.
My ISP tells me Xwiki is trying to get /WEB-INF/xwiki.cfg as an absolute file system path, not as a context-relative path, and it looks like changing the <env- entry> has no effect.
What should I do?
[]s, Fernando Lozano
<fernando.lozano.vcf>
-- You receive this message as a subscriber of the xwiki- [email protected] mailing list. To unsubscribe: mailto:[email protected] For general help: mailto:[email protected]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/ wws
Hi Vincent, This happens in just a single source line? Or is this coding idiom used in other parts of Xwiki? Because if it's a single source (or half a dozen source files) I'll gladly patch, recompile, test and submit the fix to the community. :-) []s, Fernando Lozano
Hi Fernando,
This is indeed a bug. Here's what we do:
� � �� �� �� �� �� �InputStream xwikicfgis = null;
� � � � � � � � � � // first try to load the file pointed by the given path � � � � � � � � � � // if it does not exist, look for it relative to the classpath � � � � � � � � � � File f = new File(xwikicfg); � � � � � � � � � � if (f.exists()) { � � � � � � � � � � � � xwikicfgis = new FileInputStream(f); � � � � � � � � � � } else { � � � � � � � � � � � � xwikicfgis = econtext.getResourceAsStream(xwikicfg); ...
The pb is that f.exists() will return true and new FileInputStream will throw an exception and thus the else will not get executed.
I have opened an issue:�http://jira.xwiki.org/jira/browse/XWIKI-1539
Thanks -Vincent
On Jul 26, 2007, at 11:06 PM, Fernando Lozano wrote: Hi there,
After running XWiki fine in my local server, I'm trying to run it on my hosting provider. Acces to WebHome yelds the error:
javax.servlet.ServletException: Error number 3 in 0: Could not initialize main XWiki context Wrapped Exception: access denied (java.io.FilePermission /WEB-INF/xwiki.cfg read)
I tried changing web.xml to
<env-entry> � � � � <env-entry-name>XWikiConfig</env-entry-name> � � � � <!-- � � � � <env-entry-value>/WEB-INF/xwiki.cfg</env-entry-value> � � � � --> � � � � <env-entry-value>/virtual/lozano.eti.br/www/xwiki/WEB-INF/xwiki.cfg</env -entry-value> � � � � <env-entry-type>java.lang.String</env-entry-type> � � </env-entry>
That is, I tried cofiguring the real phisical path to the xwiki.cfg file, But still get the same error.
My ISP tells me Xwiki is trying to get /WEB-INF/xwiki.cfg as an absolute file system path, not as a context-relative path, and it looks like changing the <env-entry> has no effect.
What should I do?
[]s, Fernando Lozano
<fernando.lozano.vcf>
-- You receive this message as a subscriber of the [email protected] mailing list. To unsubscribe: mailto:[email protected] For general help: mailto:[email protected]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
------------------------------------------------- Fernando Lozano -- Arquiteto de Soluções Neki Group ***** http://www.neki.com.br "Muito além da Tecnologia" Rio de Janeiro: (21) 2220-2222 r:232 e 231 Petrópolis: (24) 2242-5689 [email protected] -------------------------------------------------
Hi Fernando, On Jul 28, 2007, at 12:02 AM, fernando.lozano wrote:
Hi Vincent,
This happens in just a single source line? Or is this coding idiom used in other parts of Xwiki? Because if it's a single source (or half a dozen source files) I'll gladly patch, recompile, test and submit the fix to the community. :-)
We don't read that man files. I haven't checked but we should check how we read the hibernate.cfg.xml file too. Thanks for your welcome help, that would be great! Thanks -Vincent
[]s, Fernando Lozano
Hi Fernando,
This is indeed a bug. Here's what we do:
� � �� �� �� �� �� �InputStream xwikicfgis = null;
� � � � � � � � � � // first try to load the file pointed by the given path � � � � � � � � � � // if it does not exist, look for it relative to the classpath � � � � � � � � � � File f = new File(xwikicfg); � � � � � � � � � � if (f.exists()) { � � � � � � � � � � � � xwikicfgis = new FileInputStream(f); � � � � � � � � � � } else { � � � � � � � � � � � � xwikicfgis = econtext.getResourceAsStream(xwikicfg); ...
The pb is that f.exists() will return true and new FileInputStream will throw an exception and thus the else will not get executed.
I have opened an issue:�http://jira.xwiki.org/jira/browse/ XWIKI-1539
Thanks -Vincent
On Jul 26, 2007, at 11:06 PM, Fernando Lozano wrote:
Hi there,
After running XWiki fine in my local server, I'm trying to run it on my hosting provider. Acces to WebHome yelds the error:
javax.servlet.ServletException: Error number 3 in 0: Could not initialize main XWiki context Wrapped Exception: access denied (java.io.FilePermission /WEB- INF/xwiki.cfg read)
I tried changing web.xml to
<env-entry> � � � � <env-entry-name>XWikiConfig</env-entry-name> � � � � <!-- � � � � <env-entry-value>/WEB-INF/xwiki.cfg</env-entry- value> � � � � --> � � � � <env-entry-value>/virtual/lozano.eti.br/www/xwiki/ WEB-INF/xwiki.cfg</env -entry-value> � � � � <env-entry-type>java.lang.String</env-entry-type> � � </env-entry>
That is, I tried cofiguring the real phisical path to the xwiki.cfg file, But still get the same error.
My ISP tells me Xwiki is trying to get /WEB-INF/xwiki.cfg as an absolute file system path, not as a context-relative path, and it looks like changing the <env-entry> has no effect.
What should I do?
[]s, Fernando Lozano
<fernando.lozano.vcf>
-- You receive this message as a subscriber of the xwiki- [email protected] mailing list. To unsubscribe: mailto:[email protected] For general help: mailto:[email protected]?subject=help ObjectWeb mailing lists service home page: http:// www.objectweb.org/wws
------------------------------------------------- Fernando Lozano -- Arquiteto de Soluções Neki Group ***** http://www.neki.com.br "Muito além da Tecnologia" Rio de Janeiro: (21) 2220-2222 r:232 e 231 Petrópolis: (24) 2242-5689 [email protected] -------------------------------------------------
-- You receive this message as a subscriber of the xwiki- [email protected] mailing list. To unsubscribe: mailto:[email protected] For general help: mailto:[email protected]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/ wws
Hi Vincent, hibernare.cfg.xml should not be read directly by XWiki, but by the framework itself, using the classloader (Class.getResourceAsStream). []s, Fernando Lozano
We don't read that man files. I haven't checked but we should check how we read the hibernate.cfg.xml file too.
Thanks for your welcome help, that would be great!
Thanks -Vincent
Hi Vincent, Just checking if I missed something obvious. Shouldn't XWiki call call File.canRead() instead of File.exists()? Actually, by reading the Java SE API docs it looks like canRead() will throw the same Security Exception, so the solution would be to catch it. But it's kinda nonsense to have a method that should return false if I can't read a file and this method instead throws an exception. When I start my patching excercise, should I use either XWiki 1.0 sources or 1.1? For me, 1,1 should be almost production-ready to be viable, but I could restrict myself to only 1.0 features. []s, Fernando Lozano
Hi Fernando,
This is indeed a bug. Here's what we do:
InputStream xwikicfgis = null;
// first try to load the file pointed by the given path // if it does not exist, look for it relative to the classpath File f = new File(xwikicfg); if (f.exists()) { xwikicfgis = new FileInputStream(f); } else { xwikicfgis = econtext.getResourceAsStream(xwikicfg); ...
The pb is that f.exists() will return true and new FileInputStream will throw an exception and thus the else will not get executed.
I have opened an issue: http://jira.xwiki.org/jira/browse/XWIKI-1539
Thanks -Vincent
On Jul 26, 2007, at 11:06 PM, Fernando Lozano wrote:
Hi there,
After running XWiki fine in my local server, I'm trying to run it on my hosting provider. Acces to WebHome yelds the error:
javax.servlet.ServletException: Error number 3 in 0: Could not initialize main XWiki context Wrapped Exception: access denied (java.io.FilePermission /WEB-INF/xwiki.cfg read)
I tried changing web.xml <http://web.xml> to
<env-entry> <env-entry-name>XWikiConfig</env-entry-name> <!-- <env-entry-value>/WEB-INF/xwiki.cfg</env-entry-value> -->
<env-entry-value>/virtual/lozano.eti.br/www/xwiki/WEB-INF/xwiki.cfg</env -entry-value> <env-entry-type>java.lang.String</env-entry-type> </env-entry>
That is, I tried cofiguring the real phisical path to the xwiki.cfg file, But still get the same error.
My ISP tells me Xwiki is trying to get /WEB-INF/xwiki.cfg as an absolute file system path, not as a context-relative path, and it looks like changing the <env-entry> has no effect.
What should I do?
[]s, Fernando Lozano
<fernando.lozano.vcf>
-- You receive this message as a subscriber of the [email protected] <mailto:[email protected]> mailing list. To unsubscribe: mailto:[email protected] For general help: mailto:[email protected]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Hi Vincent, This is a proposal for what could be the correct idiom for XWiki regarding its configuration files. I understand XWiki wants to giver the option of specifing both filesystem absolute path and context relative paths for configuration files. I started by creating the following JSP page, which re-creates the error I get from XWiki: ------------------- readCfg.jsp ------------------ <%@ page import="java.io.*, java.lang.*, java.util.*, java.net.*, org.apache.log4j.*" %> <HTML> <% String xwikicfg = "/WEB-INF/xwiki.cfg"; InputStream xwikicfgis = null; // first try to load the file pointed by the given path // if it does not exist, look for it relative to the classpath File f = new File(xwikicfg); if (f.exists()) { out.println("<h1>Read from filesystem</h1>"); xwikicfgis = new FileInputStream(f); } else { out.println("<h1>Read as web resource</h1>"); xwikicfgis = getServletContext().getResourceAsStream(xwikicfg); } BufferedReader is = new BufferedReader(new InputStreamReader( xwikicfgis)); %> <pre> <% String linha = is.readLine(); while (linha != null) { out.println(linha); linha = is.readLine(); } is.close(); %> </pre> </HTML> -------------------------------------- I get the expected result: javax.servlet.ServletException: Error number 3 in 0: Could not initialize main XWiki context Wrapped Exception: access denied (java.io.FilePermission \WEB-INF\xwiki.cfg read) If I change "f.existsIO" with "f.canRead()" I get the same exception. But if I change the order, that is, try first a context-relative path and only later a filesystem absolute path, it works in my hosting provider. Please note that I'm not reading "relative to the classpath" as stated by Vicent. Neither is XWiki, if the code snipset he provided is correct. So here's my code: ------------------- readCfg2.jsp ------------------ <%@ page import="java.io.*, java.lang.*, java.util.*, java.net.*, org.apache.log4j.*" %> <HTML> <% String xwikicfg = "/WEB-INF/xwiki.cfg"; InputStream xwikicfgis = null; xwikicfgis = getServletContext().getResourceAsStream(xwikicfg); File f = new File(xwikicfg); if (xwikicfgis != null) { out.println("<h1>Read as web resource</h1>"); } else if (f.canRead()) { out.println("<h1>Read from filesystem</h1>"); xwikicfgis = new FileInputStream(f); } else { // this won't be run if there's a SecurityException throw new ServletException("Can't open " + xwikicfg); } BufferedReader is = new BufferedReader(new InputStreamReader( xwikicfgis)); %> <pre> <% String linha = is.readLine(); while (linha != null) { out.println(linha); linha = is.readLine(); } is.close(); %> </pre> </HTML> ------------------------------------------------ Now it runs fine. []s, Fernando Lozano
Hi Fernando,
This is indeed a bug. Here's what we do:
InputStream xwikicfgis = null;
// first try to load the file pointed by the given path // if it does not exist, look for it relative to the classpath File f = new File(xwikicfg); if (f.exists()) { xwikicfgis = new FileInputStream(f); } else { xwikicfgis = econtext.getResourceAsStream(xwikicfg); ...
The pb is that f.exists() will return true and new FileInputStream will throw an exception and thus the else will not get executed.
I have opened an issue: http://jira.xwiki.org/jira/browse/XWIKI-1539
Thanks -Vincent
participants (4)
-
Brian D. Switzer -
Fernando Lozano -
fernando.lozano -
Vincent Massol