Book Image

JBoss AS 7 Development - Second Edition

By : Francesco Marchioni
Book Image

JBoss AS 7 Development - Second Edition

By: Francesco Marchioni

Overview of this book

JBoss Application Server meets high standards of reliability, efficiency, and robustness, and is used to build powerful and secure Java EE applications. It supports the most important areas of Java Enterprise programming including EJB 3.1, Contexts and Dependency Injection, JAX-WS and JAX-RS web services, the security framework, and more. Getting started with JBoss application server development can be challenging; however, with the right approach and guidance, you can easily master it and this book promises that.Written in an easy-to-read style, this book will take you from the basics of JBoss AS—such as installing core components and plugins—to the skills that will make you a JBoss developer to be reckoned with, covering advanced topics such as developing applications with the JBoss messaging service, JBoss web services, clustered applications, and more.You will learn the necessary steps to install a suitable environment for developing enterprise applications on JBoss AS. You will also learn how to design Enterprise applications using Eclipse, JBoss plugins, and Maven to build and deploy your applications. Readers will learn how to enable distributed communication using JMS. Storing and retrieving objects will be made easier using the Java Persistence API. The core section of the book will take you into the programming arena with tested, real-world examples. The example programs have been carefully crafted to be easy to understand and useful as starting points for your applications. This practical guide will show you how to gain hands-on experience rapidly on Java EE development using JBoss AS with easy-to-understand and practical programming examples.
Table of Contents (19 chapters)
JBoss AS 7 Development
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Configuring persistence


The Entity API looks great and very intuitive, but how does the server know which database is supposed to store/query the entity objects? The persistence.xml file, which will be placed under src/main/resources/META-INF of your project, is the standard JPA configuration file. By configuring this file, you can easily switch from one persistence provider to another and thus also from one application server to another (believe it, this is a huge leap towards application server compatibility).

In the persistence.xml file we will basically need to specify the persistence provider and the underlying data source used.

<persistence version="2.0"
  xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="
        http://java.sun.com/xml/ns/persistence
        http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
  <persistence-unit name="primary">
    <jta-data-source> java:jboss/datasources...