Prepare your JSF PrimeFaces project for Eclipse Indigo and JBoss AS7.1.1

In my opinion, developing PrimeFaces application in Eclipse is the most natural way to do it, if you plan to deploy your webapp on JBoss Application Server. The easiest way to start developing web applications for JBoss in Eclipse is by using JBoss Tools Plugin. I will describe how to install it. Here is a list of things which you need to do, in order to get your IDE work and start a new project:

  1. Choose and install Eclipse version of your choice. In my case it is Eclipse Indigo Sr2 for Java EE developers.

  2. Download and install JBoss Tools 3.3.

  3. Download and define JBoss server instance in Eclipse IDE for JBoss AS 7.1.1.

  4. Create new project Dynamic Web Project. Since I want to place my web project in EAR file, I will define EAR project first.

  5. Download and add primefaces-3.5.jar to your project lib directory.
Eclipse Indigo Installation

You can find Eclipse Indigo here: Eclipse Indigo Download Page. Select your Eclipse version. In my case, it's Eclipse IDE for Java EE Developers. Since I'm developing on Mac, I will select a 64-bit Mac Cocoa installation:

eclipse.org

After download and installation are completed, you can start your Eclipse and install required Eclipse plugins.

JBoss Tools installation

Now you can install JBoss Tools plugin in your Eclipse. To do this go to Help -> Install New Software:

help-install-new-software

Then define a new repository site:

update-site

Now you can define a new repository. Put JBoss Tools 3.3 as name and http://download.jboss.org/jbosstools/updates/stable/indigo/ as repository location and click OK:

new-repository

After that you can click Select All and Next to go to the next installation step:

install

Click Next once again, accept license terms and click Finish to start installation. During installation Eclipse will ask you whether you want to install unsigned content, click OK:

jboss-tools-unassigned-content

When Eclipse finishes plugin installation, it will ask you what to do next, click: Restart Now:

restart-eclipse

After this last step, your IDE is ready to define a new server instance and create a new Dynamic Web Project.

JBoss AS 7.1.1 Installation

In order to install JBoss AS, go to JBoss Application Server Downloads page and get JBoss 7.1.1.Final Brontes. After download unzip it, go to Servers view in your Eclipse and click new server wizard to define new server:

server-view

On the list of server adapters select JBoss Community -> JBoss AS 7.1. Put localhost as server host name and click Next:

Zrzut ekranu 2013-02-17 o 17.36.34

On the next wizard page set server folder and click Next:

Zrzut ekranu 2013-02-17 o 17.48.32

Click Finish to end the adapter definition step. Your server adapter is ready. Now you can go to the next step, which is project creation.

Dynamic Web Project Creation

As I mentioned earlier, I want my project to be deployed as EAR file, so first I'm going to create an EAR project. To do so, I'm going to File -> New -> Enterprise Application Project in my Eclipse. I will set the name of this project to CRUDPrimefaces_EAR and click Next. On the next wizard page I will select checkbox Generate application.xml deployment descriptor and click Finish:

new-earenterprise-application

In this stage you will get the following error:
Description    Resource    Path    Location    Type
cvc-complex-type.2.4.b: The content of element 'application' is not complete. One of '{"http://java.sun.com/xml/ns/javaee":display-name, "http://java.sun.com/xml/ns/javaee":icon, "http://java.sun.com/xml/ns/javaee":initialize-in-order, "http://java.sun.com/xml/ns/javaee":module}' is expected.    application.xml    /CRUDPrimefaces_EAR/EarContent/META-INF    line 2    XML Problem

in your application.xml file. This happens, because there is no EJB Project associated to your EAR project (or in other words: EAR file should store at least one EJB module). Let's define it now and then we can finally create a Dynamic Web Application. To do this, go to File -> New -> EJB Project in your Eclipse. Set project name to CRUDPrimefaces_EJB, select Add project to an EAR checkbox and click Next:

new-ejb-project

Click again Next and on the last wizard page, uncheck Create an EJB Client JAR module to hold the client interfaces and classes:

ejb-module

Click Finish to create an EJB Project. After the project creation application.xml is completed, the error should disappear. Finally, we can create a new Dynamic Web Project. Click File -> New -> Dynamic Web Project, set CRUDPrimefaces as project name and check Add project to an EAR. Click Next:

new-dynamic-web-project

On the next wizard page click Next. On the next web page check Generate web.xml deployment descriptor and click Finish:

web-module

Done. After this step your application.xml file should have the following structure:


and your project explorer should, more or less, look like this:

project-explorer

PrimeFaces installation

Go to PrimeFaces download page and download primefaces-3.5.jar:

primefaces-3.5

After download drag and drop primefaces-3.5.jar to dynamic web project directory CRUDPrimefaces/WebContent/WEB-INF/lib. Create faces directory in your CRUDPrimefaces/WebContent. Now your project structure should look like this:

primefaces-project-structure

You are ready to start developing JSF PrimeFaces application. In the next article I will explain how to adjust web.xml file for JSF mapping and how to create a simple Hello Faces world JSF page.

Read timed out troubleshooting

During installation of JBoss Tools 3.3 plugins set, you can get the following error (or a similar error):
An error occurred while collecting items to be installed
session context was:(profile=epp.package.jee, phase=org.eclipse.equinox.internal.p2.engine.phases.Collect, operand=, action=).
Unable to read repository at http://download.jboss.org/jbosstools/updates/JBossTools-3.3.2.Final.core/plugins/org.jboss.tools.seam.xml_3.3.0.v20130112-0336-H148-Final.jar.
Read timed out

Read timed out can be caused by various things. What's important here is the knowledge of how to solve this issue. In order to install a set of plugins successfully, you need to modify your eclipse.ini settings to increase timeouts. Edit your eclipse.ini and add the following settings as -vmargs:
-Dorg.eclipse.ecf.provider.filetransfer.retrieve.closeTimeout=30000
-Dorg.eclipse.ecf.provider.filetransfer.retrieve.readTimeout=30000

Restart your Eclipse to apply new settings and start plugins installation again. This workaround should solve the read timed out problem.

Additional information

This article is a part of the series of articles called From Zero to PrimeFaces Hero on JBoss 7.1 with Hibernate, MySQL, Eclipse Indigo and JBoss Tools. If you'd like to get more information about this series, please check out this article.

5 comments :: Prepare your JSF PrimeFaces project for Eclipse Indigo and JBoss AS7.1.1

  1. Awesome post, very useful

  2. Thank you!

  3. with the help of JBoss Tools, we can actually setup JSF project with all the JSF project structure ready,
    instead of just drag the PF jar into a Dynamic Web Project.

    If interested, please refer http://www.kianworknotes.com/2013/04/how-to-create-primefaces-project-with.html for steps.

  4. Hey Kian, thanks for comment. It's always good to know better solution!

  5. I've just realized that SyntaxHighlighter (I belive by Alex Gorbatchev) is not working on iOS (Safari). At least for mobile version of this site (this is blogger.com blog).

    You won't see any source code on this page (like XML, java or other samples).

    Sorry for technical problems. I will stop using this tool.

    Best Regards,
    Michael Flowersky

Post a Comment