Index: xwiki-core/src/main/java/com/xpn/xwiki/web/JsxAction.java =================================================================== --- xwiki-core/src/main/java/com/xpn/xwiki/web/JsxAction.java (revision 18291) +++ xwiki-core/src/main/java/com/xpn/xwiki/web/JsxAction.java (working copy) @@ -62,8 +62,8 @@ if (context.getRequest().getParameter("resource") != null) { sxSource = new SxResourceSource(context.getRequest().getParameter("resource")); - } - + } + else { if (context.getDoc().isNew()) { context.getResponse().setStatus(HttpServletResponse.SC_NOT_FOUND); @@ -71,8 +71,13 @@ } sxSource = new SxDocumentSource(context, sxType); } - - super.renderExtension(sxSource, sxType, context); + + try { + super.renderExtension(sxSource, sxType, context); + } catch (NullPointerException e) { + context.getResponse().setStatus(HttpServletResponse.SC_NOT_FOUND); + return "docdoesnotexist"; + } return null; } Index: xwiki-core/src/main/java/com/xpn/xwiki/web/SsxAction.java =================================================================== --- xwiki-core/src/main/java/com/xpn/xwiki/web/SsxAction.java (revision 18291) +++ xwiki-core/src/main/java/com/xpn/xwiki/web/SsxAction.java (working copy) @@ -56,8 +56,8 @@ @Override public String render(XWikiContext context) throws XWikiException { - - SxSource sxSource; + + SxSource sxSource; Extension sxType = new CssExtension(); @@ -73,7 +73,13 @@ sxSource = new SxDocumentSource(context, sxType); } - super.renderExtension(sxSource, sxType, context); + + try { + super.renderExtension(sxSource, sxType, context); + } catch (NullPointerException e) { + context.getResponse().setStatus(HttpServletResponse.SC_NOT_FOUND); + return "docdoesnotexist"; + } return null; } Index: xwiki-core/src/main/java/com/xpn/xwiki/web/sx/SxResourceSource.java =================================================================== --- xwiki-core/src/main/java/com/xpn/xwiki/web/sx/SxResourceSource.java (revision 18291) +++ xwiki-core/src/main/java/com/xpn/xwiki/web/sx/SxResourceSource.java (working copy) @@ -68,6 +68,8 @@ try { InputStream in = this.getClass().getResourceAsStream("/" + this.resourceName); return IOUtils.toString(in); + } catch (NullPointerException e) { + throw e; } catch (IOException e) { return ""; }