Java EE 6 - Getting Started (maven, CDI and persistence) ready project

Java EE 6 – Getting Started (maven, CDI and persistence) ready project

This short tutorial describes how to get started easily and quickly with Java EE 6 development. For the purpose of this tutorial you would need to have installed the following tools:

1. Maven 3
2. JBoss AS 6.0
3. Eclipse (I will use Helios release)
4. Eclipse m2eclipse plugin (for managing Maven based projects)

If you have all this tools ready, you can quickly create an maven J2EE archetype provided by JBoss.

1. Open up the Eclipse IDE and select ‘File -> New -> Project’

2. One the next screen just click ‘Next’

3. One the archetype selection screen, type ‘weld’ in a filter box and select weld.jsf.jee archetype 1.0.0-BETA1

4. Fill up the details for your project

5. Click ‘Finish’

6. Right click on the newly created project and select ‘Run As.. -> Run on Server’ and select Jboss 6.0 server to run your project. If you haven’t configured your jboss server with eclipse you can do it here.

7. Go to the page at: http://localhost:8080/J2EE6Tutorial where J2EE6Tutorial is the name of my project and 8080 is the port I had installed JBoss application server.

What you will see is probably the error saying:

javax.servlet.ServletException: /home.xhtml: The class 'java.lang.String' does not have the property 'id'.
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:321)
    org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:67)

This is due to the bug in the j2ee weld artifact.

8. To solve the mentioned bug, open up home.xhtml file located in ‘scr/main/webapp/’ folder and change the following line:

 <h:dataTable var="_widget" value="#widgets">

to:

 <h:dataTable var="_widget" value="#{widgets}">

9. Redeploy the application on the server. Go to the ‘Servers’ tab, select our application, right click on it, and select ‘Full Publish’.

10. Now you can refresh the application in the browser.

10 responses on “Java EE 6 – Getting Started (maven, CDI and persistence) ready project

  1. Tomi Savolainen April 4, 2011 at 8:55 pm

    Nice tutorial, but like many others this is dependent on using Eclipse. I would like this kind of tutorials not to use a certain IDE for creating something.

  2. admin April 5, 2011 at 8:22 pm

    This project is actually maven based, so its up to you if you create it in Eclispe IDE or other, the steps will be similar and the project structure stays the same, regardless of the IDE used.

  3. Todd Morrison April 5, 2011 at 11:02 pm

    @Tomi, check out seam’s docs using Weld: http://seamframework.org/Documentation/CDIQuickstartForMavenUsers

    There is a good way to get started outside of eclipse.

  4. Dan Allen April 6, 2011 at 4:19 am

    You should be selecting the jboss-javaee6-webapp instead. It’s more up to date and you shouldn’t get any errors.

    The weld-* archetypes are deprecated.

  5. Dan Allen April 6, 2011 at 4:22 am

    See http://tinyurl.com/gojavaee for details. The page also includes instructions for creating the project from the archetype in NetBeans.

  6. admin April 6, 2011 at 8:13 am

    Thanks Dan! Didn’t know about that archetype.

  7. kim April 23, 2011 at 8:08 am

    When I created jboss-javaee6-webapp maven project, it is not recognized as Web project. Is this expected? I am using Eclipse Helios release.

Leave a Reply

Related Posts

    No Releated Posts

10 responses on “Java EE 6 – Getting Started (maven, CDI and persistence) ready project

  1. Tomi Savolainen April 4, 2011 at 8:55 pm

    Nice tutorial, but like many others this is dependent on using Eclipse. I would like this kind of tutorials not to use a certain IDE for creating something.

  2. admin April 5, 2011 at 8:22 pm

    This project is actually maven based, so its up to you if you create it in Eclispe IDE or other, the steps will be similar and the project structure stays the same, regardless of the IDE used.

  3. Todd Morrison April 5, 2011 at 11:02 pm

    @Tomi, check out seam’s docs using Weld: http://seamframework.org/Documentation/CDIQuickstartForMavenUsers

    There is a good way to get started outside of eclipse.

  4. Dan Allen April 6, 2011 at 4:19 am

    You should be selecting the jboss-javaee6-webapp instead. It’s more up to date and you shouldn’t get any errors.

    The weld-* archetypes are deprecated.

  5. Dan Allen April 6, 2011 at 4:22 am

    See http://tinyurl.com/gojavaee for details. The page also includes instructions for creating the project from the archetype in NetBeans.

  6. admin April 6, 2011 at 8:13 am

    Thanks Dan! Didn’t know about that archetype.

  7. kim April 23, 2011 at 8:08 am

    When I created jboss-javaee6-webapp maven project, it is not recognized as Web project. Is this expected? I am using Eclipse Helios release.

Leave a Reply