My Goal
I have a Dynamic Web project (PROJECT X) containing some JSF composites
- under META-INF > resources > web > compositeX.xhtml
I would like that another Dynamic Web project (PROJECT A) to be able to use the JSF composite of project X.
What i have done
I was following this solution to do so. (Packaging Facelets files (templates, includes, composites) in a JAR)
I have referenced my project X inside project A.
- Right click project A > Properties > Deployment Assembly > add project X ...
The project is now added and when i run my project A on the server (JBOSS WILDFLY 14), i checked what was deployed on the server and COULDNT see any composite under WEB-INF/resources.
My Problem
1) I have seen in my eclipse that when i reference project X in project A it will automatically import it as a WAR rather than a JAR, i have read on other post from users that their dynamic web project referenced was imported as a JAR file. What should be the format of an imported web project a JAR or WAR ?
2) I tried as well to JAR it manually and add the JAR to the java build path and deployment assembly of the project A but still it says "Unknown composite component". I can see in the JAR (project X) a folder META-INF/resources/web/compositeX.xhtml, so the composite is really here but it is not accessible from my project A even after referencing the JAR. What am i missing ?
Solution (after a while of research)
REFERENCE PROJECT
- in the referenced project build the project with MAVEN POM as a JAR.
- in the main java ee project, setup the MAVEN POM to build the project as WAR and add referenced project as a dependency.
- check both project facet configuration to be web project 4.0, java 1.8, java server face 2.3, jboss maven integration 1.0.
- check all .xml configuration file in the project beans.xml -> must contains beans_2.0.xsd, faces-config.xml -> must contains web-facesconfig_2_3.xsd, web.xml -> must contains web-app_4_0.xsd.
- In eclipse under the build path option, check maven dependency is part of the order and exports tab, it should be at the top level and crossed checked.
- you need to clean then build your referenced project.
- you need to clean then build your project.
- if it is still failing try to rerun all the steps multiple times, sometime maven do not include the referenced jar project (reason unknown).
- ultimately, if still fail, add the referenced project in the deployment assembly and rename the destination from .WAR to .JAR.
CALL THE COMPOSITE
- you can use the same way the composite is called in this thread. It works for me (Packaging Facelets files (templates, includes, composites) in a JAR)