-
1. Re: Replacement for context.xml in AS7? Access files outside the WAR?
cgaffga Jul 27, 2011 1:18 PM (in response to cgaffga)no I did a really ugly patch to JBossAS7, so far I can work with my old DirContext now.
This is not really a solution for me
diff --git a/web/src/main/java/org/jboss/as/web/deployment/WarDeploymentProcessor.java b/web/src/main/java/org/jboss/as/web/deployment/WarDeploym index fcc1165..6e015af 100644 --- a/web/src/main/java/org/jboss/as/web/deployment/WarDeploymentProcessor.java +++ b/web/src/main/java/org/jboss/as/web/deployment/WarDeploymentProcessor.java @@ -67,6 +67,7 @@ import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.logging.Logger; @@ -124,6 +125,11 @@ public class WarDeploymentProcessor implements DeploymentUnitProcessor { final StandardContext webContext = new StandardContext(); final ContextConfig config = new JBossContextConfig(deploymentUnit); + // TODO need a different DirContext for looking up resources... + Logger log = Logger.getLogger(WarDeploymentProcessor.class.getName()); + log.info("initialized a new StandardContext, registering customized resources..."); + webContext.setResources(new MyDirContextWrapper(webContext.getResources())); + List valves = metaData.getValves(); if(valves == null) { metaData.setValves(valves = new ArrayList());
-
2. Re: Replacement for context.xml in AS7? Access files outside the WAR?
guinotphil Aug 11, 2011 11:21 AM (in response to cgaffga)I'm looking for a replacement too...
I used to have in JBoss AS 4's server.xml some context like that :
<Context path="/static"
docBase="C:\static"
reloadable="false"
debug="0"
trusted="false"/>
I've seen that JBoss web 7 have a static resources configuration: http://docs.jboss.org/jbossweb/7.0.x/config/static.html
But I haven't managed to find where to configure aliases....
-
3. Re: Replacement for context.xml in AS7? Access files outside the WAR?
cgaffga Aug 12, 2011 6:09 AM (in response to guinotphil)guinotphil wrote:
I'm looking for a replacement too...
I used to have in JBoss AS 4's server.xml some context like that :
<Context path="/static" docBase="C:\static" reloadable="false" debug="0" trusted="false"/
I've seen that JBoss web 7 have a static resources configuration: http://docs.jboss.org/jbossweb/7.0.x/config/static.html
But I haven't managed to find where to configure aliases....
exactly that is my problem, too. Those things are described in JbossWeb 7 documentation, but they simplay are not cinfigurable. The issue is, that the JbossWeb7 ducumentation is simply a copy of the Tomcat6 docs, anthere there this is configurable. But if you check the sources in org.jboss.as.web, you will find that the configuration is done in a different way, neigther server.xml or context.xml is read.
I would be a great improvement if there would be some place to add custom context configuration like in Jboss4, 5, and 6, some place to add things theat before were stored in server.xml and context.xml.
Do you think people form Jboss-Dev-Team read this here? maybe we should forward it to the Dev list...
-
4. Re: Replacement for context.xml in AS7? Access files outside the WAR?
jaikiran Aug 16, 2011 12:02 AM (in response to cgaffga)The dev list is here https://lists.jboss.org/mailman/listinfo/jboss-as7-dev
-
5. Re: Replacement for context.xml in AS7? Access files outside the WAR?
guinotphil Aug 17, 2011 6:38 AM (in response to cgaffga)I've found something in JBoss Web 7 documentation:
It seems you can define context resources, see an example here:
http://docs.jboss.org/jbossweb/7.0.x/manager-howto.html
The documentation referer to a conf directory, that contains the default servlet configuration:
http://docs.jboss.org/jbossweb/7.0.x/default-servlet.html
The documentation refers to CATALINA_HOME:
http://docs.jboss.org/jbossweb/7.0.x/introduction.html
"Toughout the docs, you may notice references to $CATALINA_HOME. In JBossWeb 7.0.x that is where the webapp are deployed The default location in the Stanalone Server is configured by
jboss.server.temp.dir
normallyjboss.home.dir
/standalone/tmp."So, I'm not really sure where I should put this configuration in JBoss AS 7. Does anyone here has already configured the default servlet in AS 7 ? Thanks.
-
6. Re: Replacement for context.xml in AS7? Access files outside the WAR?
guinotphil Aug 24, 2011 11:37 AM (in response to cgaffga)Hello,
I've been investigating a bit the JBoss Web 7 documentation to understand how I could configure the web.xml, context.xml and server.xml.
The documentation says: http://docs.jboss.org/jbossweb/7.0.x/index.html
This is the top-level entry point of the documentation bundle for the JBoss Web Servlet/JSP container, which is based on the Apache Tomcat 6.0 project developed by the Apache Software Foundation.
And the JBoss Web 7 documention, as Tomcat 6's documentation, refers to conf/server.xml :
http://docs.jboss.org/jbossweb/7.0.x/jndi-resources-howto.html
For JBoss Web, these entries in per-web-application
InitialContext
are configured in the<Context>
elements that can be specified in either$CATALINA_HOME/conf/server.xml.
In my server, I notice the property catalina.home refers indeed to the standalone/tmp directory as stated in the documentation: http://docs.jboss.org/jbossweb/7.0.x/introduction.html
Throughout the docs, you may notice references to $CATALINA_HOME. In JBossWeb 7.0.x that is where the webapp are deployed The default location in the Stanalone Server is configured by
jboss.server.temp.dir
normallyjboss.home.dir
/standalone/tmp.However, I notice that, unlike Tomcat 6, in Jboss Web 7, in the class org.apache.catalina.startup.ContextConfig, the method init which created digesters and parsed the configuration with the method contextConfig() does no longer does that in JBoss Web 7.0.1. I guess JBoss AS expects to find the configuration elsewhere (standalone.xml probably), but where ? I must ask, as the documentation does not reflect the way JBoss Web seems to work...
Thank you
-
7. Re: Replacement for context.xml in AS7? Access files outside the WAR?
jfclere Sep 8, 2011 12:14 PM (in response to guinotphil)1 of 1 people found this helpfulThe jbossweb docs is being cleaned, reference to context.xml, server.xml etc are wrong.
The minimal you need is under http://docs.jboss.org/jbossweb/7.0.x/config
-
8. Re: Replacement for context.xml in AS7? Access files outside the WAR?
cgaffga Sep 8, 2011 3:58 PM (in response to jfclere)Jean-Frederic Clere wrote:
The jbossweb docs is being cleaned, reference to context.xml, server.xml etc are wrong.
The minimal you need is under http://docs.jboss.org/jbossweb/7.0.x/config
yes, just saw that the JBoss Web docs are quite reduced now. So it seems that all the nice config options from Tomcat are gone for JBoss. As I started the thread, I can only say, that me meanwhile solved the problem with only spec-compilant solutions. Was a good move anyway, instead to depend on vendor-specific enhancements and config options.
So all static rtesources we now handle with a "ExternalFilesServlet", that simply fetches the files needed. Everything else (facelets) we moved inside the WAR. But bad news for people that fetch their facelets, JSPs etc. from DB or some other non-filesystme source, then you still need to patch JBoss...
-
9. Re: Replacement for context.xml in AS7? Access files outside the WAR?
guinotphil Sep 9, 2011 4:11 AM (in response to cgaffga)Does this mean that it won't be possible to configure the Default Servlet anymore ?
-
11. Re: Replacement for context.xml in AS7? Access files outside the WAR?
jfclere Sep 9, 2011 5:36 AM (in response to guinotphil)for the mapping see http://docs.jboss.org/jbossweb/7.0.x/config/subsystem.html
-
12. Re: Replacement for context.xml in AS7? Access files outside the WAR?
guinotphil Dec 1, 2011 4:59 AM (in response to cgaffga)1 of 1 people found this helpfulI've ended up making my own servlet for this based on DefaultServlet:
/**
* Servlet to serve files from a static directory
*/
public class FileServingServlet extends DefaultServlet
{
public void init() throws ServletException {
super.init();
final Hashtable<String, Object> env = new Hashtable<String, Object>();
env.put(ProxyDirContext.HOST, resources.getHostName());
env.put(ProxyDirContext.CONTEXT, resources.getContextName());
final String docBaseProperty = getServletConfig().getInitParameter("docBaseProperty");
if (docBaseProperty == null || docBaseProperty.trim().equals("")) {
throw new RuntimeException("docBaseProperty parameter must not be blank");
}
final String docBase = System.getProperty(docBaseProperty);
if (docBase == null || docBase.trim().equals("")) {
throw new RuntimeException("docBase property " + docBaseProperty + " must be set");
}
final FileDirContext context = new FileDirContext(env);
context.setDocBase(docBase);
// Load the proxy dir context.
resources = new ProxyDirContext(env, context);
if (super.debug > 0) {
log("FileServingServlet: docBase=" + docBase);
}
}
}
Which I use like this in the web.xml
<servlet>
<servlet-name>fileServing</servlet-name>
<servlet-class>xxxx.FileServingServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>listings</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>docBaseProperty</param-name>
<!-- Name of the system property containg the base dir -->
<param-value>my.basedir.directory</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>fileServing</servlet-name>
<url-pattern>/directory/*</url-pattern>
</servlet-mapping>
It maps to /directory the content of the local directory specified in the System property my.basedir.directory. I use such a property because I did not want to hard code the local directory in the web.xml as it can be different in various deployement context.
-
13. Re: Replacement for context.xml in AS7? Access files outside the WAR?
cgaffga Dec 1, 2011 6:26 AM (in response to guinotphil)yes, I solved it the same way
-
14. Re: Replacement for context.xml in AS7? Access files outside the WAR?
r.reimann Feb 29, 2012 4:56 AM (in response to jfclere)Hello Jean-Frederic,
Jean-Frederic Clere schrieb:
The jbossweb docs is being cleaned, reference to context.xml, server.xml etc are wrong.
The minimal you need is under http://docs.jboss.org/jbossweb/7.0.x/config
In AS6 the "cache" attibute for the Authenticator Valves (e.g. org.apache.catalina.authenticator.BasicAuthenticator) could be configured inside context.xml.
Unfortunately i couldn't find a way how to configure the cache attribute within AS7 after dessupport of context.xml. Neither the jboss-as-web_1_1.xsd nor the current docs seem to cover this.
Could you please take a look into https://community.jboss.org/message/719779 and suggest a way how the principal cache can be disabled in AS7?
Thanks in advance
Robert