Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
title
Warning
Note
Warning

This document and the related feature is a work in progressconsidered a prototype and will change based on user feedback. All comments suggestions welcome.

Introduction

The OpenEJB Spring integration makes all Spring defined beans injectable to JEE components, and all JEE components can be injected to Spring beans. The injection system supports arbitrarily complex nesting (e.g., Spring bean injected into a JEE component, which is then injected into another Spring bean), including:

  • @Resouce injection of any Spring bean into EJB
  • Injection of any JEE resource into a Spring bean, including:
    • EJB 3.0 beans
    • EJB 3.1 Singleton Bean
    • JPA Persistence Context
    • JDBC Connector
    • JMS Connector
    • JMS Queue and Topic
    • Generic JEE Connector (JCA)
    • UserTransaction
    • JavaMail

In addition, the OpenEJB Spring integration add support for discovery and deployment of standard JEE packages within a Spring context, including:

...

  • OpenEJB 3.1+
  • Spring X.X
  • Java 1.5 or 1.6

...

Spring Beans

The following beans are usable in any spring xml file.

Class

Description

org.apache.openejb.spring.ClassPathApplication

Scrapes the classpath for all EJB, RAR, and Persistence applications, deploys them, and imports them into the current ApplicationContext. All applications found are treated as one big EAR unless the classpathAsEar property is set to false

org.apache.openejb.spring.Application

Scrapes an individual jar file for EJB, RAR, and Persistence applications, deploys them, and imports them into the current ApplicationContext. The 'jarFile' property is required. The application is treated as it's own self-contained EAR, separate from other uses of 'Application'

org.apache.openejb.spring.Resource

Allows an OpenEJB <Resource> to be declared in the Spring ApplicationContext

org.apache.openejb.spring.OpenEJBResource

A FactoryBean that imports a Resource from OpenEJB into the Spring ApplicationContext. Has the following properties: type such as javax.sql.DataSource, and resourceId. In the future this bean will not be required and all OpenEJB Resources will automatically be imported into the Spring ApplicationContext

org.apache.openejb.spring.BmpContainer

Allows an OpenEJB BMP <Container> to be declared in the Spring ApplicationContext. Has the following properties: poolSize

org.apache.openejb.spring.CmpContainer

Allows an OpenEJB CMP <Container> to be declared in the Spring ApplicationContext.

org.apache.openejb.spring.SingletonContainer

Allows an OpenEJB Singleton <Container> to be declared in the Spring ApplicationContext. Has the following properties: accessTimeout

org.apache.openejb.spring.StatefulContainer

Allows an OpenEJB Stateful <Container> to be declared in the Spring ApplicationContext. Has the following properties: timeOut

org.apache.openejb.spring.StatelessContainer

Allows an OpenEJB Stateful <Container> to be declared in the Spring ApplicationContext. Has the following properties: timeOut, poolSize, and strictPooling

org.apache.openejb.spring.MdbContainer

Allows an OpenEJB Message-Driven <Container> to be declared in the Spring ApplicationContext. Has the following properties: resourceAdapter, messageListenerInterface, activationSpecClass, and instanceLimit

org.apache.openejb.spring.EJB

A FactoryBean that imports an EJB from OpenEJB into the Spring ApplicationContext. One of these is automatically created for each interface of each EJB, but explicit use can be nice if you desire to import an EJB with a specific name. Has the following properties: deploymentId, interface

Examples

See the Spring EJB and JPA page for example code and a working Spring xml file.

...

The simplest installation is to add the OpenEJB jar to your classpath, and add the following to your spring.xml file:

Code Block

    <bean name="classPathApplication" class="org.apache.openejb.spring.ClassPathApplication"/>

...

Anchor
problems
problems
Problems?

Other Issues

If you are having problems with the installation, please send a message to the OpenEJB users mailing list containing any error message(s) and the following information:

...

JavaAgent - OpenEJB uses OpenJPA to provide JPA and CMP persistence, and OpenJPA currently requires a JavaAgent to function properly . This requirement is something that the OpenJPA project is working on removing. Once removed, the OpenEJB plugin for Tomcat will no longer need to modify the startup shell scripts and you will not need to restart Tomcat after the OpenEJB installation.

Transactions -

Misc

This document is a starting point for using OpenEJB in Tomcat and will evolve based on user contributions. If you wish to contribute to this document, feel very welcome to click the 'Edit' link in the lower right and make changes and add new HOWTO's and other docsin a Java 1.5 environment. OpenJPA does not require a JavaAgent in Java 1.6. Use Hibernate as your the provider in your persistence.xml files if you wish to avoid this requirement.