Use the following JNDI name and lookup in your Servlet where '''UnifiedJBossEAR''' is the name of your EAR project and '''ApplicationService''' is the name of your @Local @Stateless session bean.

+

Use the following JNDI name and lookup in your Servlet where '''org.eclipse.persistence.example.jpa.server.jboss.EnterpriseEAR''' is the name of your EAR project and '''ApplicationService''' is the name of your @Local @Stateless session bean.

<source lang="java">

<source lang="java">

Line 319:

Line 319:

-->

-->

====Persistence.xml====

====Persistence.xml====

−

*Put persistence.xml in ''yourProjectEJB/ejbModule/META-INF'' with a reference to your SessionCustomizer or...

+

*JTA is the default ''transaction-type'' when deployed in an EE container.

−

*If using a separate J2SE project for your business logic, put persistence.xml in ''yourProjectSE/src/META-INF/'' and export the SE jar to yourProjectWeb/WebContent/WEB-INF/lib/yourProjectSE.jar

*Publishing to JBoss is very simple, once the server is setup you can just drop/remove an EAR in the deploy directory to deploy/undeploy an application. Or use Eclipse to debug via the 5005 port if the server is managed through WTP.

+

*Publishing to JBoss 6 is very simple, once the server is setup you can just drop/remove an EAR in the deploy directory to deploy/undeploy an application. Or use Eclipse to debug via the 5005 port if the server is managed through WTP.

*Eclipse WTP will take care of copying the EAR file to the live deploy directory when you either [re-publish] or modify any files while the server is running.

*Eclipse WTP will take care of copying the EAR file to the live deploy directory when you either [re-publish] or modify any files while the server is running.

*You may also use any combination of running the JBoss server yourself in run or debug mode and using eclipse to publish EAR changes.

*You may also use any combination of running the JBoss server yourself in run or debug mode and using eclipse to publish EAR changes.

−

*Dynamic weaving is disabled for now because of [[http://jira.jboss.com/jira/browse/EJBTHREE-572 JIRA-572]] - Use [http://wiki.eclipse.org/EclipseLink/Examples/JPA/Migration/JBoss static weaving workaround] before deploying if required.

+

*Dynamic weaving is disabled for now because of [[http://jira.jboss.com/jira/browse/EJBTHREE-572 JIRA-572]] - Use [http://wiki.eclipse.org/EclipseLink/Examples/JPA/Migration/JBoss static weaving workaround] before deploying if required. This affects change tracking and lazy loading only.

+

*Depending on your application you will see the following after running [start server]

*Depending on your application you will see the following after running [start server]

**In your console window you will see one process both for the server and the deploy target.

**In your console window you will see one process both for the server and the deploy target.

20100217: Update for results of EclipseLink 2.0 on JBoss 6.0.0M1 in progress

If you want to get a small web application running quickly on JBoss 6 use the services provided by the Web Tools Project project as part of the EE edition of the Eclipse IDE to take care of deployment details for you.

This basic example details how to use Eclipse to run/debug a minimum J2EE web application servlet using EclipseLink JPA as the persistence provider. The goal of this example is to detail the minimum steps needed to run EclipseLink inside JBoss using the Eclipse IDE - at this point no presentation/controller layer such as JSF, Spring or Struts will be used beyond a basic HttpServlet so we can concentrate on the the integration layer JPA setup.

Tutorial Source

The EAR, EJB and WEB Eclipse project source for this EclipseLink JBoss (JPA) tutorial is available online at the following locations. These 3 projects must be imported along with the jpa core eclipselink project or jar.

As an alternative if you do not wish to use SVN or the direct html links into SVN - I have attached a version of the EAR including source to enhancement bug # 250477 in versions for JBoss 5.1.0' (JPA 1.0) and JBoss 6.0.0M1 (JPA 2.0) - except that these may not be in sync with the latest SVN repository changes.

Try changing the following jboss:service=Naming port to any available port, keep the RmiPort at 1098. Use [netstat -a] to check free ports - in my case 1099 is taken by the 1521 orcl listener.

TCP yourpc:1099 yourpc....com:1521 ESTABLISHED

<JBOSS_HOME>\server\default\conf\jboss-service.xml|jboss-minimal.xml

<mbeancode="org.jboss.naming.NamingService"name="jboss:service=Naming"xmbean-dd="resource:xmdesc/NamingService-xmbean.xml">
...
from
<attributename="Port">1199</attribute>
to
<attributename="Port">1099</attribute>

Eclipse WTP Server configuration

Open the server configuration on the [servers] view and change [Server Properties/JNDI Port] to 1199

<app>/JNDI.properties

You will also need to sync this port change in your jndi.properties file (mine is off my web application under src/ just above META-INF.

Select generate deployment descriptor if you want to change the context-root

UML Data Model

The following single entity Cell has a @ManyToMany bidirectional relationship to itself.

Tutorial Design

The goal of the tutorial is to demonstrate a quick start end-to-end deployment on a specific application server of an EclipseLink JPA application.
To accomplish this...

The web framework is a simple servlet so we avoid container specific issues around a JSF implementation.

The data model is very simple (@ManyToMany) - as the other tutorials get into more advanced JPA entity concepts and annoations

The entityManager is container managed where possible by injection

The schema is generated by DDL generation in a separate common application managed SE app for an Oracle DB (because of an implicit auto-commit on create table) or directly when using HSQL.

The application context name is standard across servers

The datasource is globally defined (by the user) on the server - with the only configuration setting being the jta-data-source element in persistence.xml

DDL/Schema Generation

The database schema for this example can be automatically generated using the DDL generation capability of EclipseLink (normally only used by development or for demos). The following project in SVN can be run as an application managed stand-alone JPA project that has ddl-generation turned on in the persistence.xml.

Note: DDL Generation is not possible on a container managed entity manager connected to a JTA datasource (if the database uses implicit auto-commits (HSQL does not) - hence the use of a separate project that is server agnostic and sharable by all the JPA Web application tutorials in this section of the Wiki.

Reference EclipseLink and JPA - Path changes

Either link to the 2 SVN projects below or link to an external eclipselink.jar and javax-persistence.jar.

After EAR project creation - reference eclipselink.core and eclipselink.jpa or include a reference to eclipselink.jar in your WAR project.

If you don't reference the eclipselink.* projects then include a classpath reference to persistence.jar and an Oracle JDBC driver jar for your DB - You will need to put this JDBC driver jar in your JBoss /server/default/lib directory as well.

@EJB Injection is not available to Servlets - use a JNDI lookup

In JBoss the JEE @EJB annotation has no effect when trying to inject you session bean that holds the entityManager.

@EJB(beanName="ApplicationService")// No effect in JBoss

Use the following JNDI name and lookup in your Servlet where org.eclipse.persistence.example.jpa.server.jboss.EnterpriseEAR is the name of your EAR project and ApplicationService is the name of your @Local @Stateless session bean.

Start Server

Steps: Select the EAR and [Run on Server].

The first "Run on Server" may not start the server, in this case you "Start Server" and then "Run on Server".

Publish EAR

Publishing to JBoss 6 is very simple, once the server is setup you can just drop/remove an EAR in the deploy directory to deploy/undeploy an application. Or use Eclipse to debug via the 5005 port if the server is managed through WTP.

Eclipse WTP will take care of copying the EAR file to the live deploy directory when you either [re-publish] or modify any files while the server is running.

You may also use any combination of running the JBoss server yourself in run or debug mode and using eclipse to publish EAR changes.

Dynamic weaving is disabled for now because of [JIRA-572] - Use static weaving workaround before deploying if required. This affects change tracking and lazy loading only.

Depending on your application you will see the following after running [start server]

In your console window you will see one process both for the server and the deploy target.