Glassfish 3: cannot set javax.faces.PROJECT_STAGE to "production"
I', trying to set开发者_如何学Go the javax.faces.PROJECT_STAGE to "production" in my web.xml, but in runtime I see, that the value is always "development". Debugging shows very strange things, cannot get to the situation.. Tried both on GF 3.0.1 and GF 3.1 - the same.
Here is the piece of my web.xml:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/applicationContext*.xml</param-value>
</context-param>
<context-param>
<param-name>javax.faces.FACELETS_LIBRARIES</param-name>
<param-value>/WEB-INF/rstk-tag.taglib.xml</param-value>
</context-param>
<context-param>
<param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>rstk.DOWNLOAD_PATH</param-name>
<param-value>c:\glassfish3.1\downloads</param-value>
</context-param>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Production</param-value>
</context-param>
and this
FacesContext.getCurrentInstance().getApplication().getProjectStage()
always returns Development!
Any help appreciated, this is the real stopper for me as JSF 2.1 in GF 3.1 results in frustrating warning in development mode..
Ok, finally I found the real reason for this staff.
It's Jrebel. For some reasons they force the DEVELOPMENT mode for jsf. For more details you can see http://java.net/jira/browse/JAVASERVERFACES-2079?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel - comments block. The other person had the same problem and finally found out the core reason.
Hope this will help everyone.
Not a solution, but some ideas:
What if you remove the context-param for the project stage? As far as I remember, Production should be default stage if nothing is defined in web.xml or default-web.xml.
Another idea: How does your default-web.xml look like in glassfish/glassfish/config directory?
Try to move the context-param to the very first position of the parameters.
I could not fix the bug, don't know, why the WeldApplication keeps returning the Development stage, the debug behaved a bit strange and I could not get real reason.. Tried to manually set the WeldApplicationFactory, but no result. Finally I made and ugly workaround, but it helped me to change the stage and get rid of annoying message from JSF ("greetings" to Mojarra team)
First override the WeldApplicationFactory to return your own Application:
public class CustomApplicationFactory extends WeldApplicationFactory {
/**
* TBD
* @param delegate
*/
public CustomApplicationFactory(ApplicationFactory delegate) {
super(delegate);
this.delegate = delegate;
}
private final ApplicationFactory delegate;
private Application application;
@Override
public void setApplication(Application application) {
this.application = application;
delegate.setApplication(application);
}
@Override
public Application getApplication() {
if (application == null) {
application = new HuckApplication(delegate.getApplication());
}
return application;
}
}
Then override the WeldApplication:
/*
* * Created on 13.03.2011 * * $Project$ * $Workfile$ * $Revision$ */
public class HuckApplication extends WeldApplication {
/**
* TBD
* @param application
*/
public HuckApplication(Application application) {
super(application);
// TODO Auto-generated constructor stub
}
/**
* @see javax.faces.application.ApplicationWrapper#getProjectStage()
*/
@Override
public ProjectStage getProjectStage() {
return ProjectStage.Production;
}
}
and register your new ApplicationFactory in faces-config.xml.
This worked for me, though this solution isn't beautiful at all, but it let's me move on my own development, and not struggling with Mojarra/Glassfish bugs :)
精彩评论