| Summary: | Annotations (@ManagedBean) and serve modules without publishing | ||
|---|---|---|---|
| Product: | [WebTools] WTP ServerTools | Reporter: | Hanspeter Klapf <hanspeter.klapf> |
| Component: | wst.server | Assignee: | Larry Isaacs <larryisaacs> |
| Status: | RESOLVED FIXED | QA Contact: | Angel Vera <arvera> |
| Severity: | normal | ||
| Priority: | P3 | CC: | jtougas, raghunathan.srinivasan |
| Version: | 3.2 | ||
| Target Milestone: | 3.2.3 | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | |||
I'm using mojarra 2.0.4-b09 and I'm having a similar problem with @FacesConverter. Doing a little digging I found that com.sun.faces.config.AnnotationScanner scans /WEB-INF/classes/, but since these classes aren't found there with the "serve modules without publishing" option, they never get scanned. JSF supports specifying these in faces-config.xml, so this is a workaround for the moment, but obviously not ideal. (In reply to comment #1) > I'm using mojarra 2.0.4-b09 and I'm having a similar problem with > @FacesConverter. Doing a little digging I found that > com.sun.faces.config.AnnotationScanner scans /WEB-INF/classes/, but since these > classes aren't found there with the "serve modules without publishing" option, > they never get scanned. Moving this to the Server Tool component based on the above comment. Please reassign to JSF if this is an issue with the JSF Tools. Sorry to take so long to address this. This behavior stems from the same basic issue in "Server modules without publishing" as the one in Bug 318449. There were other negative side effects of breaking Class.getResource() when ServletContext.getResource() was allowed to work. Unfortunately, it appears that JSF annotation processing is also lost along with ServletContext.getResource() (and ServletContext.getResourceAsStream()). Fortunately, as documented in Bug 333102 Comment #3, Tomcat 7 has improvements that allow ServletContext.getResource() and ServletContext.getResourceAsStream() functionally to be restored without impacting Class.GetResource(). Trying the test case above with Tomcat 7 shows that it continues to work with "Serve modules without publishing" enabled. Since the problem behavior was fixed for Tomcat 7, I'm marking this bug as also FIXED (in WTP 3.2.3 via Bug 333102). It's not currently possible to fix this for Tomcat 6 without breaking use cases where Class.getResource() is in use. Also, changing the current behavior may introduce more problems than it solves. If one is adventurous, you can examine the simple patch in Bug 318449 and restore what was changed for Tomcat 6 and see what happens. Annotations should resume working, but there may be other important behavior that will stop working. |
Build Identifier: 20100917-0705 After upgrading my Helios to SR1, "Serve modules without publishing" doesn't work for me. While resources (html, css, js, etc.) and classes seems to be published (I tried that with simple JSP's), it looks like Annotations (@ManagedBean, @SessionScoped) don't work. Reproducible: Always Steps to Reproduce: 1. Create a new Dynamic Web Project without special configuration (only target runtime, I take my apache-tomcat 6.0.29) 2. Add JSF and JSTL Libraries to WEB-INF/lib (jsf-api.jar, jsf-impl.jar, jstl-api-1.2.jar, jstl-impl-1.2.jar and log4j-1.2.12.jar) 3. At properties/Project Facets add "JavaServer Faces 2.0" 4. Write a simple Bean package test; import javax.faces.bean.ManagedBean; import javax.faces.bean.SessionScoped; @ManagedBean(name="testbean") @SessionScoped public class TestBean { private String property; public TestBean() { this.property = "initial-value"; } public String getProperty() { return property; } public void setProperty(String property) { this.property = property; } } 5. Write an JSF-Page <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"> <f:view contentType="text/html"/> <h:head> <title>test</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> </h:head> <h:body bgcolor="white"> <h:form id="test" prependId="false"> <h:messages styleClass="error" showDetail="true" showSummary="false" tooltip="false" /> <fieldset class="form_block"> <div align="center"> <h1><h:outputText value="#{testbean.property}" /></h1> </div> </fieldset> </h:form> </h:body> </html> 6. When adding this project to a server, the property is listed when "Serve modules without publishing" isn't checked, elsewise it doesn't