You are previewing Java EE Development with Eclipse - Second Edition.
O'Reilly logo
Java EE Development with Eclipse - Second Edition

Book Description

Develop, debug, test, and troubleshoot Java EE 7 applications rapidly with Eclipse

About This Book

  • Go beyond simply learning Java EE APIs and explore the complete workflow of developing enterprise Java applications

  • Learn to use the features of Eclipse JEE to simplify Java EE application development

  • Develop and deploy complete applications with JEE

  • Who This Book Is For

    If you are a Java developer who has little or no experience in JEE application development or you have experience in JEE technology but are looking for tips to simplify and accelerate your development process, then this book is for you.

    What You Will Learn

  • Set up Eclipse, Tomcat, and Glassfish server for JEE application development

  • Use JSP, Servlet, JSF, and EJBs to create a user interface and write business logic

  • Create JEE database applications using JDBC and JPA

  • Handle asynchronous messages using MDBs for better scalability

  • Deploy and debug JEE applications and create SOAP and REST web services

  • Write unit tests and calculate code coverage

  • Troubleshoot application performance and memory issues

  • In Detail

    Java EE is a technology for developing enterprise class, scalable applications. With recent changes to Java EE specifications, JEE application development has become a lot simpler. However, recent changes have also added many new specifications, some of which compete with existing JEE specification. Along with JEE specifications and APIs, it is also very important to understand the entire application development process and tools that can help simplify and accelerate JEE application development.

    This guide provides a complete overview of developing JEE applications using Eclipse. The many features of the Eclipse IDE are explained. These enable the rapid development, debugging, testing, and deployment of JEE applications. You'll explore not just different JEE technologies and how to use them (JSP, JSF, JPA, JDBC, EJB, web services etc.), but also suitable technologies for different scenarios.

    The book starts with how to set up the development environment for JEE applications and then goes on to describe many JEE specifications in detail, with an emphasis on examples. You'll learn how to deploy an example application on Tomcat and Glassfish Application Server.

    You'll create a simple application that reads from a queue, processes the request, and publishes results to a topic and Eclipse MAT (Memory Analysis Tool) to debug memory issues.

    Style and approach

    This guide takes a step-by-step approach to developing, testing, debugging, and troubleshooting JEE applications, complete with examples and tips.

    Downloading the example code for this book You can download the example code files for all Packt books you have purchased from your account at If you purchased this book elsewhere, you can visit and register to have the files e-mailed directly to you.

    Table of Contents

    1. Java EE Development with Eclipse Second Edition
      1. Table of Contents
      2. Java EE Development with Eclipse Second Edition
      3. Credits
      4. About the Author
      5. About the Reviewers
        1. Support files, eBooks, discount offers, and more
          1. Why subscribe?
          2. Free access for Packt account holders
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Errata
          3. Piracy
          4. Questions
      8. 1. Introducing JEE and Eclipse
        1. Java Enterprise Edition (JEE)
          1. The presentation layer
            1. Java Servlet
            2. Java Server Pages
            3. Java Server Faces
          2. The business layer
            1. Enterprise Java Beans
          3. The enterprise integration layer
            1. Java Database Connectivity (JDBC)
            2. The Java Persistent API (JPA)
            3. Java Connector Architecture (JCA)
            4. Web services
          4. Eclipse IDE
            1. Workspace
            2. Plugin
            3. Editors and views
            4. Perspective
            5. Eclipse preferences
        2. Installing products
          1. Installing Eclipse (Version 4.4)
          2. Installing Tomcat
          3. Installing the GlassFish server
          4. Installing MySQL
            1. Installing MySQL on Windows
            2. Installing MySQL on Mac OS X
            3. Installing MySQL on Linux
            4. Creating MySQL users
        3. Summary
      9. 2. Creating a Simple JEE Web Application
        1. Configuring Tomcat in Eclipse
        2. Java Server Pages
          1. Creating a dynamic web project
          2. Creating JSP
          3. Running JSP in Tomcat
          4. Using JavaBeans in JSP
          5. Using JSTL
        3. Implementing login application using Java Servlet
        4. Creating WAR
        5. Java Server Faces
        6. Using Maven for project management
          1. Maven views and preferences in Eclipse JEE
          2. Creating a Maven project
            1. Maven Archetype
          3. Exploring the POM
          4. Adding Maven dependencies
          5. The Maven project structure
          6. Creating WAR using Maven
        7. Summary
      10. 3. Source Control Management in Eclipse
        1. The Eclipse Subversion plugin
          1. Installing the Eclipse Subversion plugin
          2. Adding a project to an SVN repository
          3. Committing changes to an SVN repository
          4. Synchronizing with an SVN repository
          5. Checking out a project from SVN
        2. The Eclipse Git plugin
          1. Adding a project to Git
          2. Committing files in a Git repository
          3. Viewing a file difference after modifications
          4. Creating a new branch
          5. Committing a project to a remote repository
          6. Pulling changes from a remote repository
          7. Cloning a remote repository
        3. Summary
      11. 4. Creating a JEE Database Application
        1. Creating a database schema
          1. The script for creating tables and relationships
          2. Creating tables in MySQL
        2. Creating a database application using JDBC
          1. Creating a project and setting up Maven dependencies
          2. Creating JavaBeans for data storage
          3. Creating JSP to add a course
          4. JDBC concepts
            1. Creating a database connection
            2. Executing SQL statements
            3. Handling transactions
          5. Using the JDBC database connection pool
          6. Saving a course in a database table using JDBC
          7. Getting courses from the database table using JDBC
          8. Completing the add Course functionality
          9. Using Eclipse Data Source Explorer
        3. Creating a database application using JPA
          1. Creating the user interface for adding a course using JSF
          2. JPA concepts
            1. Entity
            2. EntityManager
            3. EntityManagerFactory
          3. Creating a JPA application
          4. Creating a new MySQL schema
          5. Setting up a Maven dependency for JPA
          6. Converting a project into a JPA project
          7. Creating entities
          8. Configuring entity relationships
            1. Configuring a many-to-one relationship
            2. Configuring a many-to-many relationship
          9. Creating database tables from entities
          10. Using JPA APIs to manage data
          11. Wiring the user interface with a JPA service class
        4. Summary
      12. 5. Unit Testing
        1. JUnit
        2. Creating and executing unit tests using Eclipse EE
          1. Creating a unit test case
          2. Running a unit test case
            1. Running a unit test case using Maven
        3. Mocking external dependencies for unit tests
          1. Using Mockito
        4. Calculating test coverage
        5. Summary
      13. 6. Debugging a JEE Application
        1. Debugging a remote Java application
        2. Debugging a web application using Tomcat in Eclipse EE
          1. Starting Tomcat in debug mode
          2. Setting breakpoints
          3. Running an application in debug mode
          4. Performing step operations and inspecting variables
          5. Inspecting variable values
        3. Debugging an application in an externally configured Tomcat
        4. Using Debugger to know the status of a program execution
        5. Summary
      14. 7. Creating JEE Applications with EJB
        1. Types of EJB
          1. Session bean
            1. Stateful session bean
            2. Stateless session bean
            3. Singleton session bean
          2. Accessing session bean from the client
            1. Creating a no-interface session
            2. Accessing session bean using dependency injection
            3. Creating session bean using the local business interface
            4. Accessing session bean using the JNDI lookup
            5. Creating session bean using a remote business interface
            6. Accessing a remote session bean
        2. Configuring the GlassFish server in Eclipse
        3. Creating the CourseManagement application using EJB
          1. Creating an EJB project in Eclipse
          2. Configuring datasource in GlassFish 4
          3. Configuring JPA
          4. Creating a JPA entity
          5. Creating stateless EJB
          6. Creating JSF and managed bean
          7. Running the example
          8. Creating EAR for deployment outside Eclipse
        4. Creating a JEE project using Maven
        5. Summary
      15. 8. Creating Web Applications with Spring MVC
        1. Dependency injection
        2. Dependency injection in Spring
          1. Component scopes
        3. Installing the Spring Tool Suite
        4. Creating a Spring MVC application
          1. Creating a Spring project
            1. Understanding files created by the Spring MVC project template
          2. Spring MVC application using JDBC
            1. Configuring datasource
            2. Using the Spring JDBCTemplate class
            3. Creating the Spring MVC Controller
            4. Calling Spring MVC Controller
            5. Mapping data using @ModelAttribute
            6. Using parameters in @RequestMapping
            7. Using the Spring interceptor
          3. Spring MVC application using JPA
            1. Configuring JPA
            2. Creating the Course entity
            3. Creating Course DAO and Controller
            4. Creating the Course list view
        5. Summary
      16. 9. Creating Web Services
        1. JAXB
          1. JAXB example
        2. REST web services
          1. Creating RESTful web services using Jersey
          2. Implementing the REST GET request
          3. Testing the REST GET request in browser
          4. Creating a Java client for the REST GET web service
          5. Implementing the REST POST request
          6. Writing a Java client for the REST POST web service
          7. Invoking the POST REST web service from JavaScript
          8. Creating the REST web service with Form POST
          9. Creating a Java client for the form-encoded REST web service
        3. SOAP web services
          1. SOAP
          2. WSDL
          3. UDDI
          4. Developing web services in Java
            1. Creating a web service implementation class
            2. Using the JAX-WS reference implementation (GlassFish Metro)
            3. Inspecting WSDL
            4. Implementing a web service using an interface
            5. Consuming a web service using JAX-WS
            6. Specifying an argument name in a web service operation
            7. Inspecting SOAP messages
            8. Handling interfaces in an RPC-style web service
            9. Handling exceptions
        4. Summary
      17. 10. Asynchronous Programming with JMS
        1. Steps to send and receive messages using JMS
        2. Creating queues and topics in GlassFish
        3. Creating a JEE project for a JMS application
        4. Creating a JMS application using JSP and JSP bean
          1. Executing addCourse.jsp
          2. Implementing a JMS queue sender class
          3. Implementing a JMS queue receiver class
            1. Adding multiple queue listeners
          4. Implementing the JMS topic publisher
          5. Implementing the JMS topic subscriber
        5. Creating a JMS application using JSF and managed beans
        6. Consuming JMS messages using MDB
        7. Summary
      18. 11. Java CPU Profiling and Memory Tracking
        1. Creating a sample Java project for profiling
        2. Profiling a Java application
          1. Identifying resource contention
          2. Memory tracking
        3. Eclipse plugins for profiling memory
        4. Summary
      19. Index