Difference between revisions of "EclipseLink/Examples/JPA/Migration/JBoss"

From Eclipsepedia

Jump to: navigation, search
m (Set target-database)
(Reference article covering AS7)
 
(47 intermediate revisions by 2 users not shown)
Line 1: Line 1:
==Migrating to JBoss using EclipseLink as JPA provider==
+
=Migrating from Hibernate to EclipseLink within the JBoss JSFEJB3 Example=
*'''*<font color="red">Warning: These instructions started on 20080505 are under construction for the next couple days</font>'''
+
*These instructions are for users wishing to use EclipseLink as the JPA provider in place of Hibernate in the [http://www.jboss.org/jbossas/downloads JBoss] container.
*These instructions are for users wishing to migrate EclipseLink to the [http://www.jboss.org/jbossas/downloads JBoss] container as well as possibly migrating from another persistence provider such as Hibernate.
+
 
 +
<b>This article may be somewhat out of date. Information for EclipseLink and JBoss AS 7 can be found here: https://community.jboss.org/wiki/HowToUseEclipseLinkWithAS7</b>
 +
 
 +
*The scope of this document is a description of the required static weaving workaround for [http://jira.jboss.com/jira/browse/EJBTHREE-572 EJBTHREE-572] using the JBoss JSFEJB3 example as reference.  See the [http://wiki.eclipse.org/EclipseLink/Examples/JPA/Migration JPA Migration] page for an overall migration example.
 
*The EJB3 example on jboss.org will be used as a common open-source example of how to migrate a small <font color="green">'''container managed'''</font> web application from using Hibernate to using EclipeLink as the JPA provider.
 
*The EJB3 example on jboss.org will be used as a common open-source example of how to migrate a small <font color="green">'''container managed'''</font> web application from using Hibernate to using EclipeLink as the JPA provider.
 
**See the RedHat [http://www.redhat.com/docs/manuals/jboss/jboss-eap-4.3/doc/Getting_Started/html-single/index.html#EJB3_Caveats JBoss EJB3 Example] documentation.
 
**See the RedHat [http://www.redhat.com/docs/manuals/jboss/jboss-eap-4.3/doc/Getting_Started/html-single/index.html#EJB3_Caveats JBoss EJB3 Example] documentation.
Line 7: Line 10:
  
 
==persistence.xml Modifications==
 
==persistence.xml Modifications==
 +
Note: the defaulted transaction-type attribute of the persistence-unit element.
 +
 +
===Original persistence.xml===
 +
<source lang="xml">
 +
<persistence>
 +
  <persistence-unit name="helloworld">
 +
      <provider>org.hibernate.ejb.HibernatePersistence</provider>
 +
      <jta-data-source>java:/DefaultDS</jta-data-source>
 +
      <properties>
 +
        <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
 +
        <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
 +
      </properties>
 +
  </persistence-unit>
 +
</persistence>
 +
</source>
 +
 +
===Modified persistence.xml===
 
<source lang="xml">
 
<source lang="xml">
 
<xml version="1.0" encoding="UTF-8"?>
 
<xml version="1.0" encoding="UTF-8"?>
Line 12: Line 32:
 
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
 
   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_1_0.xsd">
 
   xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
   <persistence-unit name="helloworld" transaction-type="JTA">
+
   <persistence-unit name="helloworld">
 
     <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
 
     <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
     <jta-data-source>java:/JTSEclipseLinkDS</jta-data-source>
+
     <jta-data-source>java:/DefaultDS</jta-data-source>
 
     <!-- Entities must be specified for EclipseLink weaving -->
 
     <!-- Entities must be specified for EclipseLink weaving -->
 
     <class>Todo</class>
 
     <class>Todo</class>
 
     <properties>
 
     <properties>
       <property name="eclipselink.target-database" value="org.eclipse.persistence.platform.database.oracle.OraclePlatform"/>
+
       <property name="eclipselink.target-database" value="HSQL"/>
       <!--property name="eclipselink.ddl-generation" value="drop-and-create-tables"/-->
+
       <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
       <!--property name="eclipselink.ddl-generation.output-mode" value="database"/-->
+
       <property name="eclipselink.ddl-generation.output-mode" value="database"/>
       <property name="eclipselink.target-server" value="org.eclipse.persistence.platform.server.jboss.JBossPlatform"/>
+
       <property name="eclipselink.target-server" value="JBoss"/>
       <!--property name="eclipselink.weaving" value="static"/--><!-- ignored -->
+
       <property name="eclipselink.weaving" value="false"/>
 
       <property name="eclipselink.logging.level" value="FINEST"/>
 
       <property name="eclipselink.logging.level" value="FINEST"/>
 
     </properties>
 
     </properties>
Line 29: Line 49:
 
</source>
 
</source>
 
*The following changes must be done to persistence.xml
 
*The following changes must be done to persistence.xml
 +
 
===Set target-server===
 
===Set target-server===
The fix for [http://jira.jboss.org/jira/browse/EJBTHREE-572 EJBTHREE-572] requires that the PersistenceUnit state the JBoss platform using the ''target-server'' property.
+
The fix for [http://jira.jboss.org/jira/browse/EJBTHREE-572 EJBTHREE-572] requires that the PersistenceUnit state the JBoss platform using the ''target-server'' property. We recommend the short name ''JBoss'' (but the full package name ''org.eclipse.persistence.platform.server.jboss.JBossPlatform'' is supported).
 +
* See org.eclipse.persistence.config.TargetServer for a list of container platforms supported.
  
<font color="red"><property name="eclipselink.target-server" value="org.eclipse.persistence.platform.server.jboss.JBossPlatform"/></font>
+
<source lang="xml">
 +
<property name="eclipselink.target-server" value="JBoss"/>
 +
</source>
  
 
===Set target-database===
 
===Set target-database===
To continue to use the HSQL (Hypersonic) Database all you need to do is define the target-database in the persistence unit.
+
To continue to use the HSQL (Hypersonic) Database all you need to do is define the target-database in the persistence unit, we recommend the short name ''HSQL'' (but the full package name ''org.eclipse.persistence.platform.database.HSQLPlatform'' is supported).
<pre>
+
* See org.eclipse.persistence.config.TargetDatabase for a list of databases supported.
<property name="eclipselink.target-database" value="org.eclipse.persistence.platform.database.HSQLPlatform"/>
+
</pre>
+
  
===Create Database===
+
<source lang="xml">
The eclipselink.ddl-generation property is not used in this example, we will manually create our table by executing the following DDL.
+
<property name="eclipselink.target-database" value="HSQL"/>
<pre>
+
</source>
CREATE TABLE TODO (ID NUMBER(19) NOT NULL, DTYPE VARCHAR2(31) NULL, DESCRIPTION VARCHAR2(255) NULL, TITLE VARCHAR2(255) NULL, PRIMARY KEY (ID))
+
</pre>
+
  
==JTA Datasource Configuration==
+
===Drop/Create Database===
*In this migration we are using an Oracle database - we need to setup the datasource in JBoss.
+
The tables will be automatically dropped and created by EclipseLink with the following 2 properties in the persistence unit. For production environments you would normally already have the schema setup on the database, so using the following schema generation properties will erase any previous existing tables and are normally used for example/demo purposes.
*Copy $JBOSS_HOME\docs\examples\jca\oracle-*ds.xml to $JBOSS_HOME\server\default\deploy
+
*Edit oracle-xa-ds.xml
+
*Enter the following into $JBOSS_HOME\server\default\deploy\oracle-xa-ds.xml
+
 
<source lang="xml">
 
<source lang="xml">
<datasources>
+
<property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
  <xa-datasource>
+
<property name="eclipselink.ddl-generation.output-mode" value="database"/>
    <jndi-name>JTSEclipseLinkDS</jndi-name>
+
    <use-java-context>true</use-java-context>
+
    <track-connection-by-tx>true</track-connection-by-tx>
+
<isSameRM-override-value>false</isSameRM-override-value>
+
    <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
+
    <xa-datasource-property name="URL">jdbc:oracle:thin:@localhost:1521:orcl</xa-datasource-property>
+
    <xa-datasource-property name="User">username</xa-datasource-property>
+
    <xa-datasource-property name="Password">password</xa-datasource-property>
+
    <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
+
    <no-tx-separate-pools/>
+
      <metadata>
+
        <type-mapping>Oracle9i</type-mapping>
+
      </metadata>
+
  </xa-datasource>
+
 
</source>
 
</source>
 +
 +
==JTA Datasource Configuration==
 +
No changes are required in the deploy directory of JBoss 4.2.2 out of the box to run HSQL.
  
 
==@EJB Injection/JNDI lookup Modifications==
 
==@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 which is not in standard JNDI naming format such as "java:comp/env/ejb/jsfejb3/TodoDao".
+
*The @EJB injection annotation does not currently work outside of the JBoss EJB container - for example in the servlet container.  The solution is to use a custom JNDI lookup which is not in standard JNDI naming format such as "java:comp/env/ejb/jsfejb3/TodoDao" - this code is already on the session DAO bean.
<pre>
+
<source lang="java">
 
InitialContext ctx = new InitialContext();
 
InitialContext ctx = new InitialContext();
 
return (TodoDaoInt) ctx.lookup("jsfejb3/TodoDao/local");
 
return (TodoDaoInt) ctx.lookup("jsfejb3/TodoDao/local");
</pre>
+
</source>
  
 
==Static Weaving / EAR Packaging Modifications==
 
==Static Weaving / EAR Packaging Modifications==
 +
*<font color="red">This example does not require weaving - this section is for reference and can be skipped.</font>
 
*Dynamic weaving (byte-code instrumentation) is not currently available in JBoss 4.2.2 because of [http://jira.jboss.org/jira/browse/EJBTHREE-572 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 [http://jira.jboss.org/jira/browse/EJBTHREE-572 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 229634: JBoss predeploy workaround]
 
*See [http://bugs.eclipse.org/229634 229634: JBoss predeploy workaround]
 
*Note: that the ant task references persistence.jar, eclipselink.jar and the persistence 1.0 XSD - you may reference these where they exist on your system.
 
*Note: that the ant task references persistence.jar, eclipselink.jar and the persistence 1.0 XSD - you may reference these where they exist on your system.
*Note: persistence.xml must have the <xml> element for NS validation and namespace references in the <persistence> element.
+
*Note: persistence.xml must have both the <xml> element declaration and the namespace validation references in the <persistence> element.
  
 
*Ant static weaving ant task
 
*Ant static weaving ant task
Line 145: Line 152:
 
Total time: 3 seconds
 
Total time: 3 seconds
 
</pre>
 
</pre>
 +
 +
===Weaving or Instrumentation===
 +
*A diff of the unweaved and weaved bytecode will look like the following.
 +
 +
[[Image:Eclipselink_jboss_weaving_bytecode_diff.jpg]]
  
 
===Deployment===
 
===Deployment===
 
*Make sure the JBoss server is running when the ear is copied to the deploy directory or start the server.
 
*Make sure the JBoss server is running when the ear is copied to the deploy directory or start the server.
 
<pre>
 
<pre>
17:11:07,633 INFO  [JmxKernelAbstraction] jboss.jca:name=DefaultDS,service=DataSourceBinding
+
 
17:11:07,635 INFO  [PersistenceUnitDeployment] Starting persistence unit persistence.units:ear=jsfejb3.ear,jar=app.jar,unitName=helloworld
+
10:13:11,063 INFO  [JmxKernelAbstraction] jboss.jca:name=DefaultDS,service=DataSourceBinding
17:11:07,801 INFO  [STDOUT] [EL Warning]: 2008.05.05 17:11:07.784--Thread(Thread[main,5,jboss])--The temporary classLoader for PersistenceLoadProcessor [helloworld] is not available.  Switching classLoader to [org.jboss.mx.loading.UnifiedClassLoader3@18b995c{ url=file:/C:/opt/jboss422/server/default/tmp/deploy/tmp46857jsfejb3.ear ,addedOrder=45}].  Weaving has been disabled for this session. EclipseLink may be unable to get a spec mandated temporary class loader from the server, you may be able to use static weaving as an optional workaround.  
+
10:13:11,064 INFO  [PersistenceUnitDeployment] Starting persistence unit persistence.units:ear=jsfejb3.ear,jar=app.jar,unitName=helloworld
17:11:07,809 INFO  [STDOUT] [EL Finest] : 2008.05.05 17:11:07.802--ServerSession(9262213)--Thread(Thread[main,5,jboss])--Begin predeploying Persistence Unit helloworld; state Initial; factoryCount 0
+
10:13:11,230 INFO  [STDOUT] [EL Warning]: 2008.05.08 10:13:11.205--Thread(Thread[main,5,jboss])--The temporary classLoader for PersistenceLoadProcessor [helloworld] is not available.  Switching classLoader to [org.jboss.mx.loading.UnifiedClassLoader3@182d86{ url=file:/C:/opt/jboss422/server/default/tmp/deploy/tmp20649jsfejb3.ear ,addedOrder=45}].  Weaving has been disabled for this session. EclipseLink may be unable to get a spec mandated temporary class loader from the server, you may be able to use static weaving as an optional workaround.  
17:11:07,811 INFO  [STDOUT] [EL Finest] : 2008.05.05 17:11:07.811--ServerSession(9262213)--Thread(Thread[main,5,jboss])--property=eclipselink.weaving; value=true
+
10:13:11,238 INFO  [STDOUT] [EL Finest]: 2008.05.08 10:13:11.231--ServerSession(2522904)--Thread(Thread[main,5,jboss])--Begin predeploying Persistence Unit helloworld; state Initial; factoryCount 0
17:11:07,812 INFO  [STDOUT] [EL Finest] : 2008.05.05 17:11:07.812--ServerSession(9262213)--Thread(Thread[main,5,jboss])--property=eclipselink.orm.throw.exceptions; default value=true
+
10:13:11,241 INFO  [STDOUT] [EL Finest]: 2008.05.08 10:13:11.241--ServerSession(2522904)--Thread(Thread[main,5,jboss])--property=eclipselink.weaving; value=true
17:11:07,830 INFO  [STDOUT] [EL Finer] : 2008.05.05 17:11:07.827--ServerSession(9262213)--Thread(Thread[main,5,jboss])--Searching for default mapping file in file:/C:/opt/jboss422/server/default/tmp/deploy/tmp46857jsfejb3.ear-contents/app.jar
+
10:13:11,241 INFO  [STDOUT] [EL Finest]: 2008.05.08 10:13:11.241--ServerSession(2522904)--Thread(Thread[main,5,jboss])--property=eclipselink.orm.throw.exceptions; default value=true
17:11:07,846 INFO  [STDOUT] [EL Finer] : 2008.05.05 17:11:07.846--ServerSession(9262213)--Thread(Thread[main,5,jboss])--Found a default mapping file at jar:file:/C:/opt/jboss422/server/default/tmp/deploy/tmp46857jsfejb3.ear-contents/app.jar!/META-INF/orm.xml for root URL file:/C:/opt/jboss422/server/default/tmp/deploy/tmp46857jsfejb3.ear-contents/app.jar
+
10:13:11,259 INFO  [STDOUT] [EL Finer]:   2008.05.08 10:13:11.256--ServerSession(2522904)--Thread(Thread[main,5,jboss])--Searching for default mapping file in file:/C:/opt/jboss422/server/default/tmp/deploy/tmp20649jsfejb3.ear-contents/app.jar
17:11:08,600 INFO  [STDOUT] [EL Config] : 2008.05.05 17:11:08.599--ServerSession(9262213)--Thread(Thread[main,5,jboss])--The table name for entity [Todo] is being defaulted to: TODO.
+
10:13:11,264 INFO  [STDOUT] [EL Finer]:   2008.05.08 10:13:11.263--ServerSession(2522904)--Thread(Thread[main,5,jboss])--Found a default mapping file at jar:file:/C:/opt/jboss422/server/default/tmp/deploy/tmp20649jsfejb3.ear-contents/app.jar!/META-INF/orm.xml for root URL file:/C:/opt/jboss422/server/default/tmp/deploy/tmp20649jsfejb3.ear-contents/app.jar
17:11:08,604 INFO  [STDOUT] [EL Config] : 2008.05.05 17:11:08.604--ServerSession(9262213)--Thread(Thread[main,5,jboss])--The discriminator column name for the root inheritance class [class Todo] is being defaulted to: DTYPE.
+
10:13:12,007 INFO  [STDOUT] [EL Config]: 2008.05.08 10:13:12.006--ServerSession(2522904)--Thread(Thread[main,5,jboss])--The table name for entity [Todo] is being defaulted to: TODO.
17:11:08,635 INFO  [STDOUT] [EL Config] : 2008.05.05 17:11:08.635--ServerSession(9262213)--Thread(Thread[main,5,jboss])--The column name for element [public java.lang.String Todo.getDescription()] is being defaulted to: DESCRIPTION.
+
10:13:12,011 INFO  [STDOUT] [EL Config]: 2008.05.08 10:13:12.011--ServerSession(2522904)--Thread(Thread[main,5,jboss])--The discriminator column name for the root inheritance class [class Todo] is being defaulted to: DTYPE.
17:11:08,639 INFO  [STDOUT] [EL Config] : 2008.05.05 17:11:08.639--ServerSession(9262213)--Thread(Thread[main,5,jboss])--The column name for element [public java.lang.String Todo.getTitle()] is being defaulted to: TITLE.
+
10:13:12,042 INFO  [STDOUT] [EL Config]: 2008.05.08 10:13:12.042--ServerSession(2522904)--Thread(Thread[main,5,jboss])--The column name for element [public java.lang.String Todo.getDescription()] is being defaulted to: DESCRIPTION.
17:11:08,642 INFO  [STDOUT] [EL Finest] : 2008.05.05 17:11:08.642--ServerSession(9262213)--Thread(Thread[main,5,jboss])--End predeploying Persistence Unit helloworld; state Predeployed; factoryCount 1
+
10:13:12,046 INFO  [STDOUT] [EL Config]: 2008.05.08 10:13:12.046--ServerSession(2522904)--Thread(Thread[main,5,jboss])--The column name for element [public java.lang.String Todo.getTitle()] is being defaulted to: TITLE.
17:11:08,685 INFO  [JmxKernelAbstraction] creating wrapper delegate for: org.jboss.ejb3.stateless.StatelessContainer
+
10:13:12,048 INFO  [STDOUT] [EL Finest]: 2008.05.08 10:13:12.048--ServerSession(2522904)--Thread(Thread[main,5,jboss])--End predeploying Persistence Unit helloworld; state Predeployed; factoryCount 1
17:11:08,690 INFO  [JmxKernelAbstraction] installing MBean: jboss.j2ee:ear=jsfejb3.ear,jar=app.jar,name=TodoDao,service=EJB3 with dependencies:
+
10:13:12,088 INFO  [JmxKernelAbstraction] creating wrapper delegate for: org.jboss.ejb3.stateless.StatelessContainer
17:11:08,690 INFO  [JmxKernelAbstraction] persistence.units:ear=jsfejb3.ear,jar=app.jar,unitName=helloworld
+
10:13:12,092 INFO  [JmxKernelAbstraction] installing MBean: jboss.j2ee:ear=jsfejb3.ear,jar=app.jar,name=TodoDao,service=EJB3 with dependencies:
17:11:08,842 INFO  [EJBContainer] STARTED EJB: TodoDao ejbName: TodoDao
+
10:13:12,092 INFO  [JmxKernelAbstraction] persistence.units:ear=jsfejb3.ear,jar=app.jar,unitName=helloworld
17:11:08,864 INFO  [EJB3Deployer] Deployed: file:/C:/opt/jboss422/server/default/tmp/deploy/tmp46857jsfejb3.ear-contents/app.jar
+
10:13:12,231 INFO  [EJBContainer] STARTED EJB: TodoDao ejbName: TodoDao
17:11:08,868 INFO  [TomcatDeployer] deploy, ctxPath=/jsfejb3, warUrl=.../tmp/deploy/tmp46857jsfejb3.ear-contents/app-exp.war/
+
10:13:12,253 INFO  [EJB3Deployer] Deployed: file:/C:/opt/jboss422/server/default/tmp/deploy/tmp20649jsfejb3.ear-contents/app.jar
17:11:09,509 INFO  [EARDeployer] Started J2EE application: file:/C:/opt/jboss422/server/default/deploy/jsfejb3.ear
+
10:13:12,257 INFO  [TomcatDeployer] deploy, ctxPath=/jsfejb3, warUrl=.../tmp/deploy/tmp20649jsfejb3.ear-contents/app-exp.war/
 +
10:13:12,704 INFO  [EARDeployer] Started J2EE application: file:/C:/opt/jboss422/server/default/deploy/jsfejb3.ear
 
</pre>
 
</pre>
  
Line 175: Line 188:
 
**Action create, read
 
**Action create, read
 
<pre>
 
<pre>
))
+
10:13:22,482 INFO  [STDOUT] >>>>new Todo: Todo@1397218
23:39:11,949 INFO  [STDOUT] [EL Config]: 2008.05.05 23:39:11.949--ServerSession(30958654)--Connection(10445386)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--Connected: jdbc:oracle:thin:@127.0.0.1:1521:orcl
+
10:13:22,525 INFO  [STDOUT] [EL Finest]: 2008.05.08 10:13:22.525--ServerSession(2522904)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--property=eclipselink.target-server; value=org.eclipse.persistence.platform.server.jboss.JBossPlatform
User: STAT
+
10:13:22,526 INFO  [STDOUT] [EL Finest]: 2008.05.08 10:13:22.526--ServerSession(2522904)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--property=eclipselink.target-database; value=org.eclipse.persistence.platform.database.HSQLPlatform
Database: Oracle  Version: Oracle Database 11g Release 11.1.0.0.0 - Production
+
10:13:22,556 INFO  [STDOUT] [EL Config]: 2008.05.08 10:13:22.556--ServerSession(2522904)--Connection(28982303)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--Connected: jdbc:hsqldb:C:\opt\jboss422\server\default\data\hypersonic\localDB
Driver: Oracle JDBC driver  Version: 11.1.0.0.0-Beta5
+
User: SA
23:39:11,986 INFO  [STDOUT] [EL Info] : 2008.05.05 23:39:11.986--ServerSession(30958654)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--file:/C:/opt/jboss422/server/default/tmp/deploy/tmp29686jsfejb3.ear-contents/app.jar-helloworld login successful
+
Database: HSQL Database Engine  Version: 1.8.0
23:39:11,986 INFO  [STDOUT] [EL Finest]: 2008.05.05 23:39:11.986--ServerSession(30958654)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--End deploying Persistence Unit helloworld; state Deployed; factoryCount 1
+
Driver: HSQL Database Engine Driver  Version: 1.8.0
23:39:11,997 INFO  [STDOUT] [EL Finer] : 2008.05.05 23:39:11.997--ServerSession(30958654)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--client acquired
+
10:13:22,596 INFO  [STDOUT] [EL Info]:   2008.05.08 10:13:22.596--ServerSession(2522904)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--file:/C:/opt/jboss422/server/default/tmp/deploy/tmp20649jsfejb3.ear-contents/app.jar-helloworld login successful
23:39:11,998 INFO  [STDOUT] [EL Finer] : 2008.05.05 23:39:11.998--UnitOfWork(11898483)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--TX binding to tx mgr, status=STATUS_ACTIVE
+
10:13:22,621 INFO  [STDOUT] [EL Finest]: 2008.05.08 10:13:22.621--ServerSession(2522904)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--Execute query DataModifyQuery()
23:39:12,000 INFO  [STDOUT] [EL Finest]: 2008.05.05 23:39:11.999--UnitOfWork(11898483)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--Execute query DoesExistQuery()
+
10:13:22,621 INFO  [STDOUT] [EL Finest]: 2008.05.08 10:13:22.621--ServerSession(2522904)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--reconnecting to external connection pool
23:39:12,005 INFO  [STDOUT] [EL Finest]: 2008.05.05 23:39:12.005--UnitOfWork(11898483)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--PERSIST operation called on: Todo@1b2601c.
+
10:13:22,622 INFO  [STDOUT] [EL Fine]:   2008.05.08 10:13:22.622--ServerSession(2522904)--Connection(9673691)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--DROP TABLE TODO
23:39:12,006 INFO  [STDOUT] [EL Finer] : 2008.05.05 23:39:12.006--UnitOfWork(11898483)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--TX beforeCompletion callback, status=STATUS_ACTIVE
+
10:13:22,627 INFO  [STDOUT] [EL Warning]: 2008.05.08 10:13:22.624--ServerSession(2522904)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--Exception [EclipseLink-4002] (Eclipse Persistence Services - 1.0 (Build SNAPSHOT - 20080502)): org.eclipse.persistence.exceptions.DatabaseException
23:39:12,006 INFO  [STDOUT] [EL Finer] : 2008.05.05 23:39:12.006--UnitOfWork(11898483)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--begin unit of work commit
+
Internal Exception: java.sql.SQLException: Table not found: TODO in statement [DROP TABLE TODO]
23:39:12,009 INFO  [STDOUT] [EL Finer] : 2008.05.05 23:39:12.009--ClientSession(18229945)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--TX beginTransaction, status=STATUS_ACTIVE
+
Error Code: -22 Call: DROP TABLE TODO Query: DataModifyQuery()
23:39:12,010 INFO  [STDOUT] [EL Finest]: 2008.05.05 23:39:12.010--UnitOfWork(11898483)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--Execute query InsertObjectQuery(Todo@1b2601c)
+
10:13:22,627 INFO  [STDOUT] [EL Finest]: 2008.05.08 10:13:22.627--ServerSession(2522904)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--Execute query DataModifyQuery()
23:39:12,016 INFO  [STDOUT] [EL Finest]: 2008.05.05 23:39:12.015--ClientSession(18229945)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--reconnecting to external connection pool
+
10:13:22,628 INFO  [STDOUT] [EL Finest]: 2008.05.08 10:13:22.628--ServerSession(2522904)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--reconnecting to external connection pool
23:39:12,016 INFO  [STDOUT] [EL Fine: 2008.05.05 23:39:12.016--ClientSession(18229945)--Connection(14510823)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--INSERT INTO TODO (ID, DESCRIPTION, TITLE, DTYPE) VALUES (?, ?, ?, ?)
+
10:13:22,628 INFO  [STDOUT] [EL Fine]:   2008.05.08 10:13:22.628--ServerSession(2522904)--Connection(24215639)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--CREATE TABLE TODO (ID NUMERIC(19) NOT NULL, DTYPE VARCHAR(31), DESCRIPTION VARCHAR(255), TITLE VARCHAR(255), PRIMARY KEY (ID))
bind => [0, test0, test0, Todo]
+
10:13:22,629 INFO  [STDOUT] [EL Finest]: 2008.05.08 10:13:22.628--ServerSession(2522904)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--End deploying Persistence Unit helloworld; state Deployed; factoryCount 1
23:39:12,265 INFO  [STDOUT] [EL Finer] : 2008.05.05 23:39:12.265--UnitOfWork(11898483)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--TX afterCompletion callback, status=COMMITTED
+
10:13:22,639 INFO  [STDOUT] [EL Finer]: 2008.05.08 10:13:22.639--ServerSession(2522904)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--client acquired
23:39:12,266 INFO  [STDOUT] [EL Finer] : 2008.05.05 23:39:12.266--UnitOfWork(11898483)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--end unit of work commit
+
10:13:22,641 INFO  [STDOUT] [EL Finer]: 2008.05.08 10:13:22.641--UnitOfWork(9517133)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--TX binding to tx mgr, status=STATUS_ACTIVE
23:39:17,431 INFO  [STDOUT] >>>>new Todo: Todo@e77ca4
+
10:13:22,641 INFO  [STDOUT] [EL Finest]: 2008.05.08 10:13:22.641--UnitOfWork(9517133)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--Execute query DoesExistQuery()
23:39:17,433 INFO  [STDOUT] [EL Finer] : 2008.05.05 23:39:17.433--ServerSession(30958654)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--client acquired
+
10:13:22,647 INFO  [STDOUT] [EL Finest]: 2008.05.08 10:13:22.647--UnitOfWork(9517133)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--PERSIST operation called on: Todo@1397218.
23:39:17,433 INFO  [STDOUT] [EL Finer] : 2008.05.05 23:39:17.433--UnitOfWork(1102187)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--TX binding to tx mgr, status=STATUS_ACTIVE
+
10:13:22,648 INFO  [STDOUT] [EL Finer]: 2008.05.08 10:13:22.648--UnitOfWork(9517133)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--TX beforeCompletion callback, status=STATUS_ACTIVE
23:39:17,599 INFO  [STDOUT] [EL Finest]: 2008.05.05 23:39:17.599--UnitOfWork(1102187)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--Execute query ReadAllQuery(Todo)
+
10:13:22,648 INFO  [STDOUT] [EL Finer]: 2008.05.08 10:13:22.648--UnitOfWork(9517133)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--begin unit of work commit
23:39:17,600 INFO  [STDOUT] [EL Finest]: 2008.05.05 23:39:17.600--ServerSession(30958654)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--reconnecting to external connection pool
+
10:13:22,652 INFO  [STDOUT] [EL Finer]: 2008.05.08 10:13:22.652--ClientSession(25769070)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--TX beginTransaction, status=STATUS_ACTIVE
23:39:17,613 INFO  [STDOUT] [EL Fine] : 2008.05.05 23:39:17.613--ServerSession(30958654)--Connection(28560534)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--SELECT ID, DTYPE, DESCRIPTION, TITLE FROM TODO WHERE (DTYPE = ?)
+
10:13:22,653 INFO  [STDOUT] [EL Finest]: 2008.05.08 10:13:22.652--UnitOfWork(9517133)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--Execute query InsertObjectQuery(Todo@1397218)
bind => [Todo]
+
10:13:22,655 INFO  [STDOUT] [EL Finest]: 2008.05.08 10:13:22.655--ClientSession(25769070)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--reconnecting to external connection pool
23:39:17,677 INFO  [STDOUT] [EL Finest]: 2008.05.05 23:39:17.677--UnitOfWork(1102187)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--Register the existing object Todo@11df416
+
10:13:22,655 INFO  [STDOUT] [EL Fine]:   2008.05.08 10:13:22.655--ClientSession(25769070)--Connection(21848338)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--INSERT INTO TODO (ID, DESCRIPTION, TITLE, DTYPE) VALUES (?, ?, ?, ?)
23:39:17,679 INFO  [STDOUT] [EL Finer] : 2008.05.05 23:39:17.678--UnitOfWork(1102187)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--TX beforeCompletion callback, status=STATUS_ACTIVE
+
bind => [0, TEST, TEST, Todo]
23:39:17,679 INFO  [STDOUT] [EL Finer] : 2008.05.05 23:39:17.679--UnitOfWork(1102187)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--begin unit of work commit
+
10:13:22,665 INFO  [STDOUT] [EL Finer]: 2008.05.08 10:13:22.664--UnitOfWork(9517133)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--TX afterCompletion callback, status=COMMITTED
23:39:17,679 INFO  [STDOUT] [EL Finer] : 2008.05.05 23:39:17.679--UnitOfWork(1102187)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--TX afterCompletion callback, status=COMMITTED
+
10:13:22,666 INFO  [STDOUT] [EL Finer]: 2008.05.08 10:13:22.666--UnitOfWork(9517133)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--end unit of work commit
23:39:17,680 INFO  [STDOUT] [EL Finer] : 2008.05.05 23:39:17.679--UnitOfWork(1102187)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--end unit of work commit
+
</pre>
+
Output of http://127.0.0.1:8080/jsfejb3/todos.faces
+
<pre>
+
The Todo List
+
Title Description 
+
test0 test0 Edit
+
 
</pre>
 
</pre>
 +
*Browser Output
 +
[[Image:Jpa_jboss_jsfejb3_screencap.jpg]]
  
 
==References==
 
==References==
 
*See [http://wiki.eclipse.org/EclipseLink/Examples/JPA/JBoss_Web_Tutorial Another example of how to use EclipseLink as JPA provider on the JBoss container.]
 
*See [http://wiki.eclipse.org/EclipseLink/Examples/JPA/JBoss_Web_Tutorial Another example of how to use EclipseLink as JPA provider on the JBoss container.]
 
*See [[EclipseLink/UserGuide/Developing_JPA_Projects_%28ELUG%29|Developing JPA Projects]] in the EclipseLink User's Guide.
 
*See [[EclipseLink/UserGuide/Developing_JPA_Projects_%28ELUG%29|Developing JPA Projects]] in the EclipseLink User's Guide.

Latest revision as of 08:43, 21 June 2012

Contents

[edit] Migrating from Hibernate to EclipseLink within the JBoss JSFEJB3 Example

  • These instructions are for users wishing to use EclipseLink as the JPA provider in place of Hibernate in the JBoss container.

This article may be somewhat out of date. Information for EclipseLink and JBoss AS 7 can be found here: https://community.jboss.org/wiki/HowToUseEclipseLinkWithAS7

  • The scope of this document is a description of the required static weaving workaround for EJBTHREE-572 using the JBoss JSFEJB3 example as reference. See the JPA Migration page for an overall migration example.
  • The EJB3 example on jboss.org will be used as a common open-source example of how to migrate a small container managed web application from using Hibernate to using EclipeLink as the JPA provider.

[edit] persistence.xml Modifications

Note: the defaulted transaction-type attribute of the persistence-unit element.

[edit] Original persistence.xml

<persistence>
   <persistence-unit name="helloworld">
      <provider>org.hibernate.ejb.HibernatePersistence</provider>
      <jta-data-source>java:/DefaultDS</jta-data-source>
      <properties>
         <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
         <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
      </properties>
   </persistence-unit>
</persistence>

[edit] Modified persistence.xml

<xml version="1.0" encoding="UTF-8"?>
<persistence version="1.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_1_0.xsd">
  <persistence-unit name="helloworld">
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    <jta-data-source>java:/DefaultDS</jta-data-source>
    <!-- Entities must be specified for EclipseLink weaving -->
    <class>Todo</class>
    <properties>
      <property name="eclipselink.target-database" value="HSQL"/>
      <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
      <property name="eclipselink.ddl-generation.output-mode" value="database"/>
      <property name="eclipselink.target-server" value="JBoss"/>
      <property name="eclipselink.weaving" value="false"/>
      <property name="eclipselink.logging.level" value="FINEST"/>
    </properties>
  </persistence-unit>
</persistence>
  • The following changes must be done to persistence.xml

[edit] Set target-server

The fix for EJBTHREE-572 requires that the PersistenceUnit state the JBoss platform using the target-server property. We recommend the short name JBoss (but the full package name org.eclipse.persistence.platform.server.jboss.JBossPlatform is supported).

  • See org.eclipse.persistence.config.TargetServer for a list of container platforms supported.
<property name="eclipselink.target-server" value="JBoss"/>

[edit] Set target-database

To continue to use the HSQL (Hypersonic) Database all you need to do is define the target-database in the persistence unit, we recommend the short name HSQL (but the full package name org.eclipse.persistence.platform.database.HSQLPlatform is supported).

  • See org.eclipse.persistence.config.TargetDatabase for a list of databases supported.
<property name="eclipselink.target-database" value="HSQL"/>

[edit] Drop/Create Database

The tables will be automatically dropped and created by EclipseLink with the following 2 properties in the persistence unit. For production environments you would normally already have the schema setup on the database, so using the following schema generation properties will erase any previous existing tables and are normally used for example/demo purposes.

<property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
<property name="eclipselink.ddl-generation.output-mode" value="database"/>

[edit] JTA Datasource Configuration

No changes are required in the deploy directory of JBoss 4.2.2 out of the box to run HSQL.

[edit] @EJB Injection/JNDI lookup Modifications

  • The @EJB injection annotation does not currently work outside of the JBoss EJB container - for example in the servlet container. The solution is to use a custom JNDI lookup which is not in standard JNDI naming format such as "java:comp/env/ejb/jsfejb3/TodoDao" - this code is already on the session DAO bean.
InitialContext ctx = new InitialContext();
return (TodoDaoInt) ctx.lookup("jsfejb3/TodoDao/local");

[edit] Static Weaving / EAR Packaging Modifications

  • This example does not require weaving - this section is for reference and can be skipped.
  • 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
  • Note: that the ant task references persistence.jar, eclipselink.jar and the persistence 1.0 XSD - you may reference these where they exist on your system.
  • Note: persistence.xml must have both the <xml> element declaration and the namespace validation references in the <persistence> element.
  • Ant static weaving ant task
<target name="run-weaver">
  <taskdef name="weave" classname="org.eclipse.persistence.tools.weaving.jpa.StaticWeaveAntTask">
    <classpath>
      <pathelement path="${libs}/persistence.jar"/>
      <pathelement path="${libs}/eclipselink.jar"/>
      <pathelement path="${libs}/persistence_1_0.xsd"/>
    </classpath>
  </taskdef>
 
  <!-- process the weaving function, persistenceInfo references persistence.xml -->
  <weave source="build/classes_unweaved"
    target="build/classes"
    persistenceinfo="build/jars/app_unweaved.jar"
    loglevel="FINEST">
  </weave>
</target>

[edit] Results

[edit] Building

  • 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\classes_unweaved
    [javac] Compiling 5 source files to C:\wse\w34b\jbossHWEAR\build\classes_unweaved
    [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\app_unweaved.jar
run-weaver:
    [weave] [EL Finer] : 2008.05.05 16:30:41.216--ServerSession(29857804)--Thread(Thread[main,5,main])--Searching for default mapping file in file:/C:/wse/w34b/jbossHWEAR/build/jars/app_unweaved.jar
    [weave] [EL Finer] : 2008.05.05 16:30:41.246--ServerSession(29857804)--Thread(Thread[main,5,main])--Found a default mapping file at jar:file:/C:/wse/w34b/jbossHWEAR/build/jars/app_unweaved.jar!/META-INF/orm.xml for root URL file:/C:/wse/w34b/jbossHWEAR/build/jars/app_unweaved.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 name 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 element [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 element [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 transformer processing class [Todo].
    [weave] [EL Finest]: 2008.05.05 16:30:42.020--ServerSession(29857804)--Thread(Thread[main,5,main])--Weaved persistence (PersistenceEntity) [Todo].
    [weave] [EL Finest]: 2008.05.05 16:30:42.029--ServerSession(29857804)--Thread(Thread[main,5,main])--Weaved change tracking (ChangeTracker) [Todo].
    [weave] [EL Finest]: 2008.05.05 16:30:42.040--ServerSession(29857804)--Thread(Thread[main,5,main])--Weaved fetch groups (FetchGroupTracker) [Todo].
    [weave] [EL Finest]: 2008.05.05 16:30:42.053--ServerSession(29857804)--Thread(Thread[main,5,main])--End weaver class transformer 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

[edit] Weaving or Instrumentation

  • A diff of the unweaved and weaved bytecode will look like the following.

Eclipselink jboss weaving bytecode diff.jpg

[edit] Deployment

  • Make sure the JBoss server is running when the ear is copied to the deploy directory or start the server.

10:13:11,063 INFO  [JmxKernelAbstraction] 	jboss.jca:name=DefaultDS,service=DataSourceBinding
10:13:11,064 INFO  [PersistenceUnitDeployment] Starting persistence unit persistence.units:ear=jsfejb3.ear,jar=app.jar,unitName=helloworld
10:13:11,230 INFO  [STDOUT] [EL Warning]: 2008.05.08 10:13:11.205--Thread(Thread[main,5,jboss])--The temporary classLoader for PersistenceLoadProcessor [helloworld] is not available.  Switching classLoader to [org.jboss.mx.loading.UnifiedClassLoader3@182d86{ url=file:/C:/opt/jboss422/server/default/tmp/deploy/tmp20649jsfejb3.ear ,addedOrder=45}].  Weaving has been disabled for this session. EclipseLink may be unable to get a spec mandated temporary class loader from the server, you may be able to use static weaving as an optional workaround. 
10:13:11,238 INFO  [STDOUT] [EL Finest]:  2008.05.08 10:13:11.231--ServerSession(2522904)--Thread(Thread[main,5,jboss])--Begin predeploying Persistence Unit helloworld; state Initial; factoryCount 0
10:13:11,241 INFO  [STDOUT] [EL Finest]:  2008.05.08 10:13:11.241--ServerSession(2522904)--Thread(Thread[main,5,jboss])--property=eclipselink.weaving; value=true
10:13:11,241 INFO  [STDOUT] [EL Finest]:  2008.05.08 10:13:11.241--ServerSession(2522904)--Thread(Thread[main,5,jboss])--property=eclipselink.orm.throw.exceptions; default value=true
10:13:11,259 INFO  [STDOUT] [EL Finer]:   2008.05.08 10:13:11.256--ServerSession(2522904)--Thread(Thread[main,5,jboss])--Searching for default mapping file in file:/C:/opt/jboss422/server/default/tmp/deploy/tmp20649jsfejb3.ear-contents/app.jar
10:13:11,264 INFO  [STDOUT] [EL Finer]:   2008.05.08 10:13:11.263--ServerSession(2522904)--Thread(Thread[main,5,jboss])--Found a default mapping file at jar:file:/C:/opt/jboss422/server/default/tmp/deploy/tmp20649jsfejb3.ear-contents/app.jar!/META-INF/orm.xml for root URL file:/C:/opt/jboss422/server/default/tmp/deploy/tmp20649jsfejb3.ear-contents/app.jar
10:13:12,007 INFO  [STDOUT] [EL Config]:  2008.05.08 10:13:12.006--ServerSession(2522904)--Thread(Thread[main,5,jboss])--The table name for entity [Todo] is being defaulted to: TODO.
10:13:12,011 INFO  [STDOUT] [EL Config]:  2008.05.08 10:13:12.011--ServerSession(2522904)--Thread(Thread[main,5,jboss])--The discriminator column name for the root inheritance class [class Todo] is being defaulted to: DTYPE.
10:13:12,042 INFO  [STDOUT] [EL Config]:  2008.05.08 10:13:12.042--ServerSession(2522904)--Thread(Thread[main,5,jboss])--The column name for element [public java.lang.String Todo.getDescription()] is being defaulted to: DESCRIPTION.
10:13:12,046 INFO  [STDOUT] [EL Config]:  2008.05.08 10:13:12.046--ServerSession(2522904)--Thread(Thread[main,5,jboss])--The column name for element [public java.lang.String Todo.getTitle()] is being defaulted to: TITLE.
10:13:12,048 INFO  [STDOUT] [EL Finest]:  2008.05.08 10:13:12.048--ServerSession(2522904)--Thread(Thread[main,5,jboss])--End predeploying Persistence Unit helloworld; state Predeployed; factoryCount 1
10:13:12,088 INFO  [JmxKernelAbstraction] creating wrapper delegate for: org.jboss.ejb3.stateless.StatelessContainer
10:13:12,092 INFO  [JmxKernelAbstraction] installing MBean: jboss.j2ee:ear=jsfejb3.ear,jar=app.jar,name=TodoDao,service=EJB3 with dependencies:
10:13:12,092 INFO  [JmxKernelAbstraction] 	persistence.units:ear=jsfejb3.ear,jar=app.jar,unitName=helloworld
10:13:12,231 INFO  [EJBContainer] STARTED EJB: TodoDao ejbName: TodoDao
10:13:12,253 INFO  [EJB3Deployer] Deployed: file:/C:/opt/jboss422/server/default/tmp/deploy/tmp20649jsfejb3.ear-contents/app.jar
10:13:12,257 INFO  [TomcatDeployer] deploy, ctxPath=/jsfejb3, warUrl=.../tmp/deploy/tmp20649jsfejb3.ear-contents/app-exp.war/
10:13:12,704 INFO  [EARDeployer] Started J2EE application: file:/C:/opt/jboss422/server/default/deploy/jsfejb3.ear

[edit] Runtime Add new TODO and display

10:13:22,482 INFO  [STDOUT] >>>>new Todo: Todo@1397218
10:13:22,525 INFO  [STDOUT] [EL Finest]: 2008.05.08 10:13:22.525--ServerSession(2522904)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--property=eclipselink.target-server; value=org.eclipse.persistence.platform.server.jboss.JBossPlatform
10:13:22,526 INFO  [STDOUT] [EL Finest]: 2008.05.08 10:13:22.526--ServerSession(2522904)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--property=eclipselink.target-database; value=org.eclipse.persistence.platform.database.HSQLPlatform
10:13:22,556 INFO  [STDOUT] [EL Config]: 2008.05.08 10:13:22.556--ServerSession(2522904)--Connection(28982303)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--Connected: jdbc:hsqldb:C:\opt\jboss422\server\default\data\hypersonic\localDB
	User: SA
	Database: HSQL Database Engine  Version: 1.8.0
	Driver: HSQL Database Engine Driver  Version: 1.8.0
10:13:22,596 INFO  [STDOUT] [EL Info]:   2008.05.08 10:13:22.596--ServerSession(2522904)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--file:/C:/opt/jboss422/server/default/tmp/deploy/tmp20649jsfejb3.ear-contents/app.jar-helloworld login successful
10:13:22,621 INFO  [STDOUT] [EL Finest]: 2008.05.08 10:13:22.621--ServerSession(2522904)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--Execute query DataModifyQuery()
10:13:22,621 INFO  [STDOUT] [EL Finest]: 2008.05.08 10:13:22.621--ServerSession(2522904)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--reconnecting to external connection pool
10:13:22,622 INFO  [STDOUT] [EL Fine]:   2008.05.08 10:13:22.622--ServerSession(2522904)--Connection(9673691)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--DROP TABLE TODO
10:13:22,627 INFO  [STDOUT] [EL Warning]: 2008.05.08 10:13:22.624--ServerSession(2522904)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--Exception [EclipseLink-4002] (Eclipse Persistence Services - 1.0 (Build SNAPSHOT - 20080502)): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Table not found: TODO in statement [DROP TABLE TODO]
Error Code: -22 Call: DROP TABLE TODO Query: DataModifyQuery()
10:13:22,627 INFO  [STDOUT] [EL Finest]: 2008.05.08 10:13:22.627--ServerSession(2522904)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--Execute query DataModifyQuery()
10:13:22,628 INFO  [STDOUT] [EL Finest]: 2008.05.08 10:13:22.628--ServerSession(2522904)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--reconnecting to external connection pool
10:13:22,628 INFO  [STDOUT] [EL Fine]:   2008.05.08 10:13:22.628--ServerSession(2522904)--Connection(24215639)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--CREATE TABLE TODO (ID NUMERIC(19) NOT NULL, DTYPE VARCHAR(31), DESCRIPTION VARCHAR(255), TITLE VARCHAR(255), PRIMARY KEY (ID))
10:13:22,629 INFO  [STDOUT] [EL Finest]: 2008.05.08 10:13:22.628--ServerSession(2522904)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--End deploying Persistence Unit helloworld; state Deployed; factoryCount 1
10:13:22,639 INFO  [STDOUT] [EL Finer]:  2008.05.08 10:13:22.639--ServerSession(2522904)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--client acquired
10:13:22,641 INFO  [STDOUT] [EL Finer]:  2008.05.08 10:13:22.641--UnitOfWork(9517133)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--TX binding to tx mgr, status=STATUS_ACTIVE
10:13:22,641 INFO  [STDOUT] [EL Finest]: 2008.05.08 10:13:22.641--UnitOfWork(9517133)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--Execute query DoesExistQuery()
10:13:22,647 INFO  [STDOUT] [EL Finest]: 2008.05.08 10:13:22.647--UnitOfWork(9517133)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--PERSIST operation called on: Todo@1397218.
10:13:22,648 INFO  [STDOUT] [EL Finer]:  2008.05.08 10:13:22.648--UnitOfWork(9517133)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--TX beforeCompletion callback, status=STATUS_ACTIVE
10:13:22,648 INFO  [STDOUT] [EL Finer]:  2008.05.08 10:13:22.648--UnitOfWork(9517133)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--begin unit of work commit
10:13:22,652 INFO  [STDOUT] [EL Finer]:  2008.05.08 10:13:22.652--ClientSession(25769070)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--TX beginTransaction, status=STATUS_ACTIVE
10:13:22,653 INFO  [STDOUT] [EL Finest]: 2008.05.08 10:13:22.652--UnitOfWork(9517133)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--Execute query InsertObjectQuery(Todo@1397218)
10:13:22,655 INFO  [STDOUT] [EL Finest]: 2008.05.08 10:13:22.655--ClientSession(25769070)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--reconnecting to external connection pool
10:13:22,655 INFO  [STDOUT] [EL Fine]:   2008.05.08 10:13:22.655--ClientSession(25769070)--Connection(21848338)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--INSERT INTO TODO (ID, DESCRIPTION, TITLE, DTYPE) VALUES (?, ?, ?, ?)
	bind => [0, TEST, TEST, Todo]
10:13:22,665 INFO  [STDOUT] [EL Finer]: 2008.05.08 10:13:22.664--UnitOfWork(9517133)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--TX afterCompletion callback, status=COMMITTED
10:13:22,666 INFO  [STDOUT] [EL Finer]: 2008.05.08 10:13:22.666--UnitOfWork(9517133)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--end unit of work commit
  • Browser Output

Jpa jboss jsfejb3 screencap.jpg

[edit] References