what are the minimal JSF jars needed to deploy a JSF app with Tomcat - eclipse

I know that a minimal API is 4 jars, I remember facelets*.jar.
What are the minimal JSF jars needed to deploy a JSF app with Tomcat?

Just use the JAR files which are provided/required by the JSF implementation you choose to use. Just download the implementation and read their own installation/users guide if you don't actually need more JAR files (as dependencies).
As of now there are only two major JSF implementations: Mojarra and MyFaces. The number of JAR files may vary per implementation and even version. Ultimately you need to make sure that you have both the JSF API and JSF implementation (which may exist of 2 or even 1 JAR file, depending on impl/version). MyFaces requires more commons-*.jar dependencies while Mojarra doesn't require any additional dependencies.
Since JSF 2.0, Facelets is bundled with the JSF implementation and has replaced JSP as default view technology.
See also:
Our JSF wiki page

These two are enough to start a simple web app using JSF 2.1 with tomcat 7.
javax.faces-2.1.14.jar
and
jstl-1.1.0.jar

You can run a JSF application with tomcat by either including Mojarra libraries or by including jars.
1. To include Mojarra libraries,
While creating an JSF application, it asks for JSF implementation library. Select option 'User library' and then click on 'Download library' option as shown in the below image.
It will then search for the libraries and show an option like below,
Select the mojarra library and then accept the "Terms and conditions" and click on "Finish".
2. Include below jars
Download JSF-API Jar http://central.maven.org/maven2/com/sun/faces/jsf-api/
Download JSF-IMPL Jar http://central.maven.org/maven2/com/sun/faces/jsf-impl/

Related

When downloading Mojarra libraries for JSF it is showing error "zip file is empty" in Eclipse

I'm working on JSF project, I'm trying to set up project facets in Eclipse, When I'm downloading Mojarra libraries for JSF2.2 it is giving error message. I'm using Eclipse Neon 2.
See the below image for more information.
Update: Updated.
Adding Mojarra Manually When Eclipse Luna/NEON/Oxygen JSF Download Library Is Empty...
When I was setting up a fresh install of JavaEE on my laptop today, the JSF Download Library would not return any results to download. Some searching suggested that I had to change my proxy settings but since I was not behind a proxy,
Actually some sorts are saying temporarily / Website is offline that's why its not downloadable ...
it would not help me. Lucky enough, JSF are just another bunch of jars that can be added to a user library.
You can download the JSF Scroll down here for newest versions of JSF jars...
Download JSF API JAR JSF API jar file
Download JSF IMPL JAR JSF IMPl jar file
Then simply; click the “Manage Libraries” icon on the JSF capabilities page click “New” and name your library
click “Add external jars” and browse to the jars you downloaded
Finally you are fully featured to the JSF Mojjara Library
Thanks...
I have downloaded javax.faces.jar file from maven repository. Added that jar file to classpath, now it is working fine.
javax.faces.jar
I found other sotution, when you start a new dynamic Web proyect pick "New runtime", then Oracle>Glassfish, install it and restart eclipse, JSF library is probided by Glassfish so in JSF Capabilities panel (when the new proyect is created) , glassfish is assigned by default (the System library). it works for me :)

Adding JSF 2.2 results in "Found multiple versions of the required class javax.faces.FactoryFinder"

I'm wondering how I can use JSF 2.2 (instead of the 2.0.2) in Eclipse?
It seems like there is no official release (only majorra 2.0 and myfaces 2.0.2 are available)
and when I add jsf 2.2 impl and api manually (Project Facets), it tells me: "Found multiple versions of the required class javax.faces.FactoryFinder.".
When i remove the old (myfaces 2.0.2) tomcat fails...
is there a way to make JSF 2.2 run in eclipse as default?
You can both, add the library to your classpath or configure it in jsf preferences, if you've the facet enabled. In the first way you're not telling Eclipse you're using JSF and second way you tell it and you can choose between configuring the classpath yourself or make Eclipse choose which JSF jars you want to use to let it include them.
First of all you need to download the jars from Mojarra's or MyFaces'es site. MyFaces doesn't have 2.2 version implemented as of today.
To just add the library to your classpath, right click on the project and go to Properties, Java build path. Then click on Add JAR or Add External JARs, depending where you have the jar and add the jsf-api and jsf-impl jars.
Otherwise, if you have the project configured as a JSF project, firstly you have to enable the JSF facet, check Project Facets. Then Eclipse will create a submenu inside Project Facets, letting you configure JSF. You can choose disable library configuration and do it the previous way or select User Library:
Then click on the books icon and you can add a new user library. Once added you only need to add required jars. Keep in mind that you need both jsf-api and jsf-impl jars to have it working, as Tomcat is a plain servlet container and doesn't include any JSF implementation out of the box.
Alternatively, you can also place the jsf-impl directly in your Tomcat shared libraries folder. You should drop it in $CATALINA_HOME/lib and every single application you deploy will use the same implementation. In that way you can just reference the jsf-api from your projects and code against it, having the implementation itself into the server's classpath.

