Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "EclipseLink/Examples/JPA/Migration/JBoss"
< EclipseLink | Examples | JPA | Migration
(→Migrating to JBoss using EclipseLink as JPA provider) |
(→EAR Packaging Modifications) |
||
Line 13: | Line 13: | ||
==EAR Packaging Modifications== | ==EAR Packaging Modifications== | ||
*Dynamic weaving (byte-code instrumentation) is not currently available in JBoss 4.2.2 because of [ JIRA EJBTHREE-572]. Our workaround is to statically weave the entities by running the following Ant task before creating your EJB jar during EAR packaging. You must use the statically weaved classes if you would like to use LAZY 1-1 and many-1 functionality. | *Dynamic weaving (byte-code instrumentation) is not currently available in JBoss 4.2.2 because of [ JIRA EJBTHREE-572]. Our workaround is to statically weave the entities by running the following Ant task before creating your EJB jar during EAR packaging. You must use the statically weaved classes if you would like to use LAZY 1-1 and many-1 functionality. | ||
− | *See [http://bugs.eclipse.org/229634 | + | *See [http://bugs.eclipse.org/229634 229634: JBoss predeploy workaround] |
+ | |||
+ | *Ant static weaving ant task | ||
+ | <pre> | ||
+ | <target name="run-weaver"> | ||
+ | <taskdef name="weave" classname="org.eclipse.persistence.tools.weaving.jpa.StaticWeaveAntTask"> | ||
+ | <classpath> | ||
+ | <pathelement path="persistence.jar"/> | ||
+ | <pathelement path="eclipselink.jar"/> | ||
+ | <pathelement path="persistence_1_0.xsd"/> | ||
+ | </classpath> | ||
+ | </taskdef> | ||
+ | <!-- process the weaving function, peristenceInfo references persistence.xml --> | ||
+ | <weave source= "build/classes_unweaved" | ||
+ | target = "build/classes" | ||
+ | persistenceinfo="build/jars/app_unweaved.jar" | ||
+ | loglevel="FINEST"> | ||
+ | </weave> | ||
+ | </target> | ||
+ | </pre> | ||
+ | *Results | ||
+ | **You should see the following on your Ant log. | ||
+ | <pre> | ||
+ | C:\wse\w34b\jbossHWEAR>ant -lib c:\wse\w34b\jbossHWEAR -f build.xml | ||
+ | Buildfile: build.xml | ||
+ | clean: | ||
+ | [delete] Deleting directory C:\wse\w34b\jbossHWEAR\build | ||
+ | compile: | ||
+ | [mkdir] Created dir: C:\wse\w34b\jbossHWEAR\build\classes | ||
+ | [mkdir] Created dir: C:\wse\w34b\jbossHWEAR\build\classes0 | ||
+ | [javac] Compiling 5 source files to C:\wse\w34b\jbossHWEAR\build\classes0 | ||
+ | [javac] Note: C:\wse\w34b\jbossHWEJB\ejbModule\TodoDao.java uses unchecked or unsafe operations. | ||
+ | [javac] Note: Recompile with -Xlint:unchecked for details. | ||
+ | ejb3jar0: | ||
+ | [mkdir] Created dir: C:\wse\w34b\jbossHWEAR\build\jars | ||
+ | [jar] Building jar: C:\wse\w34b\jbossHWEAR\build\jars\app0.jar | ||
+ | run-weaver: | ||
+ | [weave] [EL Finer]: 2008.05.05 16:30:41.216--ServerSession(29857804)--Thread(Thread[main,5,main])--Searching for default mappi | ||
+ | ng file in file:/C:/wse/w34b/jbossHWEAR/build/jars/app0.jar | ||
+ | [weave] [EL Finer]: 2008.05.05 16:30:41.246--ServerSession(29857804)--Thread(Thread[main,5,main])--Found a default mapping fil | ||
+ | e at jar:file:/C:/wse/w34b/jbossHWEAR/build/jars/app0.jar!/META-INF/orm.xml for root URL file:/C:/wse/w34b/jbossHWEAR/build/jars/a | ||
+ | pp0.jar | ||
+ | [weave] [EL Config]: 2008.05.05 16:30:41.878--ServerSession(29857804)--Thread(Thread[main,5,main])--The table name for entity | ||
+ | [Todo] is being defaulted to: TODO. | ||
+ | [weave] [EL Config]: 2008.05.05 16:30:41.891--ServerSession(29857804)--Thread(Thread[main,5,main])--The discriminator column n | ||
+ | ame for the root inheritance class [class Todo] is being defaulted to: DTYPE. | ||
+ | [weave] [EL Config]: 2008.05.05 16:30:41.928--ServerSession(29857804)--Thread(Thread[main,5,main])--The column name for elemen | ||
+ | t [public java.lang.String Todo.getDescription()] is being defaulted to: DESCRIPTION. | ||
+ | [weave] [EL Config]: 2008.05.05 16:30:41.937--ServerSession(29857804)--Thread(Thread[main,5,main])--The column name for elemen | ||
+ | t [public java.lang.String Todo.getTitle()] is being defaulted to: TITLE. | ||
+ | [weave] [EL Finer]: 2008.05.05 16:30:41.950--ServerSession(29857804)--Thread(Thread[main,5,main])--Class [Todo] registered to | ||
+ | be processed by weaver. | ||
+ | [weave] [EL Finest]: 2008.05.05 16:30:41.974--ServerSession(29857804)--Thread(Thread[main,5,main])--Begin weaver class transfo | ||
+ | rmer processing class [Todo]. | ||
+ | [weave] [EL Finest]: 2008.05.05 16:30:42.020--ServerSession(29857804)--Thread(Thread[main,5,main])--Weaved persistence (Persis | ||
+ | tenceEntity) [Todo]. | ||
+ | [weave] [EL Finest]: 2008.05.05 16:30:42.029--ServerSession(29857804)--Thread(Thread[main,5,main])--Weaved change tracking (Ch | ||
+ | angeTracker) [Todo]. | ||
+ | [weave] [EL Finest]: 2008.05.05 16:30:42.040--ServerSession(29857804)--Thread(Thread[main,5,main])--Weaved fetch groups (Fetch | ||
+ | GroupTracker) [Todo]. | ||
+ | [weave] [EL Finest]: 2008.05.05 16:30:42.053--ServerSession(29857804)--Thread(Thread[main,5,main])--End weaver class transform | ||
+ | er processing class [Todo]. | ||
+ | war: | ||
+ | [war] Building war: C:\wse\w34b\jbossHWEAR\build\jars\app.war | ||
+ | ejb3jar: | ||
+ | [jar] Building jar: C:\wse\w34b\jbossHWEAR\build\jars\app.jar | ||
+ | ear: | ||
+ | [ear] Building ear: C:\wse\w34b\jbossHWEAR\build\jars\jsfejb3.ear | ||
+ | deploy: | ||
+ | [copy] Copying 1 file to C:\opt\jboss422\server\default\deploy | ||
+ | main: | ||
+ | BUILD SUCCESSFUL | ||
+ | Total time: 3 seconds | ||
+ | </pre> |
Revision as of 16:35, 5 May 2008
Contents
Migrating to JBoss using EclipseLink as JPA provider
- These instructions are for users wishing to migrate EclipseLink to the JBoss container as well as possibly migrating from another persistence provider such as Hibernate.
- There is an good example on jboss.org that we will use an example of how to migrate a small container managed web application from using Hibernate to using EclipeLink as the JPA provider.
- See the RedHat JBoss EJB3 Example.
- See the JBoss EJB3 example jsfejb3.ear binary.
persistence.xml Modifications
- The following changes must be done to persistence.xml
@EJB Injection/JNDI lookup Modifications
- The @EJB injection annotation does not currently work outside of the EJB container - for example in the servlet container. The solution is to use a custom JNDI lookup.
EAR Packaging Modifications
- Dynamic weaving (byte-code instrumentation) is not currently available in JBoss 4.2.2 because of [ JIRA EJBTHREE-572]. Our workaround is to statically weave the entities by running the following Ant task before creating your EJB jar during EAR packaging. You must use the statically weaved classes if you would like to use LAZY 1-1 and many-1 functionality.
- See 229634: JBoss predeploy workaround
- Ant static weaving ant task
<target name="run-weaver"> <taskdef name="weave" classname="org.eclipse.persistence.tools.weaving.jpa.StaticWeaveAntTask"> <classpath> <pathelement path="persistence.jar"/> <pathelement path="eclipselink.jar"/> <pathelement path="persistence_1_0.xsd"/> </classpath> </taskdef> <!-- process the weaving function, peristenceInfo references persistence.xml --> <weave source= "build/classes_unweaved" target = "build/classes" persistenceinfo="build/jars/app_unweaved.jar" loglevel="FINEST"> </weave> </target>
- Results
- You should see the following on your Ant log.
C:\wse\w34b\jbossHWEAR>ant -lib c:\wse\w34b\jbossHWEAR -f build.xml Buildfile: build.xml clean: [delete] Deleting directory C:\wse\w34b\jbossHWEAR\build compile: [mkdir] Created dir: C:\wse\w34b\jbossHWEAR\build\classes [mkdir] Created dir: C:\wse\w34b\jbossHWEAR\build\classes0 [javac] Compiling 5 source files to C:\wse\w34b\jbossHWEAR\build\classes0 [javac] Note: C:\wse\w34b\jbossHWEJB\ejbModule\TodoDao.java uses unchecked or unsafe operations. [javac] Note: Recompile with -Xlint:unchecked for details. ejb3jar0: [mkdir] Created dir: C:\wse\w34b\jbossHWEAR\build\jars [jar] Building jar: C:\wse\w34b\jbossHWEAR\build\jars\app0.jar run-weaver: [weave] [EL Finer]: 2008.05.05 16:30:41.216--ServerSession(29857804)--Thread(Thread[main,5,main])--Searching for default mappi ng file in file:/C:/wse/w34b/jbossHWEAR/build/jars/app0.jar [weave] [EL Finer]: 2008.05.05 16:30:41.246--ServerSession(29857804)--Thread(Thread[main,5,main])--Found a default mapping fil e at jar:file:/C:/wse/w34b/jbossHWEAR/build/jars/app0.jar!/META-INF/orm.xml for root URL file:/C:/wse/w34b/jbossHWEAR/build/jars/a pp0.jar [weave] [EL Config]: 2008.05.05 16:30:41.878--ServerSession(29857804)--Thread(Thread[main,5,main])--The table name for entity [Todo] is being defaulted to: TODO. [weave] [EL Config]: 2008.05.05 16:30:41.891--ServerSession(29857804)--Thread(Thread[main,5,main])--The discriminator column n ame for the root inheritance class [class Todo] is being defaulted to: DTYPE. [weave] [EL Config]: 2008.05.05 16:30:41.928--ServerSession(29857804)--Thread(Thread[main,5,main])--The column name for elemen t [public java.lang.String Todo.getDescription()] is being defaulted to: DESCRIPTION. [weave] [EL Config]: 2008.05.05 16:30:41.937--ServerSession(29857804)--Thread(Thread[main,5,main])--The column name for elemen t [public java.lang.String Todo.getTitle()] is being defaulted to: TITLE. [weave] [EL Finer]: 2008.05.05 16:30:41.950--ServerSession(29857804)--Thread(Thread[main,5,main])--Class [Todo] registered to be processed by weaver. [weave] [EL Finest]: 2008.05.05 16:30:41.974--ServerSession(29857804)--Thread(Thread[main,5,main])--Begin weaver class transfo rmer processing class [Todo]. [weave] [EL Finest]: 2008.05.05 16:30:42.020--ServerSession(29857804)--Thread(Thread[main,5,main])--Weaved persistence (Persis tenceEntity) [Todo]. [weave] [EL Finest]: 2008.05.05 16:30:42.029--ServerSession(29857804)--Thread(Thread[main,5,main])--Weaved change tracking (Ch angeTracker) [Todo]. [weave] [EL Finest]: 2008.05.05 16:30:42.040--ServerSession(29857804)--Thread(Thread[main,5,main])--Weaved fetch groups (Fetch GroupTracker) [Todo]. [weave] [EL Finest]: 2008.05.05 16:30:42.053--ServerSession(29857804)--Thread(Thread[main,5,main])--End weaver class transform er processing class [Todo]. war: [war] Building war: C:\wse\w34b\jbossHWEAR\build\jars\app.war ejb3jar: [jar] Building jar: C:\wse\w34b\jbossHWEAR\build\jars\app.jar ear: [ear] Building ear: C:\wse\w34b\jbossHWEAR\build\jars\jsfejb3.ear deploy: [copy] Copying 1 file to C:\opt\jboss422\server\default\deploy main: BUILD SUCCESSFUL Total time: 3 seconds