开发者

How to configure JSF 2.0 application's project stage via JNDI in Tomcat

开发者 https://www.devze.com 2023-03-16 18:45 出处:网络
been struggling to find a way to configure Tomcat 7.0.11 so that my web application would use project stage setting from Tomcat\'s config. So far - no luck. The idea is to 开发者_如何学Goset this prop

been struggling to find a way to configure Tomcat 7.0.11 so that my web application would use project stage setting from Tomcat's config. So far - no luck. The idea is to 开发者_如何学Goset this property in Tomcat server/host/application wide but not to set it in web.xml. Any ideas? I am using MyFaces JSF 2 implementation 2.0.5.


The specification says that the JSF implementation looks up the Project Stage using JNDI under java:comp/env/jsf/ProjectStage. If not found it uses the context parameter javax.faces.PROJECT_STAGE from your web.xml. This means that if defined/found on your Tomcat using JNDI, the value of preferred over the web.xml setting.

There are two things you can do:

Option 1: Overwrite the context parameter: This means that context parameter is set/overwritten using the Tomcat server.xml or context.xml. You need to put this in your <Context>-tag:

<Parameter name="javax.faces.PROJECT_STAGE" value="Production" override="false" />

Careful: override="false" here means that this parameter can NOT be overriden by the web.xml (not the other way around)!

Option 2: Configure a resource that can be found using JNDI: By using this that JSF implementation can resolve the project stage using the JNDI lookup.

<Environment name="jsf/ProjectStage" value="Production" type="java.lang.String" override="false"/>

You can also move this to the <GlobalResources>-tag in your server.xml. In this case you would need to reference this in your <Context>-tag by using <ResourceLink>-tag.

0

精彩评论

暂无评论...
验证码 换一张
取 消