Develop In Java
  • Home
  • News
  • Tips and Tricks
  • Articles
    • Books>
      • Alfresco Enterprise Content Management Implementation
        • Beginning Java EE 6 Platform with GlassFish 3
          • EJB 3.1 Cookbook
            • GlassFish Security
              • GWT Java Ajax Programming
                • Java EE 5 Development using GlassFish Application Server
                  • JBoss RichFaces
                    • Seam 2.x Web Development
                    • Desktop Java>
                      • An Overview of The New Features in J2SE 5.0
                        • Using FindBugs with NetBeans 5.5
                        • Enterprise Java>
                          • Basic Java CRUD Operations With MongoDB
                            • Continuous Integration with Hudson on Glassfish
                              • Creating a Simple Spring MVC Web App With NetBeans 5.0
                                • Creating a Simple Spring MVC Web App With NetBeans 5.0 Part 2
                                  • Creating a Weld Project using Maven and NetBeans
                                    • Deploying a Java EE Web Application to OpenShift Express
                                      • Developing your first Web Service with Java EE 5 and NetBeans
                                        • Introduction to JSF 2 Using NetBeans and GlassFish
                                          • Securing a Web Application on Glassfish using JAAS
                                            • Securing a Web Application on Glassfish using JAAS Part 2
                                          • Links
                                          • Forums
                                          • Search
                                          • Contact Us

                                          Creating a Weld Project using Maven and NetBeans

                                          David Salter, 15th January 2010
                                          Now that the Beta Maven archetypes for Weld (the reference implementation of JSR 299 - Java Contexts and Dependency Injection) have been published in the Maven Central Repository, its easy to create Weld projects using Maven and NetBeans.
                                          Assuming you have NetBeans 6.8 set up with GlassFish v3 server and the Maven plugin, use the following steps to create a new project.

                                          1. Create a new Maven project.

                                          Select "File | New Project" and then choose Maven as the category and "Maven Project" as the project type.
                                          Picture

                                          2. Add the Weld Maven Archetypes

                                          On the Maven Archetype screen, press the "Add..." button. This will cause the "Specify archetype details" screen to be displayed. On this screen we can add details of the different Maven archetypes that are currently available for Weld.
                                          Picture
                                          There are currently 3 Maven archetypes defined in the catalog. 
                                          weld-jsf-servlet-minimal - Weld archetype for creating an application using JSF 2.0 and CDI 1.0 for Servlet Containers (Tomcat 6 / Jetty 6)
                                          weld-jsf-jee-minimal - Weld archetype for creating a minimal Java EE 6 application using JSF 2.0, CDI 1.0 and EJB 3.1 (persistence unit not included)
                                          weld-jsf-jee - Weld archetype for creating a Java EE 6 application using JSF 2.0, CDI 1.0, EJB 3.1 and JPA 2.0 (persistence unit included)
                                          For this example, I'm using weld-jsf-servlet-minimal. Enter the details of the archetype from the catalog into the dialog and press "OK".
                                          On the following screen, select the archetype you've just added and press the "Next" button.
                                          Picture

                                          3. Select Project Details

                                          On the final page of the create project wizard, enter the project name, location and base package name for the project and press the "Finish" button.
                                          Picture

                                          4. Run the project

                                          Now that we've created a sample project, it can easily be executed by right clicking on the project node and selecting the "Run" option. This will open a dialog asking for the default deployment server - select a GlassFish v3 server and press "OK".
                                          Picture
                                          If all is successful, the project should now build and be opened in the default browser.
                                          Picture
                                          Originally published at http://www.davidsalter.co.uk
                                          You can discuss this article here.

                                          Locations of visitors to this page

                                          Copyright (C) DevelopInJava.com 2006-2012