Java EE 8 Development with Eclipse

Book description

Develop and deploy fully functional applications and microservices utilising Tomcat, Glassfish servers, Cloud and docker in Java EE 8

About This Book
  • Explore the complete workflow of developing enterprise Java applications
  • Develop microservices with Docker Container and deploy it in cloud
  • Simplify Java EE application development
Who This Book Is For

If you are a Java developer with little or no experience in Java EE application development, or if you have experience in Java EE 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 servers for Java EE application development
  • Use JSP, Servlet, JSF, and EJBs to create a user interface and write business logic
  • Create Java EE database applications using JDBC and JPA
  • Handle asynchronous messages using MDBs for better scalability
  • Deploy and debug Java EE applications and create SOAP and REST web services
  • Write unit tests and calculate code coverage
  • Use Eclipse MAT (Memory Analysis Tool) to debug memory issues
  • Create and deploy microservices
In Detail

Java EE is one of the most popular tools for enterprise application design and development. With recent changes to Java EE 8 specifications, Java EE application development has become a lot simpler with the new specifications, some of which compete with the existing specifications. This guide provides a complete overview of developing highly performant, robust and secure enterprise applications with Java EE with Eclipse.

The book begins by exploring different Java EE technologies and how to use them (JSP, JSF, JPA, JDBC, EJB, and more), along with suitable technologies for different scenarios. You will learn how to set up the development environment for Java EE applications and understand Java EE specifications in detail, with an emphasis on examples. The book takes you through deployment of an application in Tomcat, GlassFish Servers, and also in the cloud. It goes beyond the basics and covers topics like debugging, testing, deployment, and securing your Java EE applications. You'll also get to know techniques to develop cloud-ready microservices in Java EE.

Style and approach

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

