44,39 €
Oracle WebLogic server has long been the most important, and most innovative, application server on the market. The updates in the 12c release have seen changes to the Java EE runtime and JDK version, providing developers and administrators more powerful and feature-packed functionalities.
Getting Started with Oracle WebLogic Server 12c: Developer's Guide provides a practical, hands-on, introduction to the application server, helping beginners and intermediate users alike get up to speed with Java EE development, using the Oracle application server.
Starting with an overview of the new features of JDK 7 and Java EE 6, Getting Started with Oracle WebLogic Server 12c quickly moves on to showing you how to set up a WebLogic development environment, by creating a domain and setting it up to deploy the application.
Once set up, we then explain how to use the key components of WebLogic Server, showing you how to apply them using a sample application that is continually developed throughout the chapters. On the way, we'll also be exploring Java EE 6 features such as context injection, persistence layer and transactions.
After the application has been built, you will then learn how to tune its performance with some expert WebLogic Server tips.
Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:
Seitenzahl: 414
Veröffentlichungsjahr: 2013
Copyright © 2013 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: September 2013
Production Reference: 1190913
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-84968-696-9
www.packtpub.com
Cover Image by J.Blaminsky (<[email protected]>)
Authors
Fabio Mazanatti Nunes
William Markito Oliveira
Reviewers
Daniel Amadei
Vinicius Rodrigo dos Santos
Wickes Potgieter
Acquisition Editors
Edward Gordon
Julian Ursell
Lead Technical Editor
Mayur Hule
Technical Editors
Aparna K
Sharvari Baet
Kanhucharan Panda
Copy Editors
Tanvi Gaitonde
Aditya Nair
Alfida Paiva
Kirti Pai
Laxmi Subramanian
Project Coordinators
Arshad Sopariwala
Venitha Cutinho
Proofreaders
Amy Guest
Jonathan Todd
Indexers
Tejal R. Soni
Mariammal Chettiyar
Mehreen Deshmukh
Monica Ajmera Mehta
Graphics
Abhinash Sahu
Sheetal Aute
Production Coordinator
Prachali Bhiwandkar
Cover Work
Prachali Bhiwandkar
Fabio Mazanatti Nunes: With more than two decades of experience in system design and development, Fabio worked in a wide range of projects and architectures (mainframe, client-server, distributed architecture, and SOA) for large corporations in Brazil, and for the last dozen years, he specialized in the architecture and implementation of Java EE and SOA solutions, mainly using BEA and Oracle products. You can find more material related to these topics on his blog, http://mazanatti.info.
I'd like to thank my wife, Valesca, for her constant support and for keeping calm and distracting the little ones while I was focused on writing this book, my kids, Gabriela and Caio, for being such wonderful people and a joy in my life, and my parents, for always being there for us.
A great thank you to my friend and co-author, William, for not letting my acid comments corrode his will to get this book done and for being such a curious and committed individual, raising the bar for everyone who happen to work with him.
I'd also like to thank the technical reviewers of the book, especially my friends Vinicius Santos and Daniel Amadei for accepting this tricky task and for being such nice lads to work with.
Finally, I'd like to mention the honey badger as our role model for this project, because he just takes what he wants, and sometimes in life, that's what we should do—in a positive way, of course!
William Markito Oliveira has more than 15 years of experience in software development, including solution architecture and consulting. For the last few years, he had focused on Service Oriented Architecture (SOA) solutions, Enterprise Application Integration (EAI), and system optimization.
Currently, he is looking into cloud systems with specific focus on in-memory data grid and Java EE. He is also a member of the Java EE Tutorial documentation team, helping with write-ups and code examples about new Java EE technologies and can be reached at Twitter (@william_markito) or through his blog, http://blog.markito.info.
He has authored another book, The Java EE 6 Tutorial: Advanced Topics, Fourth Edition, Addison-Wesley Professional, 978-0-13708-186-8.
I'd like to thank my wife Rebeca, as she was always supportive and encouraged me several times during the writing, helping me by distracting our little man when he tried to type his own words for the book.
Antônio, my son, who also behaved and understood things beyond his age, by letting me write the book while watching Toy Story several times in a row. Love you both more than anything.
Also, a special mention to my family, especially my mother, father, and stepfather. Regina, Antônio, and Vanderlei, thank you for giving me the best and for always being supportive during my night hacks.
Thanks to the reviewers, who prevented us from publishing some silly errors and gave us great ideas on how to write things in a clear way, especially my friend and the best man, Daniel Amadei.
And of course, I'd like to thank the Honey Badger and Fabio, for always being so inspirational and hustler on the way we look at computers and programming in general.
Daniel Amadei is a Senior Principal Consultant working for Oracle Consulting Services in Brazil and has more than 10 years of experience in the IT market, being a specialized consultant and solutions architect for SOA and Enterprise Applications. He has strong analytical and problem-solving abilities with solid experience in the development and architecture of applications.
He is a specialist in SOA and EAI Oracle middleware products, web services and related technologies, and the Java Platform, especially Java EE. He has been working with Java since 1999, and SOA/EAI since 2007, and has, at the time of this book's writing, eight certifications related to his specialties, including Oracle Certified SOA Architect, Oracle SOA Foundation Practitioner, and Sun Certified Enterprise Architect for J2EE.
You can write to him at <[email protected]>, and read about his works at http://www.amadei.com.br.
I'd like to thank the authors for giving me the chance to learn a lot by reviewing the book.
Wickes Potgieter has worked as a product specialist for over 12 years. His main focus was on the BEA WebLogic suite of products, and after the Oracle acquisition of BEA Systems, he focused on the Oracle Fusion Middleware suite of products. His experience ranges from Solution Architecture, Infrastructure Design, administration, development, pre-sales, and training to performance tuning of the Oracle Fusion Middleware products, JVM, and custom applications. He specializes in Oracle WebLogic Server, JRockit, Service Bus, SOA, AIA, BPM, BAM, Enterprise Manager 11g/12c, WebCenter, Identity & Access Management, and Application Performance Management.
They have formed a specialized consulting company in 2003 with offices in the United Kingdom and South Africa, covering customers in the EMEA region. They are in partnership with Oracle Gold and have a team of specialized Oracle Fusion Middleware consultants servicing customers both onsite and offsite.
The website of TSI-Systems is www.tsisystems.co.uk, and Wickes can be contacted on <[email protected]>.
I would like to thank my wife Mary Jane for her patience and for assisting me through all the late nights. Thank you to all my friends and family for constant encouragement.
Vinícius Rodrigo dos Santos has been working on software development since 1999 on high school projects and has developed his career focusing on middleware and EAI ever since.
He has worked for companies as a Software Engineer in South America and North America, creating and maintaining critical systems that served clients around the world.
After dedicating the last 5 years almost exclusively to SOA, he is now focused on multiplatform mobile development and cloud computing solutions.
The solutions he has worked with have served companies mainly focused on Vehicle Engineering, Home Broker, Telecommunications, and the Government.
He now owns a startup named IstyaTech ( http://www.istya.net ) in Brazil that serves customers on mobile and cloud computing solutions.
I would like to thank my parents, my mother Elisabete Brito dos Santos and my father Raimundo Nonato dos Santos, for giving me support in my young years so I could one day participate in a project as satisfying as this one. Of course my special thanks goes to my loving wife Cristiane Danna who has given me strength to carry on; I love you.
You might want to visit www.PacktPub.com for support files and downloads related to your book.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at <[email protected]> for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
http://PacktLib.PacktPub.com
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read and search across Packt's entire library of books.
If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access.
Get notified! Find out when new books are published by following @PacktEnterprise on Twitter, or the Packt Enterprise Facebook page.
Oracle WebLogic Server has been the most innovative and important application server in the market since its conception in 1995. In release 12c, which brings support for Java EE 6 platform and JDK 7, it provides developers and administrators several new and powerful functionalities along with long-awaited improvements to existing features.
With this book you will learn some of the basic WebLogic Server concepts such as domains, managed servers and node managers, and dive into more practical topics such as how to expose and consume web services and how to use and protect JMS queues, exploring Java EE 6 APIs and features such as context dependency injection (CDI), EJB 3.1, JPA 2.1, and others. This is done through an incremental development of a business case, building up a sample application with very detailed steps and screenshots, so readers can follow and apply them to real-world solutions.
Chapter 1, Overview of WebLogic Server 12c and Related Technologies, presents an overview of the latest Java Development Kit (JDK) 7 and Java EE 6 technologies, along with an introduction to the most relevant features of Oracle WebLogic 12c. It also positions WebLogic Server 12c in the Oracle Cloud Application Foundation (CAF) architecture.
Chapter 2, Setting Up the Environment, explains how to install and configure Oracle WebLogic Server and an IDE (Eclipse OEPE), setting them up to be able to develop and run the sample applications we will build throughout the book. We also set up a database (MySQL) and an LDAP Server (OpenLDAP).
Chapter 3, Java EE Basics – Persistence, Query, and Presentation, defines the business case used as a background to the technical features and implementation details that will be covered throughout the remaining chapters, giving an overview of some of the basic features of Java EE and WebLogic Server—how to create and use an optional package, the creation of a web application and a persistence layer project, including how to deploy and do sanity checks on them.
Chapter 4, Creating RESTful Services with JAX-RS, shows how to create and expose an Enterprise JavaBean as a RESTful web service through the usage of JAX-RS annotations, representing the business entities as JSON or XML instances leveraging JAXB parsing.
Chapter 5, Singleton Bean, Validations, and SOAP Web Services, explains the concepts of the validation framework, showing how to use the built-in rules and how to create custom validations. The chapter demonstrates how to persist an entity to the database and the transactional aspects involved in this operation. There is also the development of a JAX-WS service and an example of a Java EE singleton bean.
Chapter 6, Using Events, Interceptors, and Logging Service, shows how to use Java EE interceptors by creating a logging annotation that can be attached to classes or methods, how to publish and observe events by using CDI, how to create and use asynchronous methods on an EJB, and details about the logging services available in WebLogic Server.
Chapter 7, Remote Access with JMS, explains the different modes of remote connection presented by WebLogic Server, creating a standalone Java application to post messages to a JMS Queue and then enhancements to avoid problems when the server is down by keeping the message local using the SAF client.
Chapter 8, Adding Security, covers the basics of the Java EE Security model with step-by-step instructions on how to configure it on a WebLogic server, creating an authentication mechanism using LDAP, and integrating it on the sample application.
Chapter 9, Servlets, Composite Components, and WebSockets, shows how to create and apply reusable web components by applying JSF templates, how to create and test a WebSocket component, and includes a few tips about the new Servlet specification.
Chapter 10, Scaling Up the Application, explains how to create and configure a WebLogic Server cluster using a software load balancer to distribute requests among the servers, how to make session replication more scalable by using Coherence*Web, and how to use the WebLogic Singleton Service.
Chapter 11, Some WebLogic Internals, covers a few features brought by WebLogic Server and Java EE 6 that helps the development process by cutting deployment time, optimizing class redefinitions without the need to restart the whole application, finding classloader issues, and monitoring server resources in a simple way.
The following are the software applications we will use to develop and test the sample applications of this book:
We need to run at least one instance of Oracle WebLogic Server, the development environment, Eclipse with OEPE (Oracle Eclipse Pack for Eclipse), MySQL server, and OpenLDAP. You may be able to run all this on a machine with 2 GB of RAM, but consider at least 4 GB to have a smoother experience.
This book is intended for entry level and intermediate Java EE developers who want to learn how to develop for and use Oracle WebLogic Server by showing how to apply its concepts and features to a real-world scenario. The book is also intended for those who want to learn about the new features of 12c and Java EE 6 releases, and how those updates make things easier and more productive, both at design and runtime.
In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.
Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "You can find the logging configuration file at $JAVA_HOME/jre/lib/logging.properties."
A block of code is set as follows:
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
Any command-line input or output is written as follows:
New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "By clicking on the Print button the selected reservation will be printed."
Warnings or important notes appear in a box like this.
Tips and tricks appear like this.
Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.
To send us general feedback, simply send an e-mail to <[email protected]>, and mention the book title via the subject of your message.
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the erratasubmissionform link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.
Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.
Please contact us at <[email protected]> with a link to the suspected pirated material.
We appreciate your help in protecting our authors, and our ability to bring you valuable content.
You can contact us at <[email protected]> if you are having a problem with any aspect of the book, and we will do our best to address it.
In this chapter, we're going to see some basic information about the subject of this book, including:
Before we get into the new features of Oracle WebLogic Server 12c, let's do a quick recap on how it all started.
In a very brief history of WebLogic, we must remember that it came to Oracle through the acquisition of BEA (Bill, Edward, Alfred). Although the name WebLogic is widely associated with BEA, they didn't create the product.
In fact, WebLogic itself was a company formed in 1995 (same year as BEA) that created a middle-tier server to enhance communication between applets and servers providing implementations for SNMP, JDBC drivers, and ping. This server was named Tengah but also had a codename, T3Server (the three-tier server) and used a custom proprietary network protocol called T3. This server later evolved to be a Java application server as we know today and right after BEA acquired WebLogic (the company) in 1998, Tengah was officially renamed to WebLogic (Version 4.5). Later, BEA acquired a high performance JVM (BEA JRockit, now Oracle JRockit) that was certified against WebLogic and received various performance awards.
The last BEA release of WebLogic Server was Version 10.0, a full Java EE 5 application server.
After BEA's acquisition in 2008, Oracle announced WebLogic as the strategic application server to replace Oracle Application Server (OC4J), and it also became the foundation for Oracle Fusion Middleware and Oracle Fusion Applications, the main families of Oracle products.
The first release under Oracle's brand was WebLogic Server 10gR3 (10.3.0), soon followed by Version 11g. Here's a figure showing all 11g and 12c releases till now:
The focus of this book is WebLogic Sever 12c, which is approximately the eighth release by Oracle and has lots of new and improved features, as shown in the next section.
Here is a list of the most important features of Oracle WebLogic Server 12c Version 12.1.2, the most current version and the focus of this book:
This topic deserves special attention because of the huge impact Java EE 6 made into the way we develop enterprise Java applications by adding new, powerful technologies and features to its specification. Several topics are mentioned here, and most of them will be demonstrated throughout the next chapters:
Under the topic of Java EE 6, we could list and discuss several updates and enhancements in other areas, but that would be out of the scope of this book. We'll be showing examples on most of what we have seen here during the construction of case studies and the main application that will be built along with the book.
To be able to develop the application throughout this book, other products and technologies will be used. A few of them are discussed in the following sections.
Oracle Enterprise Pack for Eclipse (OEPE) is a set of plugins for the Eclipse IDE that enables Java EE application development and leverages the toolset of Oracle specific technologies for Oracle Fusion Middleware.
The following is a list of key features that OEPE supports:
Coherence provides a replicated and distributed data management and caching services, on top of a peer-to-peer clustering protocol, shared across multiple servers but with very high throughput, low response times, and predictable scalability.
In this book we're going to show examples of Coherence*Web, which is an HTTP session management module dedicated to managing the session state in clustered environments. This module integrates with WebLogic Server and provides a pluggable mechanism to scale up Java EE applications, having the benefit of not requiring any application instrumentation or changes to be activated.
PrimeFaces is a popular, free, and open source JSF component suite that provides several extensions and has a rich set of components, including an HTML editor and animated charts. It's very lightweight (only one jar, less than 2 MB) with no required dependencies other than JSF itself, making it a breeze to use and create Java EE web user interfaces.
Since the very early years of the Web, MySQL empowers millions of websites and systems worldwide, being considered the world's most used open source database. It is a relational database system and supports many high profile products such as Wikipedia, Google, Twitter, Facebook, and YouTube.
MySQL offers a huge and rich set of features, but one of the most important features is the cross-platform support. So you can run the same product on Microsoft Windows, GNU/Linux, FreeBSD, or even Apple's OS X.
WebLogic Server is part of Oracle Cloud Application Foundation (CAF), which is defined as a superset of products provided by Oracle that enable the infrastructure for building cloud environments for private or public clouds, hosting end-user applications.
Here's a graphical representation of the CAF stack, followed by a description of each component:
Oracle Traffic Director is a high-speed, layer-7 (the application layer of the OSI Model) load balancer that can be set as the main entry point for HTTP and HTTPS traffic for large volumes, low latency, and mission-critical systems. It is optimized for Oracle Exalogic Elastic Cloud and leverages InfiniBand fabric for more throughput.
It can be configured to do traffic routing and to offload SSL/TLS, acting as the termination point for HTTPS requests, reducing the overhead of security processing on the application server. Also, it can improve performance for clients through content caching and reducing impact on the backend servers.
Oracle Tuxedo runs mission-critical C/C++/COBOL applications in x86 servers or cloud environments, with ultra-high performance and linear scalability. It provides service-oriented infrastructure to manage distributed transaction processing, tracking participants, and monitoring XA two-phase commit, thus, ensuring that transactions are all committed or rolled back properly.
Oracle Virtual Assembly Builder provides an easy way for system administrators to configure new environments of multitier applications in cloud and virtualized environments. It allows drawing blueprint diagrams of the application topology and wire logical connections between the different appliances that compose the architecture.
Oracle Exalogic is an engineered system, which means that it provides the best-of-breed components (storage, compute nodes, network, operating system, and software products) that are tested, tuned, and optimized to deliver extremely high performance. It can be considered as the evolution of Oracle Grid architecture as it moves into a concept of a Private Cloud in a Box platform, ideal for consolidation of mission-critical and cloud systems.
WebLogic 12c is fully supported on Oracle Exalogic and has many enhancements that can be enabled through WebLogic's Administration Console. These enhancements leverage the Exalogic architecture and tune WebLogic Server to perform using the benefits of SDP API, for example.
SDP or Socket Direct Protocol is a low-level network technology that provides higher throughput. It is supported by JDK 7 and can be used for inter-process communication in WebLogic.
Other major features that can be enabled for Exalogic are as follows:
This book will not discuss WebLogic 12c features that are specific to Exalogic systems, but it is important to know what can be accomplished through the use of Oracle-engineered systems.
For further reading about the topics discussed in this chapter, here is a list of links with documentation or tutorials freely available on the Internet.