Configuring Mojarra 2.1.X on Eclipse Indigo

The User Library download from Properties/Project Facets/Java Server Faces only lists Apache and Mojarra 2.0.X options. And setting up a user library manually, if I add javax.faces-2.1.11.jar, it doesn't error, puts the jar in the entry, then says \jarfiles\jaf (missing). So I see no way to use Mojarra 2.1.X.
I am unable to understand completely that what are you saying? But as much as I can I understood that "you want you use Mojarra 2.1.X" in your project. Now here is the thing You should mention the server that you are using.
If you are using glassfish 3.1.x then you have to replace your javax.faces.jar present in /glassfish/modules folder with javax.faces-2.1.11.jar as the glassfish built in jar javax.faces.jar enforce glassfish to use Mojarra 2.1.6.Now if it is Tomcat then it is up to you that you have to add all jsf compulsory jars in your lib folder :) One last thing that if you are using anyother server which has built in support for JSF and you are unable to find How to replace your jar from that server or you have issue with admin access over that server then you can also upgrade JSF by placing the newer javax.faces.jar file in webapp's own /WEB-INF/lib folder and editing the /WEB-INF/glassfish-web.xml file to add the following two new entries: <class-loader delegate="false" /><property name="useBundledJsf" value="true" />.Keep in mind that you are only enforce Web servers to use your desired jars not the application servers because many applications servers are giving built in support for JSF. So Configuring Mojarra 2.1.X on Eclipse Indigo is somehow wrong to ask.You have to ask that how should I use Mojarra 2.1.x with my XXX server because eclipse is only IDE and these things are SOMEHOW managed by IDE but only in case of Webservers.Thanks :)

impossible add Icefaces 3 facet in Eclipse 3.7?

I am trying add Icefaces 3 facet but it is not work correctly, I have created a maven project (WTP=2.0) by maven command, the I have add JSF2,Java 1.6 and Javascript by Eclipse project facet, but when I try to add ICefaces 3 facet then Eclipse not working.
I add .XHTML extension in JSP editor and it work fine if I create a ICefaces project.
I don´t upload images, sorry, this is a link: http://www.flickr.com/photos/75492946#N02/6785053594/
In the image above, I press OK button and nothing happens, Icefaces 3 faces doesn´t add.
Otherwise, I download M2Eclipse and I have created a maven project, I followed the same steps above, and everything is fine until I try to add ICefaces 3 facet, with the same result for me.
I can write tag ui autocomplete bacause JSF2 nature add correctly, but I dont write autocomplete tags ace/ice
Finally, I could create a Icefaces project but this is not desired by me, because I need a Maven project within Icefaces 3 nature.
any suggestions?
Kinds regards.
==================================================================================
Finally!! I have resolved this problem. It is a very easy solution but I had overlooked. When You need to add Dynamic Web Module facet you must set Content directory: /src/main/webapp/
In this way the project preserver standard maven structure y then you could add JSF2 and Icefaces3 facet without problem.
Now, You can create *.xhtml file and autocomplete Icefaces,JSF2 and facelets tags.
Edit: The real conflict is the web.xml, it must be version=3.0, only in this way you can do the above steps.
ICefaces 3 releases note say: This release includes the Mojarra JSF 2.1.4 runtime libraries. Mojarra 2.1.4 introduces a hard depedency on Servlet 3.0 APIs, as a result, it cannot be used on older JEE5 application servers. Mojarra 2.1.3, or Apache MyFaces 2.1.6 should be used in on older JEE5 servers instead.
In my case I use Mojarra 2.1.3 and the web.mxl is version=2.5, but it conflict because ICefaces 3 eclipse facet somehow related Mojarra 2.14 and web.xml version=3.0
The final solution addition to the above is to user web.xml version=3.0 and libraries provided by Icefaces3 plugin.
If you start your project as an ICEFaces project, you can convert it to be a Maven project also after it is created.
Right click the project in your explorer
Select Configure > Convert to Maven project
This has worked for me in the past when I have needed a project to use Maven and other plugins at the same time.

debuggging eclipse plugin dependancy

I am creating an eclipse plugin that calls some classes from a Java project. I have added this Java project as a required project on my build path.
When I create an eclipse plugin jar using an ant script, everything works fine.
However when I try to debug the code at run time or open the eclipse as a run time application, the classes from the Java project are not accessible. I get a NoClassDefFoundException.
Is there something I am missing while adding the dependancy?
Eclipse is based on OSGi, and as a rule of thumb, bundles can only see other bundles. Usually for including 3rd party jars in an eclipse plugin, you have 2 choices:
1) Include the jar in your eclipse project. Add it to the build.properties. Edit the MANIFEST.MF and add it to the Classpath section on the Runtime tab.
2) turn the 3rd party jar into a bundle so that your eclipse plugin can require it. You can use File>New>Other...>Plug-in Development>Plug-in from Existing JAR. The simplest form of an OSGi bundle is just the original jar with OSGi headers added to its MANIFEST.MF.
EDIT:
Remember also you have to honour the 3rd party jar license with whichever option you choose.