Table of contents

  1. Title Page
  2. Copyright and Credits
    1. Java EE 8 Development with Eclipse Third Edition
  3. Dedication
  4. Packt Upsell
    1. Why subscribe?
    2. PacktPub.com
  5. Introducing JEE and Eclipse
    1. JEE
      1. The presentation layer
        1. Java Servlets
        2. JavaServer Pages
        3. JavaServer Faces
      2. The business layer
        1. Enterprise JavaBeans
      3. The enterprise integration layer
        1. Java Database Connectivity 
        2. The Java Persistence API
        3. Java Connector Architecture
        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
      2. Installing the Tomcat server
      3. Installing the GlassFish server
      4. Installing MySQL
        1. Installing MySQL on Windows
        2. Installing MySQL on macOS X
        3. Installing MySQL on Linux
        4. Creating MySQL users
    3. Summary
  6. Creating a Simple JEE Web Application
    1. Configuring Tomcat in Eclipse
    2. JavaServer Pages
      1. Creating a dynamic web project
      2. Creating JSP
      3. Running JSP in Tomcat
      4. Using JavaBeans in JSP
      5. Using JSTL
    3. Java Servlet
    4. Creating WAR
    5. JavaServer 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. Maven project structure
      6. Creating a WAR file using Maven
    7. Summary
  7. Source Control Management in Eclipse
    1. The Eclipse subversion plugin
      1. Installing the Eclipse Subversion plugin
      2. Adding projects 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. Eclipse Git plugin
      1. Adding a project to Git
      2. Committing files in the Git repository
      3. Viewing file differences 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
  8. Creating JEE Database Applications
    1. Creating database schema
      1. Script to create 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 database connections
        2. Executing SQL statements
        3. Handling transactions
      5. Using a JDBC database connection pool
      6. Saving courses in database tables using JDBC
      7. Getting courses from database tables using JDBC
      8. Completing add course functionality
      9. Using Eclipse Data Source Explorer
    3. Creating database applications using JPA
      1. Creating user interfaces for adding courses 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 many-to-one relationships
        2. Configuring many-to-many relationships
      9. Creating database tables from entities
      10. Using JPA APIs to manage data
      11. Wiring user interface with JPA service classes
    4. Summary
  9. Unit Testing
    1. Introducing JUnit
    2. Creating and executing unit tests using Eclipse JEE
      1. Creating unit test cases
      2. Running unit test cases
        1. Running unit test cases using Maven
    3. Mocking external dependencies for unit tests
      1. Using Mockito
    4. Calculating unit test coverage
    5. Summary
  10. Debugging the 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 the 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 the debugger to know the status of program execution
    5. Summary
  11. Creating JEE Applications with EJB
    1. Types of EJB
      1. Session beans
        1. Stateful session beans
        2. Stateless session beans
        3. Singleton session beans
      2. Accessing session beans from a client
        1. Creating a no-interface session bean
        2. Accessing session beans using dependency injection
        3. Creating session beans using local business interface
        4. Accessing session beans using JNDI lookup
        5. Creating session beans using remote business interface
        6. Accessing remote session beans
    2. Configuring the GlassFish Server in Eclipse
    3. Creating a Course Management application using EJB
      1. Creating EJB projects in Eclipse
      2. Configuring datasources in GlassFish
      3. Configuring JPA in an Eclipse project
      4. Creating a JPA entity
      5. Creating stateless EJB
      6. Creating JSF and managed beans
      7. Running the example
      8. Creating EAR for deployment outside Eclipse
    4. Creating a JEE project using Maven
    5. Summary
  12. Creating Web Applications with Spring MVC
    1. Dependency injection
    2. Dependency injection in Spring
      1. Component scopes
    3. Installing 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. Building the Spring MVC application using JDBC
        1. Configuring a datasource
        2. Using the Spring JDBCTemplate class
        3. Creating the Spring MVC Controller
        4. Creating View
        5. Mapping data using @ModelAttribute
        6. Using parameters in @RequestMapping
        7. Using Spring interceptors
      3. Spring MVC application using JPA
        1. Configuring JPA
        2. Creating the Course entity
        3. Creating CourseDAO and Controller
        4. Creating the course list view
    5. Summary
  13. Creating Web Services
    1. What is a web service?
    2. JAXB
      1. A JAXB example
    3. JSON-B
      1. A JSON-B example
    4. RESTful web services
      1. Creating RESTful web services using Jersey
      2. Implementing a REST GET request
      3. Testing the REST GET request in the browser
      4. Creating a Java client for the REST GET web service
      5. Implementing a REST POST request
      6. Writing a Java client for the REST POST web service
      7. Invoking a POST RESTful web service from JavaScript
      8. Creating a RESTful web service with form POST
      9. Creating a Java client for a form-encoded RESTful web service
      10. A RESTful web service using JSON-B
    5. SOAP web services
      1. SOAP
      2. WSDL
      3. UDDI
      4. Developing web services in Java
        1. Creating a web service implementation class
        2. Using 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 RPC-style web services
        9. Handling exceptions
    6. Summary
  14. Asynchronous Programming with JMS
    1. Steps to send and receive messages using JMS
    2. Creating queues and topics in GlassFish
    3. Creating JEE project for a JMS application
    4. Creating JMS application using JSP and JSP bean
      1. Executing addCourse.jsp
      2. Implementing JMS queue sender class
      3. Implementing JMS queue receiver class
        1. Adding multiple queue listeners
      4. Implementing JMS topic publisher
      5. Implementing JMS topic subscriber
    5. Creating JMS application using JSF and CDI beans
    6. Consuming JMS messages using MDBs
    7. Summary
  15. Java CPU Profiling and Memory Tracking
    1. Creating a sample Java project for profiling
    2. Profiling the Java application
      1. Identifying resource contention
      2. Memory tracking
    3. Eclipse plugins for profiling memory
    4. Summary
  16. Microservices
    1. What is a microservice?
    2. Eclipse MicroProfile
    3. Setting up a database for a microservice project
    4. Implementing microservices using WildFly Swarm
      1. Creating a WildFly Swarm project
      2. Configuring JPA
      3. Creating a course entity bean and a JPA factory
    5. Implementing microservices using Spring Boot
    6. Deploying microservices in a Docker container
      1. What is Docker?
      2. How to get Docker
      3. How to use Docker
        1. Dockerfile
        2. Docker commands
      4. Setting up Docker Tooling in Eclipse
      5. Creating a Docker network
      6. Creating MySQL container
      7. Deploying microservices in a Docker container
    7. Running containers using Docker Compose
    8. Summary
  17. Deploying JEE Applications in the Cloud
    1. Deploying in the cloud
    2. Deploying in AWS Cloud
      1. Creating the user group and user
      2. Installing the AWS Toolkit for Eclipse
      3. Launching the EC2 instance
      4. Installing the CourseManagement EJB application in the EC2 instance
        1. Installing the GlassFish 5 Server
        2. Installing the MySQL server
        3. Configuring the datasource in the GlassFish 5 Server
      5. Installing the CourseManagmenet REST service using Elastic Beanstalk
        1. Creating Elastic Beanstalk application from Eclipse
    3. Deploying in Google Cloud
      1. Setting up Google Cloud Tools
        1. Installing the Google Cloud SDK
        2. Installing Java extensions for the App Engine SDK
        3. Installing Google Cloud Tools for Eclipse
        4. Setting Eclipse Preferences for Google Cloud Tools
      2. Deploying the application in Google Compute Engine
        1. Creating a VM instance in Google Compute Engine
        2. Installing Docker in a VM instance
      3. Deploying the application in Google App Engine
    4. Summary
  18. Securing JEE Applications
    1. Authentication and authorization in JEE
    2. Modifying a database to save authentication information
    3. Securing applications in GlassFish
      1. Protecting access to folders in web applications
      2. Configuring a JDBC realm in GlassFish
      3. Basic authentication with the JDBC realm in GlassFish
      4. Form-based authentication with a JDBC realm in GlassFish
    4. Securing applications in Tomcat
    5. Securing servlets using annotations
    6. Securing web services
    7. Security enhancements in JEE 8
      1. Implementing portable security in JEE 8
    8. Summary
  19. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think

Product information

  • Title: Java EE 8 Development with Eclipse
  • Author(s): Ram Kulkarni
  • Release date: June 2018
  • Publisher(s): Packt Publishing
  • ISBN: 9781788833776