Getting Started with Jonas 5

Total Page:16

File Type:pdf, Size:1020Kb

Getting Started with Jonas 5 Getting started with JOnAS 5 JOnAS Team ( Philippe Coq, Guillaume Sauthier) - March 2009 - Copyright © OW2 Consortium 2007-2009 This work is licensed under the Creative Commons Attribution-ShareAlike License. To view a copy of this license,visit http://creativecommons.org/licenses/by-sa/2.0/deed.en or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA. Table of Contents Preface ........................................................................................................................ v 1. First contact with JOnAS 5 ......................................................................................... 1 1.1. How do I set up a JOnAS environment? ............................................................. 1 1.1.1. JONAS_BASE creation ......................................................................... 1 1.2. How can I check if everything is correct? ............................................................ 2 1.2.1. jonas check ......................................................................................... 2 1.3. How can I run a JOnAS server? ........................................................................ 2 1.4. How can I run my first Java EE application? ....................................................... 3 1.5. Understanding how all of this runs out of the box ................................................. 4 1.6. First step in JOnAS administration ..................................................................... 5 2. Learning JOnAS by examples ..................................................................................... 6 2.1. javaee5-earsample example from a 10.000 foot view ............................................. 6 2.1.1. Java EE Technologies in Use ................................................................. 6 2.1.2. javaee5-earsample EAR Sample Architecture ............................................. 7 2.2. javaee5-earsample example detailed ................................................................... 9 2.2.1. JOnAS Server Configuration .................................................................. 9 2.2.2. Data Tier: JPA Entity Beans ................................................................. 10 2.2.3. Business Tier: EJB3 Beans ................................................................... 15 2.2.4. Web Tier: Servlets .............................................................................. 25 2.2.5. Application Clients ............................................................................. 29 2.2.6. EAR ................................................................................................. 38 A. Download and installation instructions ........................................................................ 39 A.1. Where can I find JOnAS? .............................................................................. 39 A.2. How can I download JOnAS? ......................................................................... 39 A.3. How can I install JOnAS? .............................................................................. 39 A.4. Pre-requisites ............................................................................................... 39 B. JOnAS 5 distribution description ............................................................................... 41 B.1. JONAS_ROOT structure ................................................................................ 41 C. Glossary ................................................................................................................ 43 JOnAS 5 ii List of Figures 2.1. javaee5-earsample Sample Architecture ...................................................................... 8 2.2. Author and Book JPA Model .................................................................................. 10 JOnAS 5 iii List of Examples 2.1. JPA Entity: META-INF/persistence.xml .................................................................... 15 2.2. Stateless Session Bean: Reader Business Interface ....................................................... 16 2.3. Stateless Session Bean: Writer business Interface ........................................................ 18 2.4. Stateless Session Bean: Mailer Business Interface ....................................................... 20 2.5. An example of e-mail ............................................................................................ 30 2.6. META-INF/application-client.xml ............................................................................ 33 2.7. META-INF/jonas-client.xml .................................................................................... 33 2.8. jaas.config ........................................................................................................... 33 2.9. META-INF/application-client.xml ............................................................................ 36 2.10. META-INF/jonas-client.xml .................................................................................. 36 JOnAS 5 iv Preface Welcome new users of JOnAS ! This guide is intended to help you. Chapter 1, First contact with JOnAS 5 shows that a downloaded JOnAS 5 is usable as is. The environment to set is truly minimal. It's child's play to run a Java EE application. This chapter shows not only how to perform some actions but also explains why everything runs so easily. JOnAS 5 is distributed with examples ready to use. Users can learn a lot by studying these examples Chapter 2, Learning JOnAS by examples Theses examples may be used as a tutorial for Java EE 5 technology. They are using the simplified programming model, dependency injection, Java Persistence API, security and other functionalities available in Java EE 5. Note that this guide wants to be simple and is not intended to resolve all problems that can be encountered in real life situtations, which can be very complex. For more experimented users that need to perform more complex tasks, we recommend taking a look at the JOnAS 5 Configuration guide [configuration_guide.html] Appendix A, Download and installation instructions summarizes downloading and installing JOnAS. Appendix B, JOnAS 5 distribution description describes what you get when you download and install JOnAS. JOnAS 5 v Chapter 1. First contact with JOnAS 5 It is assumed, in this guide, that the first time user has already downloaded and installed JOnAS 5. If this is not the case, please refer to Appendix A, Download and installation instructions. In this chapter an unexperienced user will learn how to run an existing Java EE application with JOnAS. He will understand why it is so easy to achieve such results with nearly zero configuration. 1.1. How do I set up a JOnAS environment? Once you have installed your JOnAS distribution, you have to set up the JONAS_ROOT environment variable prior to using JOnAS or any of its tools. You will also have to update your PATH variable. • Unix platforms Open a new terminal and proceed as follows: bash> export JONAS_ROOT=<your_install_dir> bash> export PATH=${PATH}:${JONAS_ROOT}/bin or • Windows platforms Open a new DOS window and proceed as follows: C:> set JONAS_ROOT=<your_install_dir> C:> set PATH=%PATH%;%JONAS_ROOT%\bin To update the path permanently, do the following depending upon your Windows version: Windows XP Go to the Start Menu, then double click on System. In the System Control Panel select the Advanced tab and push the Environment Variables button. Now, you can look for the PATH to edit. Append the value ;C:\jonas-5.x\bin (assuming that you installed JOnAS in the C:\jonas-5.x directory). JOnAS distribution contains a number of configuration files in $JONAS_ROOT/conf directory. These files can be edited to change the default configuration. However, it is recommended to put the configuration files needed by a specific application running on JOnAS in a separate location. This is done by using an additional environment variable called JONAS_BASE. 1.1.1. JONAS_BASE creation 1. To create a JONAS_BASE template from scratch : Unix export JONAS_BASE=~/my_jonas_base cd $JONAS_ROOT/templates/newjb ant -f build-jb.xml create_jonas_base Windows set JONAS_BASE=my_jonas_base cd %JONAS_ROOT%/templates/newjb ant -f build-jb.xml create_jonas_base This will copy all the required files and create all the needed directories. 2. Another way to create a JONAS_BASE template from scratch : JOnAS 5 1 First contact with JOnAS 5 $JONAS_ROOT/bin must be set in the system path: Unix export JONAS_BASE=~/my_jonas_base newjb Windows set JONAS_BASE=my_jonas_base newjb The JONAS_BASE content created with the newjb command is well suited to run the JOnAS JEE conformance test suite and the example applications without any additional configuration. In order to customize a JONAS_BASE with specific property values (port numbers, services, protocols etc...), you must edit the $JONAS_ROOT/templates/newjb/build- jb.properties file or $HOME/jb.config/conf/jonas-newjb.properties file before running newjb. For further customization that cannot be performed by newjb you should modify the generated files in $JONAS_BASE/conf. For more information see the description of the newjb command in Commands Reference Guide [./command_guide.html#commands.newjb]. 1.2. How can I check if everything is correct? JOnAS provides the command jonas check that checks if your environment is set correctly. 1.2.1. jonas check Command allowing to check that the JOnAS environment is correctly set . 1.2.1.1. Synopsis jonas check [-help]
Recommended publications
  • Jonas 5 Configuration Guide
    JOnAS 5 Configuration guide JOnAS Team ( ) - September 2009 - Copyright © OW2 Consortium 2007-2009 This work is licensed under the Creative Commons Attribution-ShareAlike License. To view a copy of this license,visit http://creativecommons.org/licenses/by-sa/2.0/deed.en or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA. Table of Contents 1. Introduction .............................................................................................................. 1 1.1. Configuring JOnAS ......................................................................................... 1 1.2. Terminology .................................................................................................. 1 1.2.1. Server or JOnAS instance ...................................................................... 1 1.2.2. Service ............................................................................................... 1 1.2.3. Container ............................................................................................ 1 1.2.4. Domain .............................................................................................. 1 1.2.5. Master server ....................................................................................... 2 1.2.6. Cluster ................................................................................................ 2 2. Configuring a JOnAS instance ..................................................................................... 3 2.1. Configuring JOnAS Environment
    [Show full text]
  • 9. Platforms – Java ME and Osgi
    Department of Computer Science Institute for System Architecture, Chair for Computer Networks Application Development for Mobile and Ubiquitous Computing 9. Platforms – Java ME and OSGi Dr. Ing. Thomas Springer Technische Universität Dresden Chair of Computer Networks JAVA MICRO EDITION Java Micro Edition - Overview Creation of Stand-alone applications for resource limited devices • Native programming limits portability and reusability • Java is a widely deployed platform • supports portability and reusability • issues with resource-limited devices for Java SE Sun divides today the Java-technology into 3 domains: • Java SE (Standard Edition) ⇨ Desktop applications • Java ME (Micro Edition) ⇨ Resource restricted systems • Java EE (Enterprise Edition) ⇨ Server-side solution Goals of Java ME • Portability of applications for large range of resource-limited devices • same (Java) programming model • Comfortable development of applications for mobile devices Fast growing distribution of Java Micro Edition • Number of Java ME-enabled mobile phones: o 2002: 31 Mio. o 2003: 88 Mio. o 2008: 592 Mio. (prognosis) Dr. Thomas Springer Application Development - Lecture 9. Platforms - Java ME and OSGi 3 Application Domains of Java ME Designed for devices with restrictions concerning processor power, memory, display size and networking capabilities Heterogeneous requirements for Java ME devices • Personal, mobile, networked devices o Mobile phones, PDA`s, Smart phones, pagers o Characteristics:• Simple User Interfaces • Memory capacity: 128 – 512 kb • Wireless network connection (low bandwidth) • Commonly used, stationary, networked devices o Set-Top-Boxes, video-phones, entertainment and navigation systems… o Characteristics:• More complex user interfaces • Memory capacity: 2 – 16 MB • Broadband network connection over TCP/IP Dr. Thomas Springer Application Development - Lecture 9.
    [Show full text]
  • Full-Graph-Limited-Mvn-Deps.Pdf
    org.jboss.cl.jboss-cl-2.0.9.GA org.jboss.cl.jboss-cl-parent-2.2.1.GA org.jboss.cl.jboss-classloader-N/A org.jboss.cl.jboss-classloading-vfs-N/A org.jboss.cl.jboss-classloading-N/A org.primefaces.extensions.master-pom-1.0.0 org.sonatype.mercury.mercury-mp3-1.0-alpha-1 org.primefaces.themes.overcast-${primefaces.theme.version} org.primefaces.themes.dark-hive-${primefaces.theme.version}org.primefaces.themes.humanity-${primefaces.theme.version}org.primefaces.themes.le-frog-${primefaces.theme.version} org.primefaces.themes.south-street-${primefaces.theme.version}org.primefaces.themes.sunny-${primefaces.theme.version}org.primefaces.themes.hot-sneaks-${primefaces.theme.version}org.primefaces.themes.cupertino-${primefaces.theme.version} org.primefaces.themes.trontastic-${primefaces.theme.version}org.primefaces.themes.excite-bike-${primefaces.theme.version} org.apache.maven.mercury.mercury-external-N/A org.primefaces.themes.redmond-${primefaces.theme.version}org.primefaces.themes.afterwork-${primefaces.theme.version}org.primefaces.themes.glass-x-${primefaces.theme.version}org.primefaces.themes.home-${primefaces.theme.version} org.primefaces.themes.black-tie-${primefaces.theme.version}org.primefaces.themes.eggplant-${primefaces.theme.version} org.apache.maven.mercury.mercury-repo-remote-m2-N/Aorg.apache.maven.mercury.mercury-md-sat-N/A org.primefaces.themes.ui-lightness-${primefaces.theme.version}org.primefaces.themes.midnight-${primefaces.theme.version}org.primefaces.themes.mint-choc-${primefaces.theme.version}org.primefaces.themes.afternoon-${primefaces.theme.version}org.primefaces.themes.dot-luv-${primefaces.theme.version}org.primefaces.themes.smoothness-${primefaces.theme.version}org.primefaces.themes.swanky-purse-${primefaces.theme.version}
    [Show full text]
  • EJB 3 in Action by Debu Panda Reza Rahman Ryan Cuprak Michael Remijan
    S AMPLE CHAPTER MANNING SECOND EDITION Debu Panda Reza Rahman Ryan Cuprak Michael Remijan EJB 3 in Action by Debu Panda Reza Rahman Ryan Cuprak Michael Remijan Chapter 1 Copyright 2014 Manning Publications brief contents PART 1OVERVIEW OF THE EJB LANDSCAPE................................1 1 ■ What’s what in EJB 3 3 2 ■ A first taste of EJB 25 PART 2WORKING WITH EJB COMPONENTS ..............................47 3 ■ Building business logic with session beans 49 4 ■ Messaging and developing MDBs 93 5 ■ EJB runtime context, dependency injection, and crosscutting logic 117 6 ■ Transactions and security 160 7 ■ Scheduling and timers 196 8 ■ Exposing EJBs as web services 214 PART 3USING EJB WITH JPA AND CDI .................................251 9 ■ JPA entities 253 10 ■ Managing entities 294 11 ■ JPQL 321 12 ■ Using CDI with EJB 3 359 v vi BRIEF CONTENTS PART 4PUTTING EJB INTO ACTION.......................................395 13 ■ Packaging EJB 3 applications 397 14 ■ Using WebSockets with EJB 3 427 15 ■ Testing and EJB 458 What’s what in EJB 3 This chapter covers ■ The EJB container and its role in Enterprise applications ■ The different types of Enterprise Java Beans (EJBs) ■ Closely related technologies such as the Java Persistence API (JPA) ■ The different EJB runtime environments ■ Innovations started with EJB 3 ■ New changes with EJB 3.2 One day, when God was looking over his creatures, he noticed a boy named Sadhu whose humor and cleverness pleased him. God felt generous that day and granted Sadhu three wishes. Sadhu asked for three reincarnations—one as a ladybug, one as an elephant, and the last as a cow.
    [Show full text]
  • The Glassfish Community Delivering a Java EE Application Server
    The GlassFish Community: An Overview The GlassFish Community Delivering a Java EE Application Server Eduardo Pelegri-Llopart Yutaka Yoshida Alexis Moussine-Pouchkine Sun Microsystems, Inc. http://blogs.sun.com/theaquarium Last Updated September 2007 The GlassFish Community 1 At JavaOne 2005, Sun announced Project GlassFish, an initiative to open source its Application Server and the Java EE Reference Implementation (see inset: Project GlassFish). This was the first step of open sourcing all the Java platform, but it also had other effects. Project GlassFish Project GlassFish accelerated the adoption of Java EE 5, added a new enterprise-quality App Server Sun launched Project GlassFish to the options available to the Open Source in June 2005, during JavaOne, to community, and has lead to a Open Source the Reference transformation of how Sun's AppServer is Implementation for Java EE 5 and developed, tested, made available, and Sun's Application Server. evolved, in the process creating a much The first release followed less better product. than a year after, at JavaOne 2006 A year and a half after the initial launch, the (May 2006). GlassFish community has already delivered The second release was released its first final release and is on its way to its in September 2007. second. In this article we will provide an overview of all the aspects of the GlassFish The focus is now on GlassFish v3, Community and the GlassFish AppServer. the modular and lightweight application server (see HK2). What is GlassFish GlassFish is a Community and an Application Server. The community's main deliverables are a Java EE 5 compatible Application Server, the GlassFish AppServer, and the Reference Implementation for the Java Persistence API, TopLink Essentials.
    [Show full text]
  • Service Coroner: a Diagnostic Tool for Locating Osgi Stale References
    Service Coroner: A Diagnostic Tool for Locating OSGi Stale References Kiev Gama and Didier Donsez University of Grenoble, LIG laboratory, ADELE team {firstname.lastname}@imag.fr Abstract Moreover, the OSGi specification applies service- The OSGi Services Platform provides a framework oriented architecture principles to Java application for the dynamic deployment of Java-based design. The concept of service is important to decouple applications. It allows to install, to activate, to update the application modules in order to dynamically and to uninstall application modules without the need substitute or update individual modules without to restart the host Java Virtual Machine. However, the affecting the entire system. mishandling of such OSGi dynamics may result in a The OSGi has proved to be successful in embedded problem described in the OSGi specification as Stale systems. Its adoption in the software industry is References, which happen when services from continuously growing as more applications tend to take uninstalled modules are still referenced by active code. advantage of its pluggable architecture. One of the well It may lead to inconsistencies in application’s known cases is the Eclipse project [2] that since behavior, state and memory. Currently, there are no version 3.0 has migrated to the OSGi platform. A new tools available to address this issue. This paper trend in desktop applications [2] and server presents a diagnostics tool named ServiceCoroner that middlewares [3] (i.e., JOnAS, Weblogic, WebSphere) detects such problems. It helps developers and shows the growing adoption of OSGi as a modular administrators diagnose OSGi applications running layer for either commercial or open-source Java-based either in production or test environments.
    [Show full text]
  • Unit Test Virtualization with VMVM
    Unit Test Virtualization with VMVM Jonathan Bell Gail Kaiser Columbia University Columbia University 500 West 120th St, MC 0401 500 West 120th St, MC 0401 New York, NY USA New York, NY USA [email protected] [email protected] ABSTRACT by the test suite. These tests are added to existing unit test Testing large software packages can become very time in- suites and in an ideal continuous integration environment, tensive. To address this problem, researchers have inves- executed regularly (e.g., upon code check-ins, or nightly). tigated techniques such as Test Suite Minimization. Test Because developers are often creating new tests, as software Suite Minimization reduces the number of tests in a suite grows in size and complexity, its test suite frequently grows by removing tests that appear redundant, at the risk of a similarly. Software can reach a point where its test suite has reduction in fault-finding ability since it can be difficult to gotten so large that it takes too long to regularly execute identify which tests are truly redundant. We take a com- | previous work has reported test suites in industry taking pletely different approach to solving the same problem of several weeks to execute fully [36]. long running test suites by instead reducing the time needed To cope with long running test suites, testers might turn to execute each test, an approach that we call Unit Test to Test Suite Minimization or Test Suite Prioritization [43]. Virtualization. With Unit Test Virtualization, we reduce Test Suite Minimization techniques such as [14, 15, 22, 23, the overhead of isolating each unit test with a lightweight 27, 28, 38, 41] seek to reduce the total number of tests to virtualization container.
    [Show full text]
  • Extending an Open Source Enterprise Service Bus for Multi-Tenancy Support Focusing on Administration and Management
    Institute of Architecture of Application Systems University of Stuttgart Universitätsstraße 38 D-70569 Stuttgart Diplomarbeit Nr. 3226 Extending an Open Source Enterprise Service Bus for Multi-Tenancy Support Focusing on Administration and Management Dominik Muhler Course of Study: Software Engineering Examiner: Prof. Dr. Frank Leymann Supervisor: Dipl.-Inf. Steve Strauch Dipl.-Inf. Tobias Binz Commenced: July 28, 2011 Completed: January 27, 2012 CR-Classification: C.2.4, D.2.11, H.2.1, H.3.4 Abstract As part of cloud computing, the service model Platform-as-a-Service (PaaS) has emerged, where customers can develop and host internet-scale applications on cloud infrastructure. The Enterprise Service Bus (ESB) is one possible building block of a PaaS offering, providing integration capabilities for service-oriented architectures. Bringing the ESB to the cloud requires scalability and multi-tenancy support. When applied, these characteristics lead to economies of scale, reducing the costs per customer. In this diploma thesis we specify, design, and implement a multi-tenant management ap- plication for an existing open source ESB. The management application grants tenant users limited configuration access to the ESB’s connectivity and integration services. A tenant registry and a service registry serve as platform-wide databases. We ensure data isolation between tenants for the management application and ESB message flows. Furthermore, the management application can control clusters of ESB instances, retaining elasticity. These goals also involve extensions to the ESB itself, which implements the Java Business Integration (JBI) specification. As a result, an integration scenario emerged from the EU-funded project 4CaaSt was applied to the system.
    [Show full text]
  • Multitenancy Guide
    Multitenancy Guide JOnAS Team () - Jun 2012 - Copyright © OW2 Consortium 2012 This work is licensed under the Creative Commons Attribution-ShareAlike License. To view a copy of this license,visit http://creativecommons.org/licenses/by-sa/2.0/deed.en or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA. Table of Contents 1. Introduction .............................................................................................................. 1 1.1. Multitenancy .................................................................................................. 1 1.2. Shared application server ................................................................................. 1 2. Tenant context .......................................................................................................... 2 3. Customization ........................................................................................................... 3 3.1. Context root customization ............................................................................... 3 3.2. Data isolation in database ................................................................................. 3 3.3. JNDI names customization ............................................................................... 4 3.4. MBeans customization ..................................................................................... 5 3.5. Tenants administration isolation ......................................................................... 6 3.6. Logs customization
    [Show full text]
  • EJB 3.0 Programmer's Guide
    EJB 3.0 Programmer's Guide (Florent BENOIT) - March 2009 - Copyright © OW2 Consortium 2008-2009 This work is licensed under the Creative Commons Attribution-ShareAlike License. To view a copy of this license,visit http://creativecommons.org/licenses/by-sa/2.0/deed.en or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA. Table of Contents 1. Introduction to EJB3 .................................................................................................. 1 1.1. Overview ....................................................................................................... 1 1.2. The Advantage of EJB3 ................................................................................... 1 1.3. EJB2 vs EJB3: EoD ........................................................................................ 1 1.4. New Features ................................................................................................. 2 1.4.1. Metadata Annotations ............................................................................ 2 1.4.2. Business Interceptors ............................................................................. 2 1.4.3. Lifecycle Interceptors ............................................................................ 2 1.4.4. Dependency Injection ............................................................................ 2 1.4.5. Persistence .......................................................................................... 2 2. Writing a HelloWorld Bean .......................................................................................
    [Show full text]
  • Easybeans Developer's Guide
    EasyBeans Developer's guide Florent BENOIT, OW2 consortium EasyBeans Developer's guide by Florent BENOIT Published $Id: developerguide.xml 216 2006-03-16 19:01:07Z benoitf $ Copyright © 2006-2008 OW2 Consortium Abstract The EasyBeans developer guide is intended for developers wanting to work with the source distribution of EasyBeans. People wanted to contribute to EasyBeans should read this documentation. This work is licensed under the Creative Commons Attribution-ShareAlike License. To view a copy of this license,visit http:// creativecommons.org/licenses/by-sa/2.0/deed.en [http://creativecommons.org/licenses/by/2.0/] or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA. Table of Contents 1. Building EasyBeans From Source. ................................................................................ 1 1.1. Requirements ................................................................................................. 1 1.1.1. JDK ................................................................................................... 1 1.1.2. Maven ................................................................................................ 1 1.1.3. Ant .................................................................................................... 1 1.1.4. TestNG ............................................................................................... 1 1.1.5. Clover ................................................................................................ 1 1.2. Optional Requirements
    [Show full text]
  • Java Open Application Server (Jonas): a J2EETM Platform
    Java Open Application Server (JOnAS): a J2EETM Platform Last modified at 2006−11−30, JOnAS 4.8 This document provides an overview of the JOnAS platform. The content of this document is the following: • Introduction ♦ J2EE ♦ ObjectWeb • JOnAS Features ♦ System Requirements ♦ Java Standard Conformance ♦ Key Features ♦ JOnAS Packages • JOnAS Architecture ♦ Communication and Naming service ♦ EJB Container service ♦ WEB Container service ♦ Ear service ♦ Transaction service ♦ Database service ♦ Security service ♦ Messaging service ♦ JCA Resources service ♦ Management service ♦ Mail service ♦ WebServices service ♦ HA service • JOnAS Development and Deployment Environment ♦ JOnAS Configuration and Deployment Facilities ♦ JOnAS Development Environments • Clustering and Performance • Perspectives Introduction Java Open Application Server (JOnAS): a J2EETM Platform 1 Java Open Application Server (JOnAS): a J2EETM Platform J2EE The SunTM J2EE specification, together with its related specifications ( EJBTM, JMSTM,...), defines an architecture and interfaces for developing and deploying distributed Internet JavaTM server applications based on a multi−tier architecture. This specification intends to facilitate and standardize the development, deployment, and assembling of application components; such components will be deployable on J2EE platforms. The resulting applications are typically web−based, transactional, database−oriented, multi−user, secured, scalable, and portable. More precisely, this specification describes two kinds of information: • The
    [Show full text]