'''<font color="red">20100214: Update for results of EclipseLink 2.0 on JBoss 6.0.0M1 in progress</font>'''

+

* <font color="orange">This tutorial needs to be finished and/or expanded - vote for EclipseLink bug# '''[http://bugs.eclipse.org/308477 308477]''' if you would like this work to be fast tracked.</font>

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.

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.

*The JPA 1.0 specification jar shipped with JBoss EAP is signed. In order to be able to use '''EclipseLink''' with this specific version of the JBoss server you must override the ejb3-persistence.jar by placing an unsigned version beside the '''eclipselink.jar'' off of the '''server/default/lib''' directory - details are in the [[EclipseLink/Bugs/305331|design page for bug# 305331]]

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

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.

+

+

[[Image:Eclipselink_server_jee_jpa_examples_datamodel.gif]]

+

+

====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 [http://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/trunk/examples/org.eclipse.persistence.example.jpa.server.common.ddlgen 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 [[EclipseLink/Examples/JPA|JPA Web application tutorials]] in this section of the Wiki.

====Reference EclipseLink and JPA - Path changes====

====Reference EclipseLink and JPA - Path changes====

Line 204:

Line 283:

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

====@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.

+

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

<source lang="java">

<source lang="java">

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

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

</source>

</source>

−

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.

throw new RuntimeException("Datasource not available - lookukp failed: ", e);

}

}

} else {

} else {

Line 233:

Line 316:

</source>

</source>

−

====Session Customizer====

+

<!--====Session Customizer - deprecated ====

*<font color="red">Note: The session customizer is only required for JBoss 4.2.2</font>

*<font color="red">Note: The session customizer is only required for JBoss 4.2.2</font>

*The client will require an implementation of SessionCustomizer that will set the lookupType on the JNDI connector to STRING_LOOKUP instead of Composite.

*The client will require an implementation of SessionCustomizer that will set the lookupType on the JNDI connector to STRING_LOOKUP instead of Composite.

*Refer to the following [http://forums.oracle.com/forums/thread.jspa?messageID=3205242&tstart=0 post] for details on this issue with Catalina based containers.

*Refer to the following [http://forums.oracle.com/forums/thread.jspa?messageID=3205242&tstart=0 post] for details on this issue with Catalina based containers.

*Refer to the following [http://bugs.eclipse.org/260383 260383 enhancement request] that will make this SessionCustomizer redundant by moving this functionality as standard procedure on the server platform.

*Refer to the following [http://bugs.eclipse.org/260383 260383 enhancement request] that will make this SessionCustomizer redundant by moving this functionality as standard procedure on the server platform.

*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.

This tutorial needs to be finished and/or expanded - vote for EclipseLink bug# 308477 if you would like this work to be fast tracked.

20100217: Updated results of EclipseLink 2.0 on JBoss 6.0.0M1.

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.

Signed Jars

The JPA 1.0 specification jar shipped with JBoss EAP is signed. In order to be able to use EclipseLink' with this specific version of the JBoss server you must override the ejb3-persistence.jar by placing an unsigned version beside the eclipselink.jar off of the server/default/lib directory - details are in the design page for bug# 305331

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 Java EE @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.