Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 7.4.4
-
Fix Version/s: None
-
Component/s: Maven
-
Labels:None
-
Environment:JSF Maven2
-
Testcase included:yes
-
Number of attachments :2
Description
With a framework like JavaServer Faces (JSF) the framework scans the classes in WEB-INF/classes to find annotated classes (e.g. classes annotated with the @ManagedBean annotation - javax.faces.bean.ManagedBean). If you run jetty in maven using the "useTestClasspath" folder, when the framework looks for WEB-INF/classes so it can start scanning it the contained classes, the virtual/fake WEB-INF/classes located at target/test-classes is returned instead of target\classes. The useTestClasspath always puts test classes ahead of the main classes. It would be nice if that ordering could be controlled by a parameter but it may also be possible to ignore the test classes if code is specifically looking for a resource named "/WEB-INF/classes". If it is looking for that directory it probably wants to scan it.
I will attach sample webapp that I found on a different issue that I used to track down this problem. I mainly just added a dummy test class so there is a test class folder and I added the useTestClasspath option to the jetty plugin config in pom.xml. If you click around the sample application it will error out when it tries to evaluate expressions that involve annotated classes. If you set useTestClasspath to false or remove it then the application will work.
-
Hide
- jsf-jetty-test.zip
- 07/Sep/11 3:52 PM
- 33 kB
- Hal Deadman
-
- jsf-jetty-test/pom.xml 6 kB
- jsf-jetty-test/src/.../domain/Address.java 1 kB
- jsf-jetty-test/src/.../CreditCardType.java 0.1 kB
- jsf-jetty-test/src/.../domain/Customer.java 3 kB
- jsf-jetty-test/src/.../jsf/AgeValidator.java 2 kB
- jsf-jetty-test/.../BirthdayValidator.java 2 kB
- jsf-jetty-test/.../DebugPhaseListener.java 0.8 kB
- jsf-jetty-test/.../ParameterPhaseListener.java 1 kB
- jsf-jetty-test/src/.../ZipCodeConverter.java 1 kB
- jsf-jetty-test/src/.../page/AddressBean.java 0.6 kB
- jsf-jetty-test/src/.../CustomerBean.java 5 kB
- jsf-jetty-test/src/.../util/GuiUtil.java 2 kB
- jsf-jetty-test/src/.../MyGourmetUtil.java 0.5 kB
- jsf-jetty-test/src/.../Birthday.java 0.7 kB
- jsf-jetty-test/.../BirthdayValidator.java 2 kB
- jsf-jetty-test/src/.../jetty/jetty-env.xml 0.2 kB
- jsf-jetty-test/src/.../jetty/webdefault.xml 24 kB
- jsf-jetty-test/.../messages_de.properties 1 kB
- jsf-jetty-test/.../messages_en.properties 1 kB
- jsf-jetty-test/src/.../log4j.properties 0.7 kB
- jsf-jetty-test/.../ValidationMessages_de.properties 0.1 kB
- jsf-jetty-test/.../ValidationMessages_en.properties 0.1 kB
- jsf-jetty-test/src/.../editAddress.xhtml 2 kB
- jsf-jetty-test/src/.../editCustomer.xhtml 4 kB
- jsf-jetty-test/src/main/.../images/logo.png 0.8 kB
- jsf-jetty-test/src/.../webapp/index.html 0.1 kB
- jsf-jetty-test/.../customerTemplate.xhtml 0.9 kB
- jsf-jetty-test/src/.../leftSideBar.xhtml 0.9 kB
- jsf-jetty-test/src/.../sideBox.xhtml 0.6 kB
- jsf-jetty-test/src/.../template.xhtml 0.8 kB
-
- useTestClasspath.txt
- 12/Sep/11 2:09 PM
- 6 kB
- Hal Deadman
Activity
This patch causes target/classes to be returned instead of target/test-classes when application code is searching for the /WEB-INF/classes/ resource. The assumption is that the application code wants that folder in order to scan all the child resources for annoations.
Fixed for jetty-7.5.2.
Took your suggestion and put the target/classpath first when calling getResource() for PRECISELY "/WEB-INF/classes". Otherwise, the usual classpath order should be followed.
I tested this against the webapp you provided, but I would appreciate it if you could give it a test yourself.
This issue is related to http://jira.codehaus.org/browse/JETTY-1107. The fix for that allows JSF applications to use annotations as long as they don't use the "useTestClasspath" option.