EJBs

Custom Security-Domain and RolesAllowed EJB3 on JBossAS7.1.1Final

Hi,

In our previous demos we have already seen that how to remotely access the EJBs deployed on “JBoss AS 7.1.1.Final”. So in this example we will see how to invoke an EJB which is secured. Here we will use the “jboss-ejb3.xml” file which is a new container specific deployment descriptor for the EJBs. Also we will an alternative option of defining the security domain for our ejbs using annotation “@org.jboss.ejb3.annotation.SecurityDomain”

In this article we are going to see an easiest way to lookup a Secured EJBs remotely in >”JBoss AS7.1.1.Final”

Point-1). How to create a separate Security Realm for our EJBs inside “standalone-full.xml”.

Point-2). How to create a separate Security Domain for our EJBs inside “standalone-full.xml”.

Point-3). How to use the “jboss-ejb3.xml” file inside the EJB jar file in order to associate it with the security domain?

Point-4). How to use the annotation “@org.jboss.ejb3.annotation.SecurityDomain” sothat we will not need to write the addiaional deployment descriptor “jboss-ejb3.xml”

Point-5). A properties file need to be placed in the Clients CLASSPATH with name “jboss-ejb-client.properties”, with some additional properties.

The whole article will be divided into two Parts 1) the Server side configuration and 2). the Application Level Settings from the Client side.

Source Code (Git Repo) Source Code for this Demo Can be downloaded from GIT Repository:
https://github.com/jaysensharma/MiddlewareMagicDemos/tree/master/Custom_SecurtyDomain_EJB3_AS711

JBossAS7 side configuration changes

Here we will first see what all changes are required from the JBoss side in order to create a separate Security Realm and Security Domain for our EJBs.
Step-1). Open the “$JBOSS_HOME/standaone/configuration/standalone-full.xml” file and then add a new Security Realm there inside the tag as following:

   <security-realm name="EJBRealm">
      <authentication>
         <jaas name="ejb-security-domain"/>
      </authentication>
   </security-realm>

Step-2). As the above Security Realm is pointing to a security Domain “ejb-security-domain” so let’s create a new Security Realm inside the [subsystem xmlns=”urn:jboss:domain:security:1.1″] subsystem as following:

     <security-domain name="ejb-security-domain" cache-type="default">
         <authentication>
           <login-module code="Remoting" flag="optional">
             <module-option name="password-stacking" value="useFirstPass"/>
           </login-module>
           <login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule" flag="required">
             <module-option name="defaultUsersProperties" value="${jboss.server.config.dir}/ejb-users.properties"/>
             <module-option name="defaultRolesProperties" value="${jboss.server.config.dir}/ejb-roles.properties"/>
             <module-option name="usersProperties" value="${jboss.server.config.dir}/ejb-users.properties"/>
             <module-option name="rolesProperties" value="${jboss.server.config.dir}/ejb-roles.properties"/>
             <module-option name="password-stacking" value="useFirstPass"/>
           </login-module>
         </authentication>
     </security-domain>

Step-3). Also as we know that the EJBs are accessed remotely using the JBoss Remoting so we will need to make sure that the remoting subsystem is also using the Security Realm (EJBRealm) which we created as following:

    <subsystem xmlns="urn:jboss:domain:remoting:1.1">
       <connector name="remoting-connector" socket-binding="remoting" security-realm="EJBRealm"/>
    </subsystem>

Step-4). As our Security domain is using two properties file so we will need to create those properties file as well inside “$JBOSS_HOME/standaone/configuration/” as following:

ejb-users.properties

ejbUser=ejbPassword

ejb-roles.properties

ejbUser=ejbRole

Step-5). Now start the JBoss AS7.1.1.Final as following:

./standalone.sh -c standalone-full.xml

Developing Secure EJB3 Application

As the Server side configurations are done so now we will proceed with developing the Secure EJB3 application.

Step-6). Create a directory somewhere in your file system like “/home/userone/Custom_SecurtyDomain_EJB3_AS711” and then create another directory with name “src” inside the “/home/userone/Custom_SecurtyDomain_EJB3_AS711” directory.

Step-7). Write the EJB Stateless Bean class “CallerBean.java” as following inside the directory “/home/userone/Custom_SecurtyDomain_EJB3_AS711/src”:

package remote;
import javax.ejb.*;
import javax.naming.*;
import java.util.*;
import javax.annotation.Resource;
import javax.annotation.security.DeclareRoles;
import javax.annotation.security.RolesAllowed;
import javax.ejb.LocalBean;
import javax.ejb.SessionContext;

@Stateless  
@Remote(CallerRemote.class)

/*
   If you dont want to use "META-INF/jboss-ejb3.xml" then you can use 
   the following annotation to defing your security-domain
   @org.jboss.ejb3.annotation.SecurityDomain("ejb-security-domain")
*/

public class CallerBean implements CallerRemote
 {
     @Resource
     private SessionContext sessionContext;

     @RolesAllowed("ejbRole")
     public String testMethod(String name)
	    {
		   System.out.println("nntBean's testMethod(String name) called....");
                   System.out.println("nntUserName: '" + sessionContext.getCallerPrincipal().getName() + "' is able to access testMethod()");
                   if (sessionContext.isCallerInRole("ejbRole"))
                         System.out.println("tUser is in   "ejbRole"   ");
                   else
                         System.out.println("tUser is NOT in an allowed role");
		   return "[CallerBean] testMethod() returned Hello "+name;
	    }


     public String commonMethod(String name)
	    {
		   System.out.println("nntBean's commonMethod(String name) called....");
                   System.out.println("nnUser " + sessionContext.getCallerPrincipal().getName() + " is able to access commonMethod()");
                   if (sessionContext.isCallerInRole("ejbRole"))
                         System.out.println("t##### commonMethod()  User is in ejbRole");
                   else
                         System.out.println("t##### commonMethod()  User is NOT in ejbRole");
		   return "[CallerBean] commonMethod() returned Hello "+name;
	    }
 }

Step-8). Write the EJB Remote Interface “CallerRemote.java” as following inside the directory “/home/userone/Custom_SecurtyDomain_EJB3_AS711/src”:

package remote;
public interface CallerRemote
{
     public String testMethod(String name);
     public String commonMethod(String name);
}

Step-9). In order to secure the EJB we will define the security domain inside the “jboss-ejb3.xml” file. Spo create a file with this name inside “/home/userone/Custom_SecurtyDomain_EJB3_AS711/src” as following:


<?xml version="1.0"?>  
<jboss:ejb-jar xmlns:jboss="http://www.jboss.com/xml/ns/javaee"
   xmlns="http://java.sun.com/xml/ns/javaee"
   xmlns:s="urn:security"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee http://www.jboss.org/j2ee/schema/jboss-ejb3-2_0.xsd
   http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd"
   version="3.1"
   impl-version="2.0">
  <assembly-descriptor>
    <s:security>
      <ejb-name>*</ejb-name>
          <s:security-domain>ejb-security-domain</s:security-domain>
    </s:security>
  </assembly-descriptor>

</jboss:ejb-jar>

Step-10). As we are going to create an EAR file containing the above Stateless Session Bean so We will write the “application.xml” as following inside the directory “/home/userone/Custom_SecurtyDomain_EJB3_AS711/src”:

<?xml version="1.0" encoding="UTF-8"?>
<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:application="http://java.sun.com/xml/ns/javaee/application_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_5.xsd" id="Application_ID" version="5">
  <module>
    <ejb>remoteEJB.jar</ejb>
  </module>
</application>

Developing EJB3 Remote Client

Step-11). Now we will write the Client side code to access the Above mentioned EJB Remotely so create a class “TestRemoteClientA.java” as following inside the directory “/home/userone/Custom_SecurtyDomain_EJB3_AS711/src”:

package client;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import java.util.Properties;
import remote.CallerRemote;
public class TestRemoteClientA
  {
      public static void main(String ar[]) throws Exception 
       {
          Context context=null;
       try
         {
                Properties props = new Properties();
                props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
                props.put(Context.PROVIDER_URL, "remote://localhost:4447"); 
                props.put(Context.SECURITY_PRINCIPAL, "ejbUser");
                props.put(Context.SECURITY_CREDENTIALS, "ejbPassword");

                //props.put("jboss.naming.client.remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED","true");
                //props.put("jboss.naming.client.connect.options.org.xnio.Options.SSL_STARTTLS","true");

                props.put("jboss.naming.client.ejb.context", true);
                props.put("jboss.naming.client.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT", "false");
                context = new InitialContext(props);	
	        System.out.println("nt--------------------------nGot initial Context: "+context);		
         }
       catch (Exception e)
         {
                e.printStackTrace();
          }

         // Lookup Format will be 
         // <app-name>/<module-name>/<distinct-name>/<bean-name>!<fully-qualified-classname-of-the-remote-interface>
   
         CallerRemote remote=(CallerRemote)context.lookup("TestRemoteEJBEAR/remoteEJB//CallerBean!remote.CallerRemote");
         //System.out.println("nt remote.testMethod("Common-MiddlewareMagic") = "+remote.commonMethod("Common-MiddlewareMagic"));

         System.out.println("nt remote.testMethod("MiddlewareMagic") = "+remote.testMethod("MiddlewareMagic"));
       }
  }

Step-12). Almost everything is done, so we will create a client side logging file sothat we will get the desired logging at the Remote EJB Client side. So lets create a file “logging.properties” inside “/home/userone/Custom_SecurtyDomain_EJB3_AS711/src” as following:


# Logging
handlers =  java.util.logging.ConsoleHandler
.level = ALL
INFO

# Console Logging
java.util.logging.ConsoleHandler.level=SEVERE

Step-13). Now the most important part of building / deploying and running the application so in order to achieve that we will create a simple ant build script, So Create a “build.xml” file inside the “/home/userone/Custom_SecurtyDomain_EJB3_AS711” directory as following:

<project name="EJB3_SecurityDomain_Service" default="all">
<property name="jboss.home" value="/NotBackedUp/JBoss_All/jboss-as-7.1.1.Final" />
<property name="jboss.module.dir" value="${jboss.home}/modules" />
<property name="basedir" value="." />
<property name="tmp.dir" value="tmp" />
<property name="src.dir" value="src" />
<property name="output.dir" value="build" />
<property name="ear.name" value="TestRemoteEJBEAR.ear" />
<property name="ejb.jar" value="remoteEJB.jar" />
<property name="client.jar.name" value="remoteEJBClient.jar" />

        <path id="jboss.classpath">
           <fileset dir="${jboss.module.dir}">
               <include name="**/*.jar"/>
           </fileset>  
        </path>

        <!-- Client Needs the following Jar to be present in the CLASSPATH including -->
        <path id="jboss.new.client.classpath">
           <fileset dir="${jboss.home}/bin/client" >
               <include name="jboss-client.jar" />
           </fileset>  
        </path>
	 
        <target name="all" depends="deploy" />

        <target name="build_ear">
           <delete dir="${tmp.dir}" />
           <mkdir dir="${tmp.dir}/META-INF" />
           <javac srcdir="${src.dir}" destdir="${tmp.dir}"  includes="*.java" excludes="TestRemoteClientA.java" classpathref="jboss.classpath"/>
           <copy file="${src.dir}/jboss-ejb3.xml" todir="${tmp.dir}/META-INF"/>
           <jar jarfile="${tmp.dir}/${ejb.jar}" basedir="${tmp.dir}" compress="true" />

           <delete file="${tmp.dir}/ejb-users.properties"/>
           <delete file="${tmp.dir}/ejb-roles.properties"/>
           <delete file="${tmp.dir}/META-INF/jboss-ejb3.xml"/>

           <delete includeEmptyDirs="true">
              <fileset dir="${tmp.dir}/remote"/>
           </delete> 
           <mkdir dir="${tmp.dir}/META-INF"/>
           <copy todir="${tmp.dir}/META-INF">
                <fileset dir="${src.dir}/">
                  <include name="application.xml"/> 
                </fileset>
           </copy>           
           <jar jarfile="${tmp.dir}/${ear.name}" basedir="${tmp.dir}" compress="true" />
           <delete includeEmptyDirs="true">
              <fileset dir="${tmp.dir}/META-INF"/>
           </delete> 
           <delete file="${tmp.dir}/${ejb.jar}"/>

           <copy file="${tmp.dir}/${ear.name}" tofile="${output.dir}/${ear.name}"/>
           <delete file="${tmp.dir}/${ear.name}"/>
        </target>


        <target name="deploy" depends="build_ear">
            <echo message="*******************  Deploying the EAR file ${ear.name} *********************" />  
            <echo message="********** ${output.dir}/${ear.name} to ${jboss.home}/standalone/deployments **********" />  
            <copy todir="${jboss.home}/standalone/deployments/">
                <fileset dir="${output.dir}/">
                  <include name="${ear.name}"/> 
                </fileset>
            </copy>
            <echo message="*******************  Deployed Successfully   *********************" />  
        </target>


        <target name="run">
           <delete dir="${tmp.dir}" />
           <mkdir dir="${tmp.dir}" />
           <javac srcdir="${src.dir}" destdir="${tmp.dir}"  includes="CallerRemote.java,TestRemoteClientA.java" classpathref="jboss.classpath"/>          
           <jar jarfile="${output.dir}/${client.jar.name}" basedir="${tmp.dir}" compress="true" />
           <delete dir="${tmp.dir}"/>
           <java classname="client.TestRemoteClientA" fork="true">
               <classpath>
                  <pathelement location="${output.dir}/${client.jar.name}"/>
                  <path refid="jboss.new.client.classpath"/>
               </classpath>

               <!-- Note Here we are passing the Client side logging related file to the JVM -->
               <sysproperty key="java.util.logging.manager" value="java.util.logging.LogManager"/>
               <sysproperty key="java.util.logging.config.file" value="${src.dir}/logging.properties"/>
               <sysproperty key="java.util.logging.ConsoleHandler.level" value="SEVERE" />
           </java>
        </target>        
    
</project>


NOTE: The only change in the above file you need to do is to change the “jboss.home” directory path in the second line of the above script to point to your own JBoss AS7 directory.

Step-15). Now before running your ANT script to build and deploy the above webapplication you should have the ANT as well as JAVA set in the $PATH variable of the Shell / command prompt as following:

For Unix Based OS:
export PATH=/home/userone/jdk1.6.0_21/bin:/home/userone/org.apache.ant_1.6.5/bin:$PATH

For Windows Based OS:
set PATH=C:/jdk1.6.0_21/bin;C:/org.apache.ant_1.6.5/bin;%PATH%

Step-16). Now once the PATH is set In the command/Shell prompt you can move inside the directory “/home/userone/Custom_SecurtyDomain_EJB3_AS711” and then run the ant to build and deploy the EJB based EAR applicationon your JBoss Standalone full profile, by running the command “ant deploy”

[userone@localhost Custom_SecurtyDomain_EJB3_AS711]$ ant deploy
Buildfile: build.xml

build_ear:
    [mkdir] Created dir: /home/userone/Custom_SecurtyDomain_EJB3_AS711/tmp/META-INF
    [javac] Compiling 2 source files to /home/userone/Custom_SecurtyDomain_EJB3_AS711/tmp
     [copy] Copying 1 file to /home/userone/Custom_SecurtyDomain_EJB3_AS711/tmp/META-INF
      [jar] Building jar: /home/userone/Custom_SecurtyDomain_EJB3_AS711/tmp/remoteEJB.jar
   [delete] Deleting: /home/userone/Custom_SecurtyDomain_EJB3_AS711/tmp/META-INF/jboss-ejb3.xml
     [copy] Copying 1 file to /home/userone/Custom_SecurtyDomain_EJB3_AS711/tmp/META-INF
      [jar] Building jar: /home/userone/Custom_SecurtyDomain_EJB3_AS711/tmp/TestRemoteEJBEAR.ear
   [delete] Deleting: /home/userone/Custom_SecurtyDomain_EJB3_AS711/tmp/remoteEJB.jar
     [copy] Copying 1 file to /home/userone/Custom_SecurtyDomain_EJB3_AS711/build
   [delete] Deleting: /home/userone/Custom_SecurtyDomain_EJB3_AS711/tmp/TestRemoteEJBEAR.ear

deploy:
     [echo] *******************  Deploying the EAR file TestRemoteEJBEAR.ear *********************
     [echo] ********** build/TestRemoteEJBEAR.ear to /home/userone/jboss-as-7.1.1.Final//standalone/deployments **********
     [copy] Copying 1 file to /home/userone/jboss-as-7.1.1.Final//standalone/deployments
     [echo] *******************  Deployed Successfully   *********************

BUILD SUCCESSFUL
Total time: 2 seconds

Step-17). Now we will try to compile and run the EJB3 remote Client application by running the command “ant run”

[userone@localhost Custom_SecurtyDomain_EJB3_AS711]$ ant run
Buildfile: build.xml

run:
   [delete] Deleting directory /home/userone/Custom_SecurtyDomain_EJB3_AS711/tmp
    [mkdir] Created dir: /home/userone/Custom_SecurtyDomain_EJB3_AS711/tmp
     [copy] Copying 1 file to /home/userone/Custom_SecurtyDomain_EJB3_AS711/tmp
    [javac] Compiling 2 source files to /home/userone/Custom_SecurtyDomain_EJB3_AS711/tmp
      [jar] Building jar: /home/userone/Custom_SecurtyDomain_EJB3_AS711/build/remoteEJBClient.jar
   [delete] Deleting directory /home/userone/Custom_SecurtyDomain_EJB3_AS711/tmp
      
      	--------------------------
      Got initial Context: javax.naming.InitialContext@5ff3ce5c
      
      	 remote.testMethod("MiddlewareMagic") = [CallerBean] testMethod() returned Hello MiddlewareMagic

BUILD SUCCESSFUL
Total time: 3 seconds

.
.
Thanks πŸ™‚
Middleware Magic Team


JPA2 with OpenJPA 2.2.0 in JBossAS7.1.1

Hi,

In Our previous demo we saw how we can use Oracle TopLink 12c with JBossAS7 as persistence provider. http://middlewaremagic.com/jboss/?p=1983
Here in this example we will see how we can use the Open JPA in JBossAS7 as a persistence provider.

As we already know that the JBoss Application Server7 JPA subsystem implements the JPA 2.0 container-managed requirements. JPA Applications use the Hibernate (core) 4.0 persistence provider, that is included with JBoss AS7. Hibernate 4 is packaged with the AS and is the default persistence provider. The JPA 2.0 Specifications can be found in the following link: http://jcp.org/aboutJava/communityprocess/pfd/jsr317/index.html

However in this current Demo we will just create a Simple JPA persistence unit With the help of “Open JPA 2.2.0” and then we will try to insert some employee detils inside the DataBase. So basically this is just as a startup.

In this example we will mainly focus on following points

Point-1). We will see how to use “Open JPA 2.2.0” with JBossAS7.1.1.Final.

Point-2). For Web Applications we should put the “persistence.xml” file inside “${WEB_APPLICATION}/WEB-INF/classes/META-INF/persistence.xml” AND For EJB Applications we should put the “persistence.xml” file inside “${EJB_JAR}/META-INF”

Point-3). To inject the EntityManager inside our Web Components we can use the annotation @javax.persistence.PersistenceContext(unitName=”name”)

Point-4). We can use the @javax.ejb.EJB annotation to inject an Enterprise Java Bean inside our app components. Like @EJB(lookup=”jndiName”)

Point-5). We will also see how to create a openJPA custom module and how to use the “jboss-deployment-structure.xml” file.

Point-6). We will see what error we get when we dont define following property in our “persistence.xml” file while using OpenJPA .

           <property name="openjpa.DynamicEnhancementAgent" value="false"/>
           <property name="openjpa.RuntimeUnenhancedClasses" value="supported" />

Point-7). The Full Demo can be downloaded from the following Github repository:
https://github.com/jaysensharma/MiddlewareMagicDemos/tree/master/JPA2_And_OpenJPA_On_AS7

Creating DataSource On JBossAS7

Step-1). Here we are using JBoss AS7 latest build “jboss-as-7.1.1.Final” which can be downloaded from the following link: http://www.jboss.org/jbossas/downloads

Step-2). In order to get more details on how to create MySQL DataSource in JBoss AS7 you can refer to the following article: http://middlewaremagic.com/jboss/?p=872
Just place the “mysql-connector-java-5.1.13-bin.jar” MySQL Jdbc driver in your JBoss Deployments directory, Then create a DataSource inside “${JBOSS_HOME}/standalone/configuration/standalone-full.xml” file as following:

        <subsystem xmlns="urn:jboss:domain:datasources:1.0">
            <datasources>

                <!-- Below is the DataSource Configuration which we added for our JPA TestCase-->
                <datasource jta="false" jndi-name="java:/MySqlDS" pool-name="MySqlDS_Pool" enabled="true" use-ccm="false">
                    <connection-url>jdbc:mysql://localhost:3306/testDB</connection-url>
                    <driver-class>com.mysql.jdbc.Driver</driver-class>
                    <driver>mysql-connector-java-5.1.13-bin.jar</driver>
                    <security>
                        <user-name>someDBUserName</user-name>
                        <password>someDBPassword</password>
                    </security>
                </datasource>
                <drivers>
                    <driver name="h2" module="com.h2database.h2">
                        <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
                    </driver>
                </drivers>
            </datasources>
        </subsystem>

Creating OpenJPA 2.2.0 Module In JBossAS7

Step-3). Download the “OpenJPA 2.2.0” (apache-openjpa-2.2.0-binary.zip) from the following link:
http://openjpa.apache.org/downloads.html

Step-4). Extract the downloaded “apache-openjpa-2.2.0-binary.zip” and then copy the two Jars “apache-openjpa-2.2.0/lib/serp-1.13.1.jar” And “apache-openjpa-2.2.0/openjpa-all-2.2.0.jar”

Step-5). Create the following directory structure [jboss-as-7.1.1.Final/modules/org/eclipse/persistence/jpa/main] in your file system so that the OpenJPA 2.2.0 Module can be created.

     .
     .Β Β 
     jboss-as-7.1.1.Final/modules/
     β”‚Β Β 
     β”œβ”€β”€org
     β”‚Β Β  β”‚Β Β      
     β”‚Β Β  β”œβ”€β”€ apache
     β”‚Β Β  β”‚Β Β  β”‚Β 
     β”‚Β Β  β”‚Β Β  β”œβ”€β”€ openjpa
  Β Β                 β”‚Β 
                      ── main
                         β”œβ”€β”€ module.xml
               Β          β”œ
               Β          β”œβ”€β”€ openjpa-all-2.2.0.jar
               Β          β”œ
               Β          β”œβ”€β”€ serp-1.13.1.jar

Paste the “openjpa-all-2.2.0.jar” And “serp-1.13.1.jar” from downloaded OpenJPA s/w into the “jboss-as-7.1.1.Final/modules/org/apache/openjpa/main” and then write the following kind of “module.xml” file:

<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="org.apache.openjpa">
    <resources>
        <resource-root path="openjpa-all-2.2.0.jar"/>
        <resource-root path="serp-1.13.1.jar"/>
    </resources>

        <dependencies> 
            <module name="javax.persistence.api"/> 
            <module name="javax.transaction.api"/> 
            <module name="javax.validation.api"/> 
        </dependencies> 
</module>

Step-6). Restart your JBoss AS7 from inside “/home/userone/jboss-as-7.1.1.Final/bin” directory as following:

.
 ./standalone.sh -c standalone-full.xml
.

Developing OpenJPA 2.2.0 JPA Demo

Step1). Create a directory somewhere in your filesystem like “/home/userone/JPA2_And_OpenJPA_On_AS7” where we will place our application build related stuff. Then create another directory “src” inside “/home/userone/JPA2_And_OpenJPA_On_AS7” where we will be placing our source codes and JSPs.

Step2). Now first of all we will create an Entity “Employee.java” as following inside the “/home/userone/JPA2_And_OpenJPA_On_AS7/src” directory.

package jpa;
import java.io.Serializable;
import javax.persistence.*;
import java.lang.Integer;

@Entity
@Table(name="Employee")
public class Employee implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	private Integer empno;

	private String ename;

    public Employee() {
    	System.out.println("Employee Object Created. this: "+this);
    }

	public Integer getEmpno() {
		return this.empno;
	}

	public void setEmpno(Integer empno) {
		this.empno = empno;
	}

	public String getEname() {
		return this.ename;
	}

	public void setEname(String ename) {
		this.ename = ename;
	}

}

Step3). Now we will create a Simple Stateless SessionBean remote Interface “EmployeeServiceRemote.java” inside “/home/userone/JPA2_And_OpenJPA_On_AS7/src” directory as following:

package jpa;
import java.lang.Integer;
import java.util.Collection;
import javax.ejb.Remote;
@Remote

public interface EmployeeServiceRemote{
  public void doAction();
  public Employee createEmployee(Integer id, String name);
  public void removeEmployee(Integer id);
  public Employee findEmployee(Integer id);
  public Collection<Employee> findAllEmployees() ;

}

Step4). Now we will Stateless Session Bean class “EmployeeService.java” by implementing the interface “EmployeeServiceRemote.java”. Place this file as well inside the “/home/userone/JPA2_And_OpenJPA_On_AS7/src” directory as following:

package jpa;
import java.lang.Integer;
import java.util.Collection;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import javax.persistence.EntityTransaction;
import javax.ejb.*;

@Stateless
public class EmployeeService implements EmployeeServiceRemote {
  @PersistenceContext(unitName="EmployeeService")
  EntityManager em;

  public EmployeeService() {
	  System.out.println("ntEmployeeService  Object Created. this: "+this);
  }

  @TransactionAttribute (TransactionAttributeType.REQUIRED)
  public Employee createEmployee(Integer id, String name) {
    Employee emp = new Employee();
    emp.setEmpno(id);
    emp.setEname(name);
    System.out.println("nt[EmployeeService] Before em.persist(emp)");

    try{ 
         
         //em.getTransaction().begin();
         em.persist(emp);
         //em.flush();
         //em.getTransaction().commit();
       } 
    catch(Exception e)
       {
          e.printStackTrace();
          try{   em.getTransaction().rollback();   } catch(Exception ee)  {  ee.printStackTrace();  }
       }

     System.out.println("nt[EmployeeService] Before findEmployee(id)");
     emp = findEmployee(id);
     System.out.println("nt[EmployeeService] Inside createEmployee() findEmployee result: "+emp);
     return emp;
  }

  public void removeEmployee(Integer id) {
	System.out.println("nt Inside removeEmployee("+id+")");
    Employee emp = findEmployee(id);
    if (emp != null) {
       try{ 
            //em.getTransaction().begin();
            em.remove(emp);
            //em.getTransaction().commit();
          } 
       catch(Exception e)
          {
             e.printStackTrace();
             try{   em.getTransaction().rollback();   } catch(Exception ee)  {  ee.printStackTrace();  }
          }
    }
  }

  public Employee findEmployee(Integer id) {
	System.out.println("nt Inside findEmployee("+id+")");
    return em.find(Employee.class, id);
  }

  @SuppressWarnings("unchecked")
  public Collection<Employee> findAllEmployees() 
     {
	System.out.println("nt Inside findAllEmployees()");
        Query query = em.createQuery("SELECT e FROM Employee e");
        return (Collection<Employee>) query.getResultList();
     }

  public void doAction(){
       System.out.println("nt Hello World...");
  }
}

Step5). Now we will write the “persistence.xml” file inside the “/home/userone/JPA2_And_OpenJPA_On_AS7/src” directory as following:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.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_2_0.xsd">
  <persistence-unit name="EmployeeService">
    <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
       <jta-data-source>java:/MySqlDS</jta-data-source> 
       <class>jpa.Employee</class>

      <properties>
          <property name="jboss.as.jpa.providerModule" value="org.apache.openjpa" />
          <property name="openjpa.Log" value="DefaultLevel=TRACE, Tool=INFO"/>


           <!--   IMPORTANT PROPERTIES   -->           
           <property name="openjpa.DynamicEnhancementAgent" value="false"/>
           <property name="openjpa.RuntimeUnenhancedClasses" value="supported" />
      </properties>
  </persistence-unit>
</persistence>

NOTE: We need to make sure that this “persistence.xml” file goes inside the “${war.name}/WEB-INF/classes/META-INF” directory of our WAR file. Note jboss.as.jpa.providerModule property is very important

Step6). Now we will write a simple “index.jsp” page to just provide a some input forms so that a user can enter the employee name and id details , Place this file as well inside the “/home/userone/JPA2_And_OpenJPA_On_AS7/src” directory as following:

<html>
<head>
<title>JPA Demo In JBoss AS7</title>
</head>
<body>
   <form action="TestServlet">
   Enter Employee ID : <input name="empId" type="text" value="" /> <BR/>
   Enter Employee Name : <input name="empName" type="text" value="" /> <BR/>
   <input type="submit" value="Store" />
   </form>
</body>
</html>

Step7). We will write the “TestServlet.java” inside the “/home/userone/JPA2_And_OpenJPA_On_AS7/src” as following in order to insert the details entered by the user in previous index.jsp page.


package servlets;
import java.io.IOException;
import java.io.PrintWriter;
import java.lang.Integer;
import javax.ejb.EJB;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import java.util.*;
import javax.transaction.*;
import javax.annotation.*;
import jpa.Employee;

@WebServlet(value="/TestServlet")
public class TestServlet extends HttpServlet 
  {
	private static final long serialVersionUID = 1L;

        @PersistenceContext(unitName="EmployeeService")
	EntityManager em;
	  
        @EJB(lookup="java:global/JPA_BASIC_Demo/EmployeeService!jpa.EmployeeServiceRemote")
        jpa.EmployeeServiceRemote remote;


	public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
                PrintWriter out=null;
		try {
			System.out.println("inside TestServlet service()");
			System.out.println("Got jpa.EmployeeServiceRemote :  "+remote);
			out=response.getWriter();			
			
                        out.println("<html><head><title>JPA Insert</title></head><body>");
			out.println("<BR>Employee Record Inserted in the Database.<BR>");
                        remote.createEmployee(new Integer(request.getParameter("empId")),request.getParameter("empName"));
                        out.println("Record Inserted.....");
                        
                        /*
                          //  If i call the "remote.findAllEmployees()" Now then i get an Exception here .... Only with OpenJPA 
                          //  (where as it works well with TopLink and Hibernate) 

                   
                        Collection<Employee> employees=remote.findAllEmployees();
                        out.println("<TABLE border="10%">");
                        out.println("<TR><TD>EmpID</TD><TD>EmpName</TD></TR>");
			for(Employee tmp : employees)
			{
			   out.println("<TR><TD>"+tmp.getEmpno()+"</TD><TD>"+tmp.getEname()+"</TD></TR>");
			}
                        out.println("</TABLE>");
                        */
                        remote.doAction();
                        out.println("<BR><BR><a href="index.jsp"> Want to insert Some More Employee Records ?</a></body></html>");
		     } 
                 catch (Exception e) 
                     {
			e.printStackTrace();
		     }
	}
}

Step8). As we created a module “org.eclipse.persistence.jpa” earlier which we are going to use in our web application. So we will need to create a “jboss-deployment-structure.xml” file as following:

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
  <deployment>
    <dependencies>
      <module name="org.apache.openjpa" />
    </dependencies>
  </deployment>
</jboss-deployment-structure>

NOTE: Once our application is build then we should be able to see this file present inside our WebApplication “WEB-INF/jboss-deployment-structure.xml”.

Step9). Now the most important part, here we are going to develop “build.xml” ANT file, which will build, deploy our web application on the JBoss AS7.1 Beta Server, so write the following “build.xml” file inside “/home/userone/JPA2_And_OpenJPA_On_AS7” directory.


<project name="JPA_BASIC_Demo" default="deploy">
<property name="jboss.home" value="/NotBackedUp/JBoss_All/jboss-as-7.1.1.Final" />
<property name="jboss.module.dir" value="${jboss.home}/modules" />
<property name="basedir" value="." />
<property name="tmp.dir" value="tmp" />
<property name="output.dir" value="build" />
<property name="src.dir" value="src" />
<property name="war.name" value="JPA_BASIC_Demo.war" />
 
   <path id="jboss.classpath">
     <fileset dir="${jboss.module.dir}">
        <include name="**/*.jar"/>
     </fileset>
   </path>
 
        <target name="init">
           <delete dir="${output.dir}" />
           <mkdir dir="${output.dir}" />
           <delete dir="${tmp.dir}" />
           <mkdir dir="${tmp.dir}" />
           <mkdir dir="${tmp.dir}/WEB-INF/classes/META-INF"/>
        </target>
 
        <target name="build" depends="init">
           <javac srcdir="${src.dir}" destdir="${tmp.dir}/WEB-INF/classes"  includes="*.java" classpathref="jboss.classpath" />
           <copy todir="${tmp.dir}/WEB-INF/classes">
                <fileset dir="${src.dir}" includes="**/*.java"/>
           </copy>
           <copy file="${src.dir}/index.jsp" tofile="${tmp.dir}/index.jsp"/>
           <copy file="${src.dir}/jboss-deployment-structure.xml" tofile="${tmp.dir}/WEB-INF/jboss-deployment-structure.xml"/>

           <!-- Make Sure that the persistence.xml file is placed inside "${war.name}/WEB-INF/classes/META-INF" directory -->
           <copy file="${src.dir}/persistence.xml" tofile="${tmp.dir}/WEB-INF/classes/META-INF/persistence.xml"/>

           <jar jarfile="${tmp.dir}/${war.name}" basedir="${tmp.dir}" compress="true" />
           <copy file="${tmp.dir}/${war.name}" tofile="${output.dir}/${war.name}"/>

           <delete includeEmptyDirs="true">
              <fileset dir="${tmp.dir}"/>
           </delete>
        </target>
 
        <target name="deploy" depends="build">
            <echo message="*******************  Deploying the WAR file ${war.name} *********************" />
            <echo message="********** ${output.dir}/${war.name} to ${jboss.home}/standalone/deployments **********" />
            <copy todir="${jboss.home}/standalone/deployments/">
                <fileset dir="${output.dir}/">
                  <include name="${war.name}"/>
                </fileset>
            </copy>
            <echo message="*******************  Deployed Successfully   *********************" />
        </target>
</project>

NOTE: The only change in the above file you need to do is to change the “jboss.home” directory path in the second line of the above script to point to your own JBoss AS7 directory.

Step9). Now before running your ANT script to build and deploy the above webapplication you should have the ANT as well as JAVA set in the $PATH variable of the Shell / command prompt as following:

For Unix Based OS:
export PATH=/home/userone/jdk1.6.0_21/bin:/home/userone/org.apache.ant_1.6.5/bin:$PATH

For Windows Based OS:
set PATH=C:/jdk1.6.0_21/bin;C:/org.apache.ant_1.6.5/bin;%PATH%

Step10). Now once the PATH is set In the command/Shell prompt you can move inside the directory “/home/userone/JPA2_And_OpenJPA_On_AS7” and then run the ant to build the webservice. by running the command “ant deploy”

Buildfile: build.xml

init:
   [delete] Deleting directory /home/userone/JPA2_And_OpenJPA_On_AS7/build
    [mkdir] Created dir: /home/userone/JPA2_And_OpenJPA_On_AS7/build
    [mkdir] Created dir: /home/userone/JPA2_And_OpenJPA_On_AS7/tmp
    [mkdir] Created dir: /home/userone/JPA2_And_OpenJPA_On_AS7/tmp/WEB-INF/classes/META-INF

build:
    [javac] Compiling 4 source files to /home/userone/JPA2_And_OpenJPA_On_AS7/tmp/WEB-INF/classes
     [copy] Copying 4 files to /home/userone/JPA2_And_OpenJPA_On_AS7/tmp/WEB-INF/classes
     [copy] Copying 1 file to /home/userone/JPA2_And_OpenJPA_On_AS7/tmp
     [copy] Copying 1 file to /home/userone/JPA2_And_OpenJPA_On_AS7/tmp/WEB-INF
     [copy] Copying 1 file to /home/userone/JPA2_And_OpenJPA_On_AS7/tmp/WEB-INF/classes/META-INF
      [jar] Building jar: /home/userone/JPA2_And_OpenJPA_On_AS7/tmp/JPA_BASIC_Demo.war
     [copy] Copying 1 file to /home/userone/JPA2_And_OpenJPA_On_AS7/build

deploy:
     [echo] *******************  Deploying the WAR file JPA_BASIC_Demo.war *********************
     [echo] ********** build/JPA_BASIC_Demo.war to /home/userone/jboss-as-7.1.1.Final/standalone/deployments **********
     [copy] Copying 1 file to /home/userone/jboss-as-7.1.1.Final/standalone/deployments
     [echo] *******************  Deployed Successfully   *********************

BUILD SUCCESSFUL
Total time: 2 seconds

Step11). Now you will see the following kind of output on your JBoss AS7.1 console which means the application is deployed successfully:


22:31:20,023 INFO  [org.jboss.as.jpa] (MSC service thread 1-4) JBAS011403: Stopping Persistence Unit Service 'JPA_BASIC_Demo.war#EmployeeService'
22:31:20,024 ERROR [stderr] (MSC service thread 1-4) 1670729  EmployeeService  TRACE  [MSC service thread 1-4] openjpa.Runtime - org.apache.openjpa.persistence.EntityManagerFactoryImpl@eed9a0e.close() invoked.
22:31:20,025 ERROR [stderr] (MSC service thread 1-4) 1670730  EmployeeService  TRACE  [MSC service thread 1-4] openjpa.MetaData - Clearing metadata repository "org.apache.openjpa.jdbc.meta.MappingRepository@151c6810".
22:31:20,050 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015877: Stopped deployment JPA_BASIC_Demo.war in 40ms
22:31:20,051 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-7) JBAS015876: Starting deployment of "JPA_BASIC_Demo.war"
22:31:20,060 INFO  [org.jboss.as.jpa] (MSC service thread 1-7) JBAS011401: Read persistence.xml for EmployeeService
22:31:20,093 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-8) JNDI bindings for session bean named EmployeeService in deployment unit deployment "JPA_BASIC_Demo.war" are as follows:

	java:global/JPA_BASIC_Demo/EmployeeService!jpa.EmployeeServiceRemote
	java:app/JPA_BASIC_Demo/EmployeeService!jpa.EmployeeServiceRemote
	java:module/EmployeeService!jpa.EmployeeServiceRemote
	java:jboss/exported/JPA_BASIC_Demo/EmployeeService!jpa.EmployeeServiceRemote
	java:global/JPA_BASIC_Demo/EmployeeService
	java:app/JPA_BASIC_Demo/EmployeeService
	java:module/EmployeeService

22:31:20,181 INFO  [org.jboss.as.jpa] (MSC service thread 1-1) JBAS011402: Starting Persistence Unit Service 'JPA_BASIC_Demo.war#EmployeeService'
22:31:20,221 ERROR [stderr] (MSC service thread 1-1) 0  EmployeeService  TRACE  [MSC service thread 1-1] openjpa.Runtime - Setting the following properties from "?" into configuration: {javax.persistence.provider=org.apache.openjpa.persistence.PersistenceProviderImpl, openjpa.RuntimeUnenhancedClasses=supported, javax.persistence.sharedCache.mode=UNSPECIFIED, PersistenceVersion=2.0, openjpa.Log=DefaultLevel=TRACE, Tool=INFO, openjpa.Id=EmployeeService, openjpa.ConnectionFactoryMode=managed, openjpa.ConnectionFactory=org.jboss.jca.adapters.jdbc.WrapperDataSource@36cb1594, javax.persistence.validation.mode=AUTO, javax.persistence.validation.factory=org.jboss.as.jpa.validator.SerializableValidatorFactory@4600f385, jboss.as.jpa.providerModule=org.apache.openjpa, openjpa.TransactionMode=managed, openjpa.MetaDataFactory=jpa(URLs=vfs:/content/JPA_BASIC_Demo.war/WEB-INF/classes/, Types=jpa.Employee), openjpa.ClassResolver=org.apache.openjpa.persistence.PersistenceUnitInfoImpl$ClassResolverImpl@269be988, openjpa.DynamicEnhancementAgent=false}
22:31:20,227 ERROR [stderr] (MSC service thread 1-1) 6  EmployeeService  TRACE  [MSC service thread 1-1] openjpa.Runtime - No cache marshaller found for id org.apache.openjpa.conf.MetaDataCacheMaintenance.
22:31:20,228 ERROR [stderr] (MSC service thread 1-1) 7  EmployeeService  TRACE  [MSC service thread 1-1] openjpa.MetaData - Scanning URL "vfs:/content/JPA_BASIC_Demo.war/WEB-INF/classes/" for persistent types.
22:31:20,229 ERROR [stderr] (MSC service thread 1-1) 8  EmployeeService  TRACE  [MSC service thread 1-1] openjpa.MetaData - Scan of "vfs:/content/JPA_BASIC_Demo.war/WEB-INF/classes/" found persistent types [].
22:31:20,229 ERROR [stderr] (MSC service thread 1-1) 8  EmployeeService  TRACE  [MSC service thread 1-1] openjpa.MetaData - Skipping persistent type location association for location "vfs:/content/JPA_BASIC_Demo.war/WEB-INF/classes/" since it is a directory.
22:31:20,230 ERROR [stderr] (MSC service thread 1-1) 9  EmployeeService  TRACE  [MSC service thread 1-1] openjpa.MetaData - Scanning resource "META-INF/orm.xml" for persistent types.
22:31:20,230 ERROR [stderr] (MSC service thread 1-1) 9  EmployeeService  TRACE  [MSC service thread 1-1] openjpa.MetaData - The persistent unit root url is "null"
22:31:20,230 ERROR [stderr] (MSC service thread 1-1) 9  EmployeeService  TRACE  [MSC service thread 1-1] openjpa.MetaData - parsePersistentTypeNames() found [jpa.Employee].
22:31:20,231 ERROR [stderr] (MSC service thread 1-1) 10  EmployeeService  TRACE  [MSC service thread 1-1] openjpa.MetaData - Found 1 classes with metadata in 3 milliseconds.
22:31:20,235 ERROR [stderr] (MSC service thread 1-1) 0  EmployeeService  TRACE  [MSC service thread 1-1] openjpa.Runtime - Setting the following properties from "?" into configuration: {openjpa.BrokerFactory=jdbc, javax.persistence.provider=org.apache.openjpa.persistence.PersistenceProviderImpl, openjpa.RuntimeUnenhancedClasses=supported, javax.persistence.sharedCache.mode=UNSPECIFIED, PersistenceVersion=2.0, openjpa.Log=DefaultLevel=TRACE, Tool=INFO, openjpa.Id=EmployeeService, openjpa.ConnectionFactoryMode=managed, openjpa.ConnectionFactory=org.jboss.jca.adapters.jdbc.WrapperDataSource@36cb1594, javax.persistence.validation.mode=AUTO, javax.persistence.validation.factory=org.jboss.as.jpa.validator.SerializableValidatorFactory@4600f385, jboss.as.jpa.providerModule=org.apache.openjpa, openjpa.TransactionMode=managed, openjpa.BrokerImpl=non-finalizing, openjpa.MetaDataFactory=jpa(URLs=vfs:/content/JPA_BASIC_Demo.war/WEB-INF/classes/, Types=jpa.Employee), openjpa.ClassResolver=org.apache.openjpa.persistence.PersistenceUnitInfoImpl$ClassResolverImpl@269be988, openjpa.DynamicEnhancementAgent=false}
22:31:20,237 ERROR [stderr] (MSC service thread 1-1) 2  EmployeeService  TRACE  [MSC service thread 1-1] openjpa.Runtime - Trying to load javax.validation APIs based on the ValidationMode=AUTO
22:31:20,241 ERROR [stderr] (MSC service thread 1-1) 6  EmployeeService  INFO   [MSC service thread 1-1] openjpa.Runtime - OpenJPA dynamically loaded a validation provider.
22:31:20,241 ERROR [stderr] (MSC service thread 1-1) 6  EmployeeService  TRACE  [MSC service thread 1-1] openjpa.Runtime - org.apache.openjpa.persistence.PersistenceProviderImpl@6873c4aa creating container org.apache.openjpa.persistence.EntityManagerFactoryImpl@874aa79 for PU EmployeeService.
22:31:20,256 INFO  [org.jboss.web] (MSC service thread 1-5) JBAS018210: Registering web context: /JPA_BASIC_Demo
22:31:20,373 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 1) JBAS018565: Replaced deployment "JPA_BASIC_Demo.war" with deployment "JPA_BASIC_Demo.war"


NOTE: When OpenJPA displays TRACE Logging message above then …JBoss Incorrectly showing ERROR Message.

Step12). Now access the WebApplication like following and then fill the form :
http://localhost:8080/JPA_BASIC_Demo/index.jsp

Once you hit the above URL you will see thew following kind of output in oyur JBossAS7 console:

.
22:33:39,382 INFO  [stdout] (http--127.0.0.1-8080-2) inside TestServlet service()
22:33:39,382 INFO  [stdout] (http--127.0.0.1-8080-2) Got jpa.EmployeeServiceRemote :  Proxy for remote EJB StatelessEJBLocator{appName='', moduleName='JPA_BASIC_Demo', distinctName='', beanName='EmployeeService', view='interface jpa.EmployeeServiceRemote'}
22:33:39,384 INFO  [stdout] (http--127.0.0.1-8080-2) 
22:33:39,384 INFO  [stdout] (http--127.0.0.1-8080-2) 	EmployeeService  Object Created. this: jpa.EmployeeService@598427a0
22:33:39,385 INFO  [stdout] (http--127.0.0.1-8080-2) Employee Object Created. this: jpa.Employee@7345a749
22:33:39,385 INFO  [stdout] (http--127.0.0.1-8080-2) 
22:33:39,385 INFO  [stdout] (http--127.0.0.1-8080-2) 	[EmployeeService] Before em.persist(emp)
22:33:39,385 ERROR [stderr] (http--127.0.0.1-8080-2) 139150  EmployeeService  INFO   [http--127.0.0.1-8080-2] openjpa.Runtime - Starting OpenJPA 2.2.0
22:33:39,386 ERROR [stderr] (http--127.0.0.1-8080-2) 139151  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.Runtime - Properties: javax.persistence.lock.timeout: 0
22:33:39,386 ERROR [stderr] (http--127.0.0.1-8080-2) javax.persistence.query.timeout: 0
22:33:39,386 ERROR [stderr] (http--127.0.0.1-8080-2) javax.persistence.sharedCache.mode: UNSPECIFIED
22:33:39,387 ERROR [stderr] (http--127.0.0.1-8080-2) javax.persistence.validation.group.pre-persist: javax.validation.groups.Default
22:33:39,387 ERROR [stderr] (http--127.0.0.1-8080-2) javax.persistence.validation.group.pre-update: javax.validation.groups.Default
22:33:39,387 ERROR [stderr] (http--127.0.0.1-8080-2) javax.persistence.validation.mode: AUTO
22:33:39,387 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.AutoClear: 0
22:33:39,387 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.AutoDetach: []
22:33:39,388 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.BrokerFactory: jdbc
22:33:39,388 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.BrokerImpl: non-finalizing
22:33:39,388 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.CacheDistributionPolicy: default
22:33:39,388 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.Callbacks: default
22:33:39,388 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.ClassResolver: org.apache.openjpa.persistence.PersistenceUnitInfoImpl$ClassResolverImpl
22:33:39,388 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.Compatibility: default
22:33:39,389 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.ConnectionFactoryMode: true
22:33:39,389 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.ConnectionRetainMode: 0
22:33:39,389 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.DataCache: false
22:33:39,389 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.DataCacheManager: default
22:33:39,389 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.DataCacheTimeout: -1
22:33:39,389 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.DetachState: loaded
22:33:39,390 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.DynamicDataStructs: false
22:33:39,390 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.DynamicEnhancementAgent: false
22:33:39,390 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.EntityManagerFactory: default
22:33:39,390 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.FetchBatchSize: -1
22:33:39,390 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.FetchGroups: [default]
22:33:39,390 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.FlushBeforeQueries: 0
22:33:39,391 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.Id: EmployeeService
22:33:39,391 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.IgnoreChanges: false
22:33:39,391 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.InitializeEagerly: false
22:33:39,391 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.InstrumentationManager: default
22:33:39,391 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.InverseManager: false
22:33:39,391 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.LifecycleEventManager: validating
22:33:39,391 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.LockManager: mixed
22:33:39,392 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.Log: true(DefaultLevel=TRACE, Tool=INFO)
22:33:39,392 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.ManagedRuntime: auto
22:33:39,392 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.MaxFetchDepth: -1
22:33:39,392 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.MetaDataFactory: jpa(URLs=vfs:/content/JPA_BASIC_Demo.war/WEB-INF/classes/, Types=jpa.Employee)
22:33:39,392 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.MetaDataRepository: default
22:33:39,392 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.Multithreaded: false
22:33:39,392 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.NontransactionalRead: true
22:33:39,393 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.NontransactionalWrite: true
22:33:39,393 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.Optimistic: true
22:33:39,393 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.OptimizeIdCopy: false
22:33:39,393 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.OrphanedKeyAction: log
22:33:39,393 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.PostLoadOnMerge: false
22:33:39,393 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.ProxyManager: default
22:33:39,393 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.QueryCache: false
22:33:39,394 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.QueryCompilationCache: true
22:33:39,394 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.ReadLockLevel: 10
22:33:39,394 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.RefreshFromDataCache: false
22:33:39,394 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.RestoreState: 1
22:33:39,394 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.RetainState: true
22:33:39,394 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.RetryClassRegistration: false
22:33:39,395 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.RuntimeUnenhancedClasses: 0
22:33:39,395 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.SavepointManager: in-mem
22:33:39,395 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.Sequence: table
22:33:39,395 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.TransactionMode: true
22:33:39,395 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.WriteLockLevel: 20
22:33:39,396 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.jdbc.DriverDataSource: auto
22:33:39,396 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.jdbc.EagerFetchMode: 2
22:33:39,396 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.jdbc.FetchDirection: 1000
22:33:39,396 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.jdbc.FinderCache: true
22:33:39,396 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.jdbc.IdentifierUtil: default
22:33:39,397 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.jdbc.LRSSize: 2
22:33:39,397 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.jdbc.MappingDefaults: jpa
22:33:39,397 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.jdbc.QuerySQLCache: true
22:33:39,397 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.jdbc.ResultSetType: 1003
22:33:39,397 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.jdbc.SQLFactory: default
22:33:39,398 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.jdbc.SchemaFactory: dynamic
22:33:39,398 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.jdbc.Schemas: []
22:33:39,398 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.jdbc.SubclassFetchMode: 1
22:33:39,398 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.jdbc.SynchronizeMappings: null
22:33:39,398 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.jdbc.TransactionIsolation: -1
22:33:39,398 ERROR [stderr] (http--127.0.0.1-8080-2) openjpa.jdbc.UpdateManager: default
22:33:39,399 ERROR [stderr] (http--127.0.0.1-8080-2) 139164  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.Runtime - No cache marshaller found for id org.apache.openjpa.conf.MetaDataCacheMaintenance.
22:33:39,399 ERROR [stderr] (http--127.0.0.1-8080-2) 139164  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - Using metadata factory "org.apache.openjpa.persistence.jdbc.PersistenceMappingFactory@61e9e4be".
22:33:39,400 ERROR [stderr] (http--127.0.0.1-8080-2) 139165  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.jdbc.JDBC - OpenJPA will now connect to the database to attempt to determine what type of database dictionary to use. You may prevent this connection in the future by setting your openjpa.jdbc.DBDictionary configuration property to the appropriate value for your database (see the documentation for available values).
22:33:39,400 ERROR [stderr] (http--127.0.0.1-8080-2) 139165  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.jdbc.JDBC - createConnectionFactory: DataSource:org.jboss.jca.adapters.jdbc.WrapperDataSource@36cb1594
22:33:39,401 ERROR [stderr] (http--127.0.0.1-8080-2) 139166  EmployeeService  INFO   [http--127.0.0.1-8080-2] openjpa.jdbc.JDBC - Using dictionary class "org.apache.openjpa.jdbc.sql.MySQLDictionary" (MySQL 5.5.20 ,MySQL-AB JDBC Driver mysql-connector-java-5.1.13 ( Revision: ${bzr.revision-id} )).
22:33:39,405 ERROR [stderr] (http--127.0.0.1-8080-2) 139170  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.jdbc.JDBC - catalogSeparator: .
22:33:39,405 ERROR [stderr] (http--127.0.0.1-8080-2) catalogTerm: database
22:33:39,405 ERROR [stderr] (http--127.0.0.1-8080-2) databaseProductName: MySQL
22:33:39,405 ERROR [stderr] (http--127.0.0.1-8080-2) databaseProductVersion: 5.5.20
22:33:39,405 ERROR [stderr] (http--127.0.0.1-8080-2) driverName: MySQL-AB JDBC Driver
22:33:39,405 ERROR [stderr] (http--127.0.0.1-8080-2) driverVersion: mysql-connector-java-5.1.13 ( Revision: ${bzr.revision-id} )
22:33:39,406 ERROR [stderr] (http--127.0.0.1-8080-2) extraNameCharacters: #@
22:33:39,406 ERROR [stderr] (http--127.0.0.1-8080-2) identifierQuoteString: `
22:33:39,406 ERROR [stderr] (http--127.0.0.1-8080-2) numericFunctions: ABS,ACOS,ASIN,ATAN,ATAN2,BIT_COUNT,CEILING,COS,COT,DEGREES,EXP,FLOOR,LOG,LOG10,MAX,MIN,MOD,PI,POW,POWER,RADIANS,RAND,ROUND,SIN,SQRT,TAN,TRUNCATE
22:33:39,406 ERROR [stderr] (http--127.0.0.1-8080-2) procedureTerm: PROCEDURE
22:33:39,406 ERROR [stderr] (http--127.0.0.1-8080-2) schemaTerm: 
22:33:39,406 ERROR [stderr] (http--127.0.0.1-8080-2) searchStringEscape: 
22:33:39,407 ERROR [stderr] (http--127.0.0.1-8080-2) sqlKeywords: ACCESSIBLE,ANALYZE,ASENSITIVE,BEFORE,BIGINT,BINARY,BLOB,CALL,CHANGE,CONDITION,DATABASE,DATABASES,DAY_HOUR,DAY_MICROSECOND,DAY_MINUTE,DAY_SECOND,DELAYED,DETERMINISTIC,DISTINCTROW,DIV,DUAL,EACH,ELSEIF,ENCLOSED,ESCAPED,EXIT,EXPLAIN,FLOAT4,FLOAT8,FORCE,FULLTEXT,HIGH_PRIORITY,HOUR_MICROSECOND,HOUR_MINUTE,HOUR_SECOND,IF,IGNORE,INFILE,INOUT,INT1,INT2,INT3,INT4,INT8,ITERATE,KEYS,KILL,LEAVE,LIMIT,LINEAR,LINES,LOAD,LOCALTIME,LOCALTIMESTAMP,LOCK,LONG,LONGBLOB,LONGTEXT,LOOP,LOW_PRIORITY,MEDIUMBLOB,MEDIUMINT,MEDIUMTEXT,MIDDLEINT,MINUTE_MICROSECOND,MINUTE_SECOND,MOD,MODIFIES,NO_WRITE_TO_BINLOG,OPTIMIZE,OPTIONALLY,OUT,OUTFILE,PURGE,RANGE,READS,READ_ONLY,READ_WRITE,REGEXP,RELEASE,RENAME,REPEAT,REPLACE,REQUIRE,RETURN,RLIKE,SCHEMAS,SECOND_MICROSECOND,SENSITIVE,SEPARATOR,SHOW,SPATIAL,SPECIFIC,SQLEXCEPTION,SQL_BIG_RESULT,SQL_CALC_FOUND_ROWS,SQL_SMALL_RESULT,SSL,STARTING,STRAIGHT_JOIN,TERMINATED,TINYBLOB,TINYINT,TINYTEXT,TRIGGER,UNDO,UNLOCK,UNSIGNED,USE,UTC_DATE,UTC_TIME,UTC_TIMESTAMP,VARBINARY,VARCHARACTER,WHILE,X509,XOR,YEAR_MONTH,ZEROFILL
22:33:39,408 ERROR [stderr] (http--127.0.0.1-8080-2) stringFunctions: ASCII,BIN,BIT_LENGTH,CHAR,CHARACTER_LENGTH,CHAR_LENGTH,CONCAT,CONCAT_WS,CONV,ELT,EXPORT_SET,FIELD,FIND_IN_SET,HEX,INSERT,INSTR,LCASE,LEFT,LENGTH,LOAD_FILE,LOCATE,LOCATE,LOWER,LPAD,LTRIM,MAKE_SET,MATCH,MID,OCT,OCTET_LENGTH,ORD,POSITION,QUOTE,REPEAT,REPLACE,REVERSE,RIGHT,RPAD,RTRIM,SOUNDEX,SPACE,STRCMP,SUBSTRING,SUBSTRING,SUBSTRING,SUBSTRING,SUBSTRING_INDEX,TRIM,UCASE,UPPER
22:33:39,409 ERROR [stderr] (http--127.0.0.1-8080-2) systemFunctions: DATABASE,USER,SYSTEM_USER,SESSION_USER,PASSWORD,ENCRYPT,LAST_INSERT_ID,VERSION
22:33:39,409 ERROR [stderr] (http--127.0.0.1-8080-2) timeDateFunctions: DAYOFWEEK,WEEKDAY,DAYOFMONTH,DAYOFYEAR,MONTH,DAYNAME,MONTHNAME,QUARTER,WEEK,YEAR,HOUR,MINUTE,SECOND,PERIOD_ADD,PERIOD_DIFF,TO_DAYS,FROM_DAYS,DATE_FORMAT,TIME_FORMAT,CURDATE,CURRENT_DATE,CURTIME,CURRENT_TIME,NOW,SYSDATE,CURRENT_TIMESTAMP,UNIX_TIMESTAMP,FROM_UNIXTIME,SEC_TO_TIME,TIME_TO_SEC
22:33:39,410 ERROR [stderr] (http--127.0.0.1-8080-2) url: jdbc:mysql://localhost:3306/testDB
22:33:39,410 ERROR [stderr] (http--127.0.0.1-8080-2) userName: root@localhost
22:33:39,410 ERROR [stderr] (http--127.0.0.1-8080-2) defaultTransactionIsolation: 2
22:33:39,410 ERROR [stderr] (http--127.0.0.1-8080-2) driverMajorVersion: 5
22:33:39,410 ERROR [stderr] (http--127.0.0.1-8080-2) driverMinorVersion: 1
22:33:39,411 ERROR [stderr] (http--127.0.0.1-8080-2) maxBinaryLiteralLength: 16777208
22:33:39,411 ERROR [stderr] (http--127.0.0.1-8080-2) maxCatalogNameLength: 32
22:33:39,411 ERROR [stderr] (http--127.0.0.1-8080-2) maxCharLiteralLength: 16777208
22:33:39,411 ERROR [stderr] (http--127.0.0.1-8080-2) maxColumnNameLength: 64
22:33:39,411 ERROR [stderr] (http--127.0.0.1-8080-2) maxColumnsInGroupBy: 64
22:33:39,412 ERROR [stderr] (http--127.0.0.1-8080-2) maxColumnsInIndex: 16
22:33:39,412 ERROR [stderr] (http--127.0.0.1-8080-2) maxColumnsInOrderBy: 64
22:33:39,412 ERROR [stderr] (http--127.0.0.1-8080-2) maxColumnsInSelect: 256
22:33:39,412 ERROR [stderr] (http--127.0.0.1-8080-2) maxColumnsInTable: 512
22:33:39,412 ERROR [stderr] (http--127.0.0.1-8080-2) maxConnections: 0
22:33:39,413 ERROR [stderr] (http--127.0.0.1-8080-2) maxCursorNameLength: 64
22:33:39,413 ERROR [stderr] (http--127.0.0.1-8080-2) maxIndexLength: 256
22:33:39,413 ERROR [stderr] (http--127.0.0.1-8080-2) maxProcedureNameLength: 0
22:33:39,413 ERROR [stderr] (http--127.0.0.1-8080-2) maxRowSize: 2147483639
22:33:39,413 ERROR [stderr] (http--127.0.0.1-8080-2) maxSchemaNameLength: 0
22:33:39,413 ERROR [stderr] (http--127.0.0.1-8080-2) maxStatementLength: 65531
22:33:39,414 ERROR [stderr] (http--127.0.0.1-8080-2) maxStatements: 0
22:33:39,414 ERROR [stderr] (http--127.0.0.1-8080-2) maxTableNameLength: 64
22:33:39,414 ERROR [stderr] (http--127.0.0.1-8080-2) maxTablesInSelect: 256
22:33:39,414 ERROR [stderr] (http--127.0.0.1-8080-2) maxUserNameLength: 16
22:33:39,414 ERROR [stderr] (http--127.0.0.1-8080-2) isCatalogAtStart: true
22:33:39,415 ERROR [stderr] (http--127.0.0.1-8080-2) isReadOnly: false
22:33:39,415 ERROR [stderr] (http--127.0.0.1-8080-2) nullPlusNonNullIsNull: true
22:33:39,415 ERROR [stderr] (http--127.0.0.1-8080-2) nullsAreSortedAtEnd: false
22:33:39,415 ERROR [stderr] (http--127.0.0.1-8080-2) nullsAreSortedAtStart: false
22:33:39,415 ERROR [stderr] (http--127.0.0.1-8080-2) nullsAreSortedHigh: false
22:33:39,415 ERROR [stderr] (http--127.0.0.1-8080-2) nullsAreSortedLow: true
22:33:39,415 ERROR [stderr] (http--127.0.0.1-8080-2) storesLowerCaseIdentifiers: false
22:33:39,416 ERROR [stderr] (http--127.0.0.1-8080-2) storesLowerCaseQuotedIdentifiers: false
22:33:39,416 ERROR [stderr] (http--127.0.0.1-8080-2) storesMixedCaseIdentifiers: true
22:33:39,416 ERROR [stderr] (http--127.0.0.1-8080-2) storesMixedCaseQuotedIdentifiers: true
22:33:39,416 ERROR [stderr] (http--127.0.0.1-8080-2) storesUpperCaseIdentifiers: false
22:33:39,416 ERROR [stderr] (http--127.0.0.1-8080-2) storesUpperCaseQuotedIdentifiers: true
22:33:39,416 ERROR [stderr] (http--127.0.0.1-8080-2) supportsAlterTableWithAddColumn: true
22:33:39,417 ERROR [stderr] (http--127.0.0.1-8080-2) supportsAlterTableWithDropColumn: true
22:33:39,417 ERROR [stderr] (http--127.0.0.1-8080-2) supportsANSI92EntryLevelSQL: true
22:33:39,417 ERROR [stderr] (http--127.0.0.1-8080-2) supportsANSI92FullSQL: false
22:33:39,417 ERROR [stderr] (http--127.0.0.1-8080-2) supportsANSI92IntermediateSQL: false
22:33:39,417 ERROR [stderr] (http--127.0.0.1-8080-2) supportsCatalogsInDataManipulation: true
22:33:39,417 ERROR [stderr] (http--127.0.0.1-8080-2) supportsCatalogsInIndexDefinitions: true
22:33:39,418 ERROR [stderr] (http--127.0.0.1-8080-2) supportsCatalogsInPrivilegeDefinitions: true
22:33:39,418 ERROR [stderr] (http--127.0.0.1-8080-2) supportsCatalogsInProcedureCalls: true
22:33:39,418 ERROR [stderr] (http--127.0.0.1-8080-2) supportsCatalogsInTableDefinitions: true
22:33:39,419 ERROR [stderr] (http--127.0.0.1-8080-2) supportsColumnAliasing: true
22:33:39,419 ERROR [stderr] (http--127.0.0.1-8080-2) supportsConvert: false
22:33:39,419 ERROR [stderr] (http--127.0.0.1-8080-2) supportsCoreSQLGrammar: true
22:33:39,419 ERROR [stderr] (http--127.0.0.1-8080-2) supportsCorrelatedSubqueries: true
22:33:39,419 ERROR [stderr] (http--127.0.0.1-8080-2) supportsDataDefinitionAndDataManipulationTransactions: false
22:33:39,420 ERROR [stderr] (http--127.0.0.1-8080-2) supportsDataManipulationTransactionsOnly: false
22:33:39,420 ERROR [stderr] (http--127.0.0.1-8080-2) supportsDifferentTableCorrelationNames: true
22:33:39,420 ERROR [stderr] (http--127.0.0.1-8080-2) supportsExpressionsInOrderBy: true
22:33:39,420 ERROR [stderr] (http--127.0.0.1-8080-2) supportsExtendedSQLGrammar: false
22:33:39,420 ERROR [stderr] (http--127.0.0.1-8080-2) supportsFullOuterJoins: false
22:33:39,421 ERROR [stderr] (http--127.0.0.1-8080-2) supportsGroupBy: true
22:33:39,421 ERROR [stderr] (http--127.0.0.1-8080-2) supportsGroupByBeyondSelect: true
22:33:39,421 ERROR [stderr] (http--127.0.0.1-8080-2) supportsGroupByUnrelated: true
22:33:39,421 ERROR [stderr] (http--127.0.0.1-8080-2) supportsIntegrityEnhancementFacility: false
22:33:39,421 ERROR [stderr] (http--127.0.0.1-8080-2) supportsLikeEscapeClause: true
22:33:39,421 ERROR [stderr] (http--127.0.0.1-8080-2) supportsLimitedOuterJoins: true
22:33:39,421 ERROR [stderr] (http--127.0.0.1-8080-2) supportsMinimumSQLGrammar: true
22:33:39,422 ERROR [stderr] (http--127.0.0.1-8080-2) supportsMixedCaseIdentifiers: true
22:33:39,422 ERROR [stderr] (http--127.0.0.1-8080-2) supportsMixedCaseQuotedIdentifiers: true
22:33:39,422 ERROR [stderr] (http--127.0.0.1-8080-2) supportsMultipleResultSets: false
22:33:39,422 ERROR [stderr] (http--127.0.0.1-8080-2) supportsMultipleTransactions: true
22:33:39,422 ERROR [stderr] (http--127.0.0.1-8080-2) supportsNonNullableColumns: true
22:33:39,422 ERROR [stderr] (http--127.0.0.1-8080-2) supportsOpenCursorsAcrossCommit: false
22:33:39,422 ERROR [stderr] (http--127.0.0.1-8080-2) supportsOpenCursorsAcrossRollback: false
22:33:39,422 ERROR [stderr] (http--127.0.0.1-8080-2) supportsOpenStatementsAcrossCommit: false
22:33:39,423 ERROR [stderr] (http--127.0.0.1-8080-2) supportsOpenStatementsAcrossRollback: false
22:33:39,423 ERROR [stderr] (http--127.0.0.1-8080-2) supportsOrderByUnrelated: false
22:33:39,423 ERROR [stderr] (http--127.0.0.1-8080-2) supportsOuterJoins: true
22:33:39,423 ERROR [stderr] (http--127.0.0.1-8080-2) supportsPositionedDelete: false
22:33:39,423 ERROR [stderr] (http--127.0.0.1-8080-2) supportsPositionedUpdate: false
22:33:39,423 ERROR [stderr] (http--127.0.0.1-8080-2) supportsSchemasInDataManipulation: false
22:33:39,423 ERROR [stderr] (http--127.0.0.1-8080-2) supportsSchemasInIndexDefinitions: false
22:33:39,424 ERROR [stderr] (http--127.0.0.1-8080-2) supportsSchemasInPrivilegeDefinitions: false
22:33:39,424 ERROR [stderr] (http--127.0.0.1-8080-2) supportsSchemasInProcedureCalls: false
22:33:39,424 ERROR [stderr] (http--127.0.0.1-8080-2) supportsSchemasInTableDefinitions: false
22:33:39,424 ERROR [stderr] (http--127.0.0.1-8080-2) supportsSelectForUpdate: true
22:33:39,424 ERROR [stderr] (http--127.0.0.1-8080-2) supportsStoredProcedures: true
22:33:39,424 ERROR [stderr] (http--127.0.0.1-8080-2) supportsSubqueriesInComparisons: true
22:33:39,424 ERROR [stderr] (http--127.0.0.1-8080-2) supportsSubqueriesInExists: true
22:33:39,424 ERROR [stderr] (http--127.0.0.1-8080-2) supportsSubqueriesInIns: true
22:33:39,425 ERROR [stderr] (http--127.0.0.1-8080-2) supportsSubqueriesInQuantifieds: true
22:33:39,425 ERROR [stderr] (http--127.0.0.1-8080-2) supportsTableCorrelationNames: true
22:33:39,425 ERROR [stderr] (http--127.0.0.1-8080-2) supportsTransactions: true
22:33:39,425 ERROR [stderr] (http--127.0.0.1-8080-2) supportsUnion: true
22:33:39,425 ERROR [stderr] (http--127.0.0.1-8080-2) supportsUnionAll: true
22:33:39,425 ERROR [stderr] (http--127.0.0.1-8080-2) usesLocalFilePerTable: false
22:33:39,425 ERROR [stderr] (http--127.0.0.1-8080-2) usesLocalFiles: false
22:33:39,425 ERROR [stderr] (http--127.0.0.1-8080-2) allProceduresAreCallable: false
22:33:39,426 ERROR [stderr] (http--127.0.0.1-8080-2) allTablesAreSelectable: false
22:33:39,426 ERROR [stderr] (http--127.0.0.1-8080-2) dataDefinitionCausesTransactionCommit: true
22:33:39,426 ERROR [stderr] (http--127.0.0.1-8080-2) dataDefinitionIgnoredInTransactions: false
22:33:39,426 ERROR [stderr] (http--127.0.0.1-8080-2) doesMaxRowSizeIncludeBlobs: true
22:33:39,426 ERROR [stderr] (http--127.0.0.1-8080-2) supportsBatchUpdates: true
22:33:39,426 ERROR [stderr] (http--127.0.0.1-8080-2) 139191  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.jdbc.JDBC - Initial connection autoCommit: true, holdability: 2, TransactionIsolation: 4
22:33:39,427 ERROR [stderr] (http--127.0.0.1-8080-2) 139192  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.jdbc.JDBC - <t 1160114731, conn 1118349354> [0 ms] close
22:33:39,427 ERROR [stderr] (http--127.0.0.1-8080-2) 139192  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.jdbc.JDBC - createConnectionFactory: DataSource:org.jboss.jca.adapters.jdbc.WrapperDataSource@36cb1594
22:33:39,428 ERROR [stderr] (http--127.0.0.1-8080-2) 139193  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.jdbc.JDBC - <t 1160114731, conn 1607615466> [0 ms] close
22:33:39,430 ERROR [stderr] (http--127.0.0.1-8080-2) 139195  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.Runtime - Found datasource1: datasource 919278996 from configuration. StoreContext: org.apache.openjpa.kernel.BrokerImpl@4a8b9b70
22:33:39,432 ERROR [stderr] (http--127.0.0.1-8080-2) 139197  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - Scanning URL "vfs:/content/JPA_BASIC_Demo.war/WEB-INF/classes/" for persistent types.
22:33:39,433 ERROR [stderr] (http--127.0.0.1-8080-2) 139198  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - Scan of "vfs:/content/JPA_BASIC_Demo.war/WEB-INF/classes/" found persistent types [].
22:33:39,433 ERROR [stderr] (http--127.0.0.1-8080-2) 139198  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - Skipping persistent type location association for location "vfs:/content/JPA_BASIC_Demo.war/WEB-INF/classes/" since it is a directory.
22:33:39,434 ERROR [stderr] (http--127.0.0.1-8080-2) 139199  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - Scanning resource "META-INF/orm.xml" for persistent types.
22:33:39,435 ERROR [stderr] (http--127.0.0.1-8080-2) 139200  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - The persistent unit root url is "vfs:/content/JPA_BASIC_Demo.war/WEB-INF/classes/"
22:33:39,436 ERROR [stderr] (http--127.0.0.1-8080-2) 139201  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - parsePersistentTypeNames() found [jpa.Employee].
22:33:39,436 ERROR [stderr] (http--127.0.0.1-8080-2) 139201  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - Found 1 classes with metadata in 4 milliseconds.
22:33:39,439 ERROR [stderr] (http--127.0.0.1-8080-2) 139204  EmployeeService  WARN   [http--127.0.0.1-8080-2] openjpa.Enhance - Creating subclass for "[class jpa.Employee]". This means that your application will be less efficient and will consume more memory than it would if you ran the OpenJPA enhancer. Additionally, lazy loading will not be available for one-to-one and many-to-one persistent attributes in types using field access; they will be loaded eagerly instead.
22:33:39,441 ERROR [stderr] (http--127.0.0.1-8080-2) 139206  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.Runtime - No cache marshaller found for id org.apache.openjpa.conf.MetaDataCacheMaintenance.
22:33:39,441 ERROR [stderr] (http--127.0.0.1-8080-2) 139206  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - Using metadata factory "org.apache.openjpa.persistence.jdbc.PersistenceMappingFactory@4812eb99".
22:33:39,442 ERROR [stderr] (http--127.0.0.1-8080-2) 139207  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - Loading metadata for "class jpa.Employee" under mode "[META]".
22:33:39,442 ERROR [stderr] (http--127.0.0.1-8080-2) 139207  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - Scanning URL "vfs:/content/JPA_BASIC_Demo.war/WEB-INF/classes/" for persistent types.
22:33:39,443 ERROR [stderr] (http--127.0.0.1-8080-2) 139208  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - Scan of "vfs:/content/JPA_BASIC_Demo.war/WEB-INF/classes/" found persistent types [].
22:33:39,443 ERROR [stderr] (http--127.0.0.1-8080-2) 139208  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - Skipping persistent type location association for location "vfs:/content/JPA_BASIC_Demo.war/WEB-INF/classes/" since it is a directory.
22:33:39,443 ERROR [stderr] (http--127.0.0.1-8080-2) 139208  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - Scanning resource "META-INF/orm.xml" for persistent types.
22:33:39,444 ERROR [stderr] (http--127.0.0.1-8080-2) 139209  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - The persistent unit root url is "vfs:/content/JPA_BASIC_Demo.war/WEB-INF/classes/"
22:33:39,444 ERROR [stderr] (http--127.0.0.1-8080-2) 139209  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - parsePersistentTypeNames() found [jpa.Employee].
22:33:39,444 ERROR [stderr] (http--127.0.0.1-8080-2) 139209  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - Found 1 classes with metadata in 2 milliseconds.
22:33:39,445 ERROR [stderr] (http--127.0.0.1-8080-2) 139210  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - Parsing class "jpa.Employee".
22:33:39,445 ERROR [stderr] (http--127.0.0.1-8080-2) 139210  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - Parsing package "jpa.Employee".
22:33:39,448 ERROR [stderr] (http--127.0.0.1-8080-2) 139213  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - Generating default metadata for type "jpa.Employee".
22:33:39,449 ERROR [stderr] (http--127.0.0.1-8080-2) 139214  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - Using reflection for metadata generation.
22:33:39,451 ERROR [stderr] (http--127.0.0.1-8080-2) 139216  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - Set persistence-capable superclass of "jpa.Employee" to "null".
22:33:39,451 ERROR [stderr] (http--127.0.0.1-8080-2) 139216  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - Resolving metadata for "jpa.Employee@1378463430".
22:33:39,451 ERROR [stderr] (http--127.0.0.1-8080-2) 139216  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - 	Resolving field "jpa.Employee@1378463430.empno".
22:33:39,452 ERROR [stderr] (http--127.0.0.1-8080-2) 139217  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - 	Resolving field "jpa.Employee@1378463430.ename".
22:33:39,452 ERROR [stderr] (http--127.0.0.1-8080-2) 139217  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - Preparing mapping for "jpa.Employee".
22:33:39,452 ERROR [stderr] (http--127.0.0.1-8080-2) 139217  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - 	Resolving field "jpa.Employee@1378463430.empno".
22:33:39,453 ERROR [stderr] (http--127.0.0.1-8080-2) 139218  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - 	"empno" has mapping strategy "org.apache.openjpa.jdbc.meta.strats.HandlerFieldStrategy".
22:33:39,453 ERROR [stderr] (http--127.0.0.1-8080-2) 139218  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - 	Resolving field "jpa.Employee@1378463430.ename".
22:33:39,453 ERROR [stderr] (http--127.0.0.1-8080-2) 139218  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - 	"ename" has mapping strategy "org.apache.openjpa.jdbc.meta.strats.StringFieldStrategy".
22:33:39,454 ERROR [stderr] (http--127.0.0.1-8080-2) 139219  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - "jpa.Employee<discriminator>" has mapping strategy "none".
22:33:39,454 ERROR [stderr] (http--127.0.0.1-8080-2) 139219  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - "jpa.Employee<version>" has mapping strategy "none".
22:33:39,454 ERROR [stderr] (http--127.0.0.1-8080-2) 139219  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - Resolving mapping for "jpa.Employee@1378463430".
22:33:39,455 ERROR [stderr] (http--127.0.0.1-8080-2) 139220  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - "jpa.Employee" has mapping strategy "full".
22:33:39,455 ERROR [stderr] (http--127.0.0.1-8080-2) 139220  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.Enhance - Enhancing type "class jpa.Employee" loaded by ModuleClassLoader for Module "deployment.JPA_BASIC_Demo.war:main" from Service Module Loader.
22:33:39,475 INFO  [stdout] (http--127.0.0.1-8080-2) Employee Object Created. this: org.apache.openjpa.enhance.jpa$Employee$pcsubclass@206ab4f
22:33:39,477 ERROR [stderr] (http--127.0.0.1-8080-2) 139242  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - Loading metadata for "class jpa.Employee" under mode "[META][QUERY]".
22:33:39,477 ERROR [stderr] (http--127.0.0.1-8080-2) 139242  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - Parsing class "jpa.Employee".
22:33:39,477 ERROR [stderr] (http--127.0.0.1-8080-2) 139242  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - Parsing package "jpa.Employee".
22:33:39,478 ERROR [stderr] (http--127.0.0.1-8080-2) 139243  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - Generating default metadata for type "jpa.Employee".
22:33:39,480 ERROR [stderr] (http--127.0.0.1-8080-2) 139245  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - Set persistence-capable superclass of "jpa.Employee" to "null".
22:33:39,480 ERROR [stderr] (http--127.0.0.1-8080-2) 139245  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - Resolving metadata for "jpa.Employee@64540819".
22:33:39,481 ERROR [stderr] (http--127.0.0.1-8080-2) 139246  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - 	Resolving field "jpa.Employee@64540819.empno".
22:33:39,481 ERROR [stderr] (http--127.0.0.1-8080-2) 139246  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - 	Resolving field "jpa.Employee@64540819.ename".
22:33:39,481 INFO  [stdout] (http--127.0.0.1-8080-2) Employee Object Created. this: org.apache.openjpa.enhance.jpa$Employee$pcsubclass@f6564de
22:33:39,481 ERROR [stderr] (http--127.0.0.1-8080-2) 139246  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - Preparing mapping for "jpa.Employee".
22:33:39,482 INFO  [stdout] (http--127.0.0.1-8080-2) Employee Object Created. this: org.apache.openjpa.enhance.jpa$Employee$pcsubclass@49c132b7
22:33:39,482 ERROR [stderr] (http--127.0.0.1-8080-2) 139247  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - Processing registered persistence-capable class "class jpa.Employee".
22:33:39,482 INFO  [stdout] (http--127.0.0.1-8080-2) Employee Object Created. this: org.apache.openjpa.enhance.jpa$Employee$pcsubclass@2ae8b235
22:33:39,483 ERROR [stderr] (http--127.0.0.1-8080-2) 139248  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - Processing registered persistence-capable class "class jpa.Employee".
22:33:39,483 INFO  [stdout] (http--127.0.0.1-8080-2) Employee Object Created. this: org.apache.openjpa.enhance.jpa$Employee$pcsubclass@130bcb95
22:33:39,483 ERROR [stderr] (http--127.0.0.1-8080-2) 139248  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - Processing registered persistence-capable class "class jpa.Employee".
22:33:39,484 INFO  [stdout] (http--127.0.0.1-8080-2) Employee Object Created. this: org.apache.openjpa.enhance.jpa$Employee$pcsubclass@6b62acf7
22:33:39,484 ERROR [stderr] (http--127.0.0.1-8080-2) 139249  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - Processing registered persistence-capable class "class jpa.Employee".
22:33:39,484 INFO  [stdout] (http--127.0.0.1-8080-2) Employee Object Created. this: org.apache.openjpa.enhance.jpa$Employee$pcsubclass@1b49c335
22:33:39,485 ERROR [stderr] (http--127.0.0.1-8080-2) 139250  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - Processing registered persistence-capable class "class jpa.Employee".
22:33:39,485 INFO  [stdout] (http--127.0.0.1-8080-2) Employee Object Created. this: org.apache.openjpa.enhance.jpa$Employee$pcsubclass@7aeda92
22:33:39,486 ERROR [stderr] (http--127.0.0.1-8080-2) 139251  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - Processing registered persistence-capable class "class jpa.Employee".
22:33:39,486 INFO  [stdout] (http--127.0.0.1-8080-2) Employee Object Created. this: org.apache.openjpa.enhance.jpa$Employee$pcsubclass@688fab2e
22:33:39,486 ERROR [stderr] (http--127.0.0.1-8080-2) 139251  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - Processing registered persistence-capable class "class jpa.Employee".
22:33:39,487 INFO  [stdout] (http--127.0.0.1-8080-2) Employee Object Created. this: org.apache.openjpa.enhance.jpa$Employee$pcsubclass@302f8ea3
22:33:39,487 ERROR [stderr] (http--127.0.0.1-8080-2) 139252  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - Processing registered persistence-capable class "class jpa.Employee".
22:33:39,488 INFO  [stdout] (http--127.0.0.1-8080-2) Employee Object Created. this: org.apache.openjpa.enhance.jpa$Employee$pcsubclass@23d880c
22:33:39,488 ERROR [stderr] (http--127.0.0.1-8080-2) 139253  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - Processing registered persistence-capable class "class jpa.Employee".
22:33:39,488 INFO  [stdout] (http--127.0.0.1-8080-2) Employee Object Created. this: org.apache.openjpa.enhance.jpa$Employee$pcsubclass@15aeccfa
22:33:39,489 ERROR [stderr] (http--127.0.0.1-8080-2) 139254  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - Processing registered persistence-capable class "class jpa.Employee".
22:33:39,489 INFO  [stdout] (http--127.0.0.1-8080-2) Employee Object Created. this: org.apache.openjpa.enhance.jpa$Employee$pcsubclass@7133c35
22:33:39,489 ERROR [stderr] (http--127.0.0.1-8080-2) 139254  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - Processing registered persistence-capable class "class jpa.Employee".
22:33:39,490 INFO  [stdout] (http--127.0.0.1-8080-2) Employee Object Created. this: org.apache.openjpa.enhance.jpa$Employee$pcsubclass@7fd5bf33
22:33:39,490 ERROR [stderr] (http--127.0.0.1-8080-2) 139255  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - Processing registered persistence-capable class "class jpa.Employee".
22:33:39,490 INFO  [stdout] (http--127.0.0.1-8080-2) Employee Object Created. this: org.apache.openjpa.enhance.jpa$Employee$pcsubclass@29fbeed6
22:33:39,490 ERROR [stderr] (http--127.0.0.1-8080-2) 139255  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - Processing registered persistence-capable class "class jpa.Employee".
22:33:39,491 INFO  [stdout] (http--127.0.0.1-8080-2) Employee Object Created. this: org.apache.openjpa.enhance.jpa$Employee$pcsubclass@5afd3922
22:33:39,491 ERROR [stderr] (http--127.0.0.1-8080-2) 139256  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - Processing registered persistence-capable class "class jpa.Employee".
22:33:39,491 INFO  [stdout] (http--127.0.0.1-8080-2) Employee Object Created. this: org.apache.openjpa.enhance.jpa$Employee$pcsubclass@26b215d9
22:33:39,492 ERROR [stderr] (http--127.0.0.1-8080-2) 139257  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - Processing registered persistence-capable class "class jpa.Employee".
22:33:39,492 INFO  [stdout] (http--127.0.0.1-8080-2) Employee Object Created. this: org.apache.openjpa.enhance.jpa$Employee$pcsubclass@75b86d67
22:33:39,492 ERROR [stderr] (http--127.0.0.1-8080-2) 139257  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - Processing registered persistence-capable class "class jpa.Employee".
22:33:39,492 INFO  [stdout] (http--127.0.0.1-8080-2) Employee Object Created. this: org.apache.openjpa.enhance.jpa$Employee$pcsubclass@1f16c192
22:33:39,493 ERROR [stderr] (http--127.0.0.1-8080-2) 139258  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - Processing registered persistence-capable class "class jpa.Employee".
22:33:39,493 INFO  [stdout] (http--127.0.0.1-8080-2) Employee Object Created. this: org.apache.openjpa.enhance.jpa$Employee$pcsubclass@efe6830
22:33:39,493 ERROR [stderr] (http--127.0.0.1-8080-2) 139258  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - Processing registered persistence-capable class "class jpa.Employee".
22:33:39,496 INFO  [stdout] (http--127.0.0.1-8080-2) Employee Object Created. this: org.apache.openjpa.enhance.jpa$Employee$pcsubclass@606a2f00
22:33:39,496 ERROR [stderr] (http--127.0.0.1-8080-2) 139261  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - Processing registered persistence-capable class "class jpa.Employee".
22:33:39,497 INFO  [stdout] (http--127.0.0.1-8080-2) Employee Object Created. this: org.apache.openjpa.enhance.jpa$Employee$pcsubclass@5b33da73
22:33:39,497 ERROR [stderr] (http--127.0.0.1-8080-2) 139262  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - Processing registered persistence-capable class "class jpa.Employee".
22:33:39,497 ERROR [stderr] (http--127.0.0.1-8080-2) 139262  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - 	Resolving field "jpa.Employee@64540819.empno".
22:33:39,498 ERROR [stderr] (http--127.0.0.1-8080-2) 139263  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - 	"empno" has mapping strategy "org.apache.openjpa.jdbc.meta.strats.HandlerFieldStrategy".
22:33:39,499 ERROR [stderr] (http--127.0.0.1-8080-2) 139264  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - 	Resolving field "jpa.Employee@64540819.ename".
22:33:39,499 ERROR [stderr] (http--127.0.0.1-8080-2) 139264  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - 	"ename" has mapping strategy "org.apache.openjpa.jdbc.meta.strats.StringFieldStrategy".
22:33:39,500 ERROR [stderr] (http--127.0.0.1-8080-2) 139265  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - "jpa.Employee<discriminator>" has mapping strategy "none".
22:33:39,500 ERROR [stderr] (http--127.0.0.1-8080-2) 139265  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - "jpa.Employee<version>" has mapping strategy "none".
22:33:39,501 ERROR [stderr] (http--127.0.0.1-8080-2) 139266  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - Resolving mapping for "jpa.Employee@64540819".
22:33:39,501 ERROR [stderr] (http--127.0.0.1-8080-2) 139266  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - "jpa.Employee" has mapping strategy "full".
22:33:39,501 ERROR [stderr] (http--127.0.0.1-8080-2) 139266  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - Initializing mapping for "jpa.Employee@64540819".
22:33:39,501 ERROR [stderr] (http--127.0.0.1-8080-2) 139266  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - 	Resolving field "jpa.Employee@64540819.empno".
22:33:39,502 ERROR [stderr] (http--127.0.0.1-8080-2) 139267  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.MetaData - 	Resolving field "jpa.Employee@64540819.ename".
22:33:39,502 ERROR [stderr] (http--127.0.0.1-8080-2) 139267  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.Runtime - org.apache.openjpa.persistence.EntityManagerFactoryImpl@874aa79 created EntityManager org.apache.openjpa.persistence.EntityManagerImpl@4a8b9b70.
22:33:39,503 INFO  [stdout] (http--127.0.0.1-8080-2) Employee Object Created. this: org.apache.openjpa.enhance.jpa$Employee$pcsubclass@294ae2cc
22:33:39,505 INFO  [stdout] (http--127.0.0.1-8080-2) Employee Object Created. this: org.apache.openjpa.enhance.jpa$Employee$pcsubclass@4555333c
22:33:39,506 INFO  [stdout] (http--127.0.0.1-8080-2) 
22:33:39,506 INFO  [stdout] (http--127.0.0.1-8080-2) 	[EmployeeService] Before findEmployee(id)
22:33:39,507 INFO  [stdout] (http--127.0.0.1-8080-2) 
22:33:39,507 INFO  [stdout] (http--127.0.0.1-8080-2) 	 Inside findEmployee(67)
22:33:39,507 INFO  [stdout] (http--127.0.0.1-8080-2) 
22:33:39,507 INFO  [stdout] (http--127.0.0.1-8080-2) 	[EmployeeService] Inside createEmployee() findEmployee result: jpa.Employee@7345a749
22:33:39,507 ERROR [stderr] (http--127.0.0.1-8080-2) 139272  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.jdbc.SQLDiag - flush: org.apache.openjpa.kernel.PNewState for oid=67
22:33:39,508 ERROR [stderr] (http--127.0.0.1-8080-2) 139273  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.jdbc.JDBC - The batch limit is set to 0.
22:33:39,508 ERROR [stderr] (http--127.0.0.1-8080-2) 139273  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.jdbc.SQL - <t 1160114731, conn 1553386419> executing prepstmnt 1335485472 INSERT INTO Employee (empno, ename) VALUES (?, ?) [params=?, ?]
22:33:39,579 ERROR [stderr] (http--127.0.0.1-8080-2) 139344  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.jdbc.SQL - <t 1160114731, conn 1553386419> [70 ms] spent
22:33:39,580 ERROR [stderr] (http--127.0.0.1-8080-2) 139345  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.Runtime - org.apache.openjpa.persistence.EntityManagerImpl@4a8b9b70.close() invoked.
22:33:39,580 ERROR [stderr] (http--127.0.0.1-8080-2) 139345  EmployeeService  TRACE  [http--127.0.0.1-8080-2] openjpa.jdbc.JDBC - <t 1160114731, conn 1553386419> [0 ms] close
22:33:39,600 INFO  [stdout] (http--127.0.0.1-8080-2) Employee Object Created. this: jpa.Employee@42c16479
22:33:39,601 INFO  [stdout] (http--127.0.0.1-8080-2) 
22:33:39,601 INFO  [stdout] (http--127.0.0.1-8080-2) 	 Hello World...

.

=======================================================================

Some Issues You Might Face

=======================================================================

Issue-1

If you dont declare the property name=”jboss.as.jpa.providerModule” value=”org.apache.openjpa” in your “persistence.xml” file then you might see following exception while deploying your OpenJPA JPA:

22:39:34,646 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-5) MSC00001: Failed to start service jboss.deployment.unit."JPA_BASIC_Demo.war".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit."JPA_BASIC_Demo.war".INSTALL: Failed to process phase INSTALL of deployment "JPA_BASIC_Demo.war"
	at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
	at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
	at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.6.0_24]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.6.0_24]
	at java.lang.Thread.run(Thread.java:679) [rt.jar:1.6.0_24]
Caused by: javax.persistence.PersistenceException: JBAS011466: PersistenceProvider 'org.apache.openjpa.persistence.PersistenceProviderImpl' not found
	at org.jboss.as.jpa.processor.PersistenceUnitDeploymentProcessor.lookupProvider(PersistenceUnitDeploymentProcessor.java:555)
	at org.jboss.as.jpa.processor.PersistenceUnitDeploymentProcessor.deployPersistenceUnit(PersistenceUnitDeploymentProcessor.java:295)
	at org.jboss.as.jpa.processor.PersistenceUnitDeploymentProcessor.addPuService(PersistenceUnitDeploymentProcessor.java:258)
	at org.jboss.as.jpa.processor.PersistenceUnitDeploymentProcessor.handleWarDeployment(PersistenceUnitDeploymentProcessor.java:194)
	at org.jboss.as.jpa.processor.PersistenceUnitDeploymentProcessor.deploy(PersistenceUnitDeploymentProcessor.java:118)
	at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
	... 5 more

Issue-2

If the above code “TestServlet.java” If you will invoke two Operations on the entity then you may get following exceptions. To reproduce this issue just uncomment the following section in the “TestServlet.java”:


                        remote.createEmployee(new Integer(request.getParameter("empId")),request.getParameter("empName"));
                        out.println("Everything is OK till Here ...");

                        /* 
                         If i call the "remote.findAllEmployees()" Now then i get an Exception here .... Only with OpenJPA 
                         (where as it works well with TopLink and Hibernate) 
                        */                   

                        Collection<Employee> employees=remote.findAllEmployees();   //----> This line throws the following exception 

You will see the following kind of “ClassNotFoundException”

23:00:04,399 ERROR [stderr] (http--127.0.0.1-8080-1) java.lang.RuntimeException: ClassNotFoundException marshaling EJB parameters
23:00:04,400 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.as.ejb3.remote.LocalEjbReceiver.clone(LocalEjbReceiver.java:229)
23:00:04,400 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.as.ejb3.remote.LocalEjbReceiver.clone(LocalEjbReceiver.java:216)
23:00:04,400 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.as.ejb3.remote.LocalEjbReceiver.processInvocation(LocalEjbReceiver.java:188)
23:00:04,400 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:179)
23:00:04,401 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.ejb.client.TransactionInterceptor.handleInvocation(TransactionInterceptor.java:43)
23:00:04,401 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:181)
23:00:04,401 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:128)
23:00:04,402 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:181)
23:00:04,402 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:136)
23:00:04,402 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:121)
23:00:04,402 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:104)
23:00:04,403 ERROR [stderr] (http--127.0.0.1-8080-1) 	at $Proxy19.findAllEmployees(Unknown Source)
23:00:04,403 ERROR [stderr] (http--127.0.0.1-8080-1) 	at servlets.TestServlet.service(Unknown Source)
23:00:04,403 ERROR [stderr] (http--127.0.0.1-8080-1) 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
23:00:04,403 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)
23:00:04,403 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
23:00:04,404 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
23:00:04,404 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
23:00:04,404 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50)
23:00:04,404 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153)
23:00:04,405 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)
23:00:04,405 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
23:00:04,405 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
23:00:04,405 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368)
23:00:04,406 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
23:00:04,406 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671)
23:00:04,406 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930)
23:00:04,406 ERROR [stderr] (http--127.0.0.1-8080-1) 	at java.lang.Thread.run(Thread.java:679)
23:00:04,407 ERROR [stderr] (http--127.0.0.1-8080-1) Caused by: java.lang.ClassNotFoundException: org.apache.openjpa.enhance.jpa$Employee$pcsubclass from [Module "deployment.JPA_BASIC_Demo.war:main" from Service Module Loader]
23:00:04,407 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
23:00:04,407 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
23:00:04,408 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
23:00:04,408 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:423)
23:00:04,408 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
23:00:04,408 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
23:00:04,408 ERROR [stderr] (http--127.0.0.1-8080-1) 	at java.lang.Class.forName0(Native Method)
23:00:04,409 ERROR [stderr] (http--127.0.0.1-8080-1) 	at java.lang.Class.forName(Class.java:264)
23:00:04,409 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.marshalling.cloner.ClassLoaderClassCloner.clone(ClassLoaderClassCloner.java:46)
23:00:04,409 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:158)
23:00:04,409 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:135)
23:00:04,409 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:187)
23:00:04,410 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:135)
23:00:04,410 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.marshalling.cloner.SerializingCloner$StepObjectInput.doReadObject(SerializingCloner.java:738)
23:00:04,410 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.marshalling.AbstractObjectInput.readObject(AbstractObjectInput.java:37)
23:00:04,410 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.marshalling.MarshallerObjectInputStream.readObjectOverride(MarshallerObjectInputStream.java:57)

Issue-3

If you wont Specify the following properties in your “persistence.xml” file then you may encounter the following exceptions:

           <!--   IMPORTANT PROPERTIES FOR openJPA -->           
           <property name="openjpa.DynamicEnhancementAgent" value="false"/>
           <property name="openjpa.RuntimeUnenhancedClasses" value="supported" />

Following exceptions you will encounter …

22:43:47,285 ERROR [org.jboss.ejb3.invocation] (http--127.0.0.1-8080-1) JBAS014134: EJB Invocation failed on component EmployeeService for method public abstract jpa.Employee jpa.EmployeeServiceRemote.createEmployee(java.lang.Integer,java.lang.String): javax.ejb.EJBException: <openjpa-2.2.0-r422266:1244990 fatal user error> org.apache.openjpa.persistence.ArgumentException: The type "class jpa.Employee" has not been enhanced.

	at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleExceptionInOurTx(CMTTxInterceptor.java:166) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
	at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:230) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
	at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:304) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
	at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:190) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
	at org.jboss.as.ejb3.remote.EJBRemoteTransactionPropagatingInterceptor.processInvocation(EJBRemoteTransactionPropagatingInterceptor.java:80) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
	at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
	at org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:59) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
	at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
	at org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:32) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
	at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
	at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
	at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:165) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]
	at org.jboss.as.ejb3.remote.LocalEjbReceiver.processInvocation(LocalEjbReceiver.java:179) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
	at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:179) [jboss-ejb-client-1.0.5.Final.jar:1.0.5.Final]
	at org.jboss.ejb.client.TransactionInterceptor.handleInvocation(TransactionInterceptor.java:43) [jboss-ejb-client-1.0.5.Final.jar:1.0.5.Final]
	at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:181) [jboss-ejb-client-1.0.5.Final.jar:1.0.5.Final]
	at org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:128) [jboss-ejb-client-1.0.5.Final.jar:1.0.5.Final]
	at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:181) [jboss-ejb-client-1.0.5.Final.jar:1.0.5.Final]
	at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:136) [jboss-ejb-client-1.0.5.Final.jar:1.0.5.Final]
	at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:121) [jboss-ejb-client-1.0.5.Final.jar:1.0.5.Final]
	at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:104) [jboss-ejb-client-1.0.5.Final.jar:1.0.5.Final]
	at $Proxy15.createEmployee(Unknown Source)	at servlets.TestServlet.service(Unknown Source) [classes:]
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.13.Final.jar:]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.13.Final.jar:]
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.13.Final.jar:]
	at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]
	at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:]
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:]
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:]
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:]
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.13.Final.jar:]
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.13.Final.jar:]
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.13.Final.jar:]
	at java.lang.Thread.run(Thread.java:679) [rt.jar:1.6.0_24]



Caused by: <openjpa-2.2.0-r422266:1244990 fatal user error> org.apache.openjpa.persistence.ArgumentException: The type "class jpa.Employee" has not been enhanced.
	at org.apache.openjpa.meta.ClassMetaData.resolveMeta(ClassMetaData.java:1823) [openjpa-all-2.2.0.jar:2.2.0]
	at org.apache.openjpa.meta.ClassMetaData.resolve(ClassMetaData.java:1797) [openjpa-all-2.2.0.jar:2.2.0]
	at org.apache.openjpa.meta.MetaDataRepository.processBuffer(MetaDataRepository.java:822) [openjpa-all-2.2.0.jar:2.2.0]
	at org.apache.openjpa.meta.MetaDataRepository.resolveMeta(MetaDataRepository.java:719) [openjpa-all-2.2.0.jar:2.2.0]
	at org.apache.openjpa.meta.MetaDataRepository.resolve(MetaDataRepository.java:643) [openjpa-all-2.2.0.jar:2.2.0]
	at org.apache.openjpa.meta.MetaDataRepository.getMetaDataInternal(MetaDataRepository.java:411) [openjpa-all-2.2.0.jar:2.2.0]
	at org.apache.openjpa.meta.MetaDataRepository.getMetaData(MetaDataRepository.java:384) [openjpa-all-2.2.0.jar:2.2.0]
	at org.apache.openjpa.kernel.BrokerImpl.newObjectId(BrokerImpl.java:1262) [openjpa-all-2.2.0.jar:2.2.0]
	at org.apache.openjpa.kernel.DelegatingBroker.newObjectId(DelegatingBroker.java:316) [openjpa-all-2.2.0.jar:2.2.0]
	at org.apache.openjpa.persistence.EntityManagerImpl.find(EntityManagerImpl.java:486) [openjpa-all-2.2.0.jar:2.2.0]
	at org.jboss.as.jpa.container.AbstractEntityManager.find(AbstractEntityManager.java:193) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]
	at jpa.EmployeeService.findEmployee(Unknown Source) [classes:]
	at jpa.EmployeeService.createEmployee(Unknown Source) [classes:]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.6.0_24]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.6.0_24]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.6.0_24]
	at java.lang.reflect.Method.invoke(Method.java:616) [rt.jar:1.6.0_24]
	at org.jboss.as.ee.component.ManagedReferenceMethodInterceptorFactory$ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptorFactory.java:72) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
	at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
	at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:36) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
	at org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:47) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
	at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
	at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
	at org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:53) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
	at org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:51) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
	at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:228) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
	... 43 more

22:43:47,461 ERROR [stderr] (http--127.0.0.1-8080-1) javax.ejb.EJBException: <openjpa-2.2.0-r422266:1244990 fatal user error> org.apache.openjpa.persistence.ArgumentException: The type "class jpa.Employee" has not been enhanced.


22:43:47,462 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleExceptionInOurTx(CMTTxInterceptor.java:166)
22:43:47,462 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:230)
22:43:47,462 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:304)
22:43:47,462 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:190)
22:43:47,463 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
22:43:47,463 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.as.ejb3.remote.EJBRemoteTransactionPropagatingInterceptor.processInvocation(EJBRemoteTransactionPropagatingInterceptor.java:80)
22:43:47,463 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
22:43:47,463 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41)
22:43:47,464 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
22:43:47,464 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:59)
22:43:47,464 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
22:43:47,464 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)
22:43:47,465 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
22:43:47,465 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:32)
22:43:47,465 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
22:43:47,465 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45)
22:43:47,466 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
22:43:47,466 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
22:43:47,466 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:165)
22:43:47,466 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.as.ejb3.remote.LocalEjbReceiver.processInvocation(LocalEjbReceiver.java:179)
22:43:47,467 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:179)
22:43:47,467 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.ejb.client.TransactionInterceptor.handleInvocation(TransactionInterceptor.java:43)
22:43:47,467 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:181)
22:43:47,468 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:128)
22:43:47,468 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:181)
22:43:47,468 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:136)
22:43:47,469 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:121)
22:43:47,469 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:104)
22:43:47,469 ERROR [stderr] (http--127.0.0.1-8080-1) 	at $Proxy15.createEmployee(Unknown Source)
22:43:47,469 ERROR [stderr] (http--127.0.0.1-8080-1) 	at servlets.TestServlet.service(Unknown Source)
22:43:47,469 ERROR [stderr] (http--127.0.0.1-8080-1) 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
22:43:47,470 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)
22:43:47,470 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
22:43:47,470 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
22:43:47,470 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
22:43:47,471 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50)
22:43:47,471 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153)
22:43:47,471 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)
22:43:47,471 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
22:43:47,472 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
22:43:47,472 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368)
22:43:47,472 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
22:43:47,472 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671)
22:43:47,473 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930)
22:43:47,473 ERROR [stderr] (http--127.0.0.1-8080-1) 	at java.lang.Thread.run(Thread.java:679)




22:43:47,473 ERROR [stderr] (http--127.0.0.1-8080-1) Caused by: <openjpa-2.2.0-r422266:1244990 fatal user error> org.apache.openjpa.persistence.ArgumentException: The type "class jpa.Employee" has not been enhanced.
22:43:47,474 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.apache.openjpa.meta.ClassMetaData.resolveMeta(ClassMetaData.java:1823)
22:43:47,474 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.apache.openjpa.meta.ClassMetaData.resolve(ClassMetaData.java:1797)
22:43:47,474 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.apache.openjpa.meta.MetaDataRepository.processBuffer(MetaDataRepository.java:822)
22:43:47,475 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.apache.openjpa.meta.MetaDataRepository.resolveMeta(MetaDataRepository.java:719)
22:43:47,475 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.apache.openjpa.meta.MetaDataRepository.resolve(MetaDataRepository.java:643)
22:43:47,475 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.apache.openjpa.meta.MetaDataRepository.getMetaDataInternal(MetaDataRepository.java:411)
22:43:47,475 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.apache.openjpa.meta.MetaDataRepository.getMetaData(MetaDataRepository.java:384)
22:43:47,475 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.apache.openjpa.kernel.BrokerImpl.newObjectId(BrokerImpl.java:1262)
22:43:47,476 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.apache.openjpa.kernel.DelegatingBroker.newObjectId(DelegatingBroker.java:316)
22:43:47,476 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.apache.openjpa.persistence.EntityManagerImpl.find(EntityManagerImpl.java:486)
22:43:47,476 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.as.jpa.container.AbstractEntityManager.find(AbstractEntityManager.java:193)
22:43:47,476 ERROR [stderr] (http--127.0.0.1-8080-1) 	at jpa.EmployeeService.findEmployee(Unknown Source)
22:43:47,477 ERROR [stderr] (http--127.0.0.1-8080-1) 	at jpa.EmployeeService.createEmployee(Unknown Source)

Issue-4

In the above JBoss Console Outputs you will notice that JBoss is showing “ERROR” for most of the things where the Open JPA TRACE log is showing a successful execution,. Means Even if the Execution is successful JBoss is showing ERROR.

.
.
Thanks
Middleware Magic Team πŸ™‚


JPA2 with Oracle TopLink 12c (12.1.1) in JBossAS7.1.1

Hi,

The Java Persistence Architecture API (JPA) is a Java specification for accessing, persisting, and managing data between Java objects / classes and a relational database. JPA was defined as part of the EJB 3.0 specification as a replacement for the EJB 2 CMP Entity Beans specification. JPA is now considered the standard industry approach for Object to Relational Mapping (ORM) in the Java Industry.

The JBoss Application Server JPA subsystem implements the JPA 2.0 container-managed requirements. JPA Applications use the Hibernate (core) 4.0 persistence provider, that is included with JBoss AS. Hibernate 4 is packaged with the AS and is the default persistence provider. The JPA 2.0 Specifications can be found in the following link: http://jcp.org/aboutJava/communityprocess/pfd/jsr317/index.html

A Best reference for JPA features inside JBoss AS7 can be foun in the following link: https://docs.jboss.org/author/display/AS7/JPA+Reference+Guide

However in this current Demo we will just create a Simple JPA persistence unit With the help of “Oracle TopLink 12c (12.1.1)” and then we will try to insert some employee detils insie the DataBase. So basically this is just as a startup.

In this example we will mainly focus on following points

Point-1). We will see how to use “Oracle TopLink 12c (12.1.1)” with JBossAS7.1.1.Final.

Point-2). For Web Applications we should put the “persistence.xml” file inside “${WEB_APPLICATION}/WEB-INF/classes/META-INF/persistence.xml” AND For EJB Applications we should put the “persistence.xml” file inside “${EJB_JAR}/META-INF”

Point-3). To inject the EntityManager inside our Web Components we can use the annotation @javax.persistence.PersistenceContext(unitName=”name”)

Point-4). We can use the @javax.ejb.EJB annotation to inject an Enterprise Java Bean inside our app components. Like @EJB(lookup=”jndiName”)

Point-5). We will see what error we get when we dont define following property in our “persistence.xml” file while using Oracle topLink. < property name=”jboss.as.jpa.providerModule” value=”org.eclipse.persistence.jpa” />

Point-6). The Full Demo can be downloaded from the following Github repository:
https://github.com/jaysensharma/MiddlewareMagicDemos/tree/master/JPA2_And_Toplink_On_AS7

Creating DataSource On JBossAS7

Step-1). Here we are using JBoss AS7 latest build “jboss-as-7.1.1.Final” which can be downloaded from the following link: http://www.jboss.org/jbossas/downloads

Step-2). In order to get more details on how to create MySQL DataSource in JBoss AS7 you can refer to the following article: http://middlewaremagic.com/jboss/?p=872
Just place the “mysql-connector-java-5.1.13-bin.jar” MySQL Jdbc driver in your JBoss Deployments directory, Then create a DataSource inside “${JBOSS_HOME}/standalone/configuration/standalone-full.xml” file as following:

        <subsystem xmlns="urn:jboss:domain:datasources:1.0">
            <datasources>

                <!-- Below is the DataSource Configuration which we added for our JPA TestCase-->
                <datasource jta="false" jndi-name="java:/MySqlDS" pool-name="MySqlDS_Pool" enabled="true" use-ccm="false">
                    <connection-url>jdbc:mysql://localhost:3306/testDB</connection-url>
                    <driver-class>com.mysql.jdbc.Driver</driver-class>
                    <driver>mysql-connector-java-5.1.13-bin.jar</driver>
                    <security>
                        <user-name>someDBUserName</user-name>
                        <password>someDBPassword</password>
                    </security>
                </datasource>
                <drivers>
                    <driver name="h2" module="com.h2database.h2">
                        <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
                    </driver>
                </drivers>
            </datasources>
        </subsystem>

Creating Oracle Toplink Module In JBossAS7

Step-3). Download the “Oracle TopLink 12c (12.1.1)” toplink.zip (25,456,648 bytes) from the following link:
http://www.oracle.com/technetwork/middleware/toplink/downloads/index.html

Step-4). Extract the downloaded “toplink.zip” and then copy the two Jars placed insie the extracted “toplink/jlib” directory. The Jar names will be “toplink-grid.jar” And “eclipselink.jar”

Step-5). Create the following directory structure [jboss-as-7.1.1.Final/modules/org/eclipse/persistence/jpa/main] in your file system so that the Oracle TopLink Module can be created.

     .
     .Β Β 
     jboss-as-7.1.1.Final/modules/
     β”‚Β Β 
     β”œβ”€β”€org
     β”‚Β Β  β”‚Β Β      
     β”‚Β Β  β”œβ”€β”€ eclipse
     β”‚Β Β  β”‚Β Β  └── persistence
     β”‚Β Β  β”‚Β Β      └── jpa
     β”‚Β Β  β”‚Β Β          └── main
     β”‚Β Β  β”‚Β Β              β”œβ”€β”€ eclipselink.jar
     β”‚Β Β  β”‚Β Β              β”œ
     β”‚Β Β  β”‚Β Β              β”œβ”€β”€ toplink-grid.jar
     β”‚Β Β  β”‚Β Β              β”œ
     β”‚Β Β  β”‚Β Β              β”œβ”€β”€ module.xml
     .
     .

Paste the “toplink-grid.jar” And “eclipselink.jar” from downloaded toplink s/w into the “jboss-as-7.1.1.Final/modules/org/eclipse/persistence/jpa/main” and then write the following kind of “module.xml” file:

<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="org.eclipse.persistence.jpa">
    <resources>
        <resource-root path="eclipselink.jar"/>
        <resource-root path="toplink-grid.jar"/>
    </resources>

        <dependencies> 
            <module name="javax.persistence.api"/> 
            <module name="javax.transaction.api"/> 
            <module name="javax.validation.api"/> 
        </dependencies> 
</module>

Step-6). Restart your JBoss AS7 from inside “/home/userone/jboss-as-7.1.1.Final/bin” directory as following:

.
 ./standalone.sh -c standalone-full.xml
.

Developing Oracle Toplink JPA Demo

Step1). Create a directory somewhere in your filesystem like “/home/userone/JPA2_And_Toplink_On_AS7” where we will place our application build related stuff. Then create another directory “src” inside “/home/userone/JPA2_And_Toplink_On_AS7” where we will be placing our source codes and JSPs.

Step2). Now first of all we will create an Entity “Employee.java” as following inside the “/home/userone/JPA2_And_Toplink_On_AS7/src” directory.

package jpa;
import java.io.Serializable;
import javax.persistence.*;
import java.lang.Integer;

@Entity
@Table(name="Employee")
public class Employee implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	private Integer empno;

	private String ename;

    public Employee() {
    	System.out.println("Employee Object Created. this: "+this);
    }

	public Integer getEmpno() {
		return this.empno;
	}

	public void setEmpno(Integer empno) {
		this.empno = empno;
	}

	public String getEname() {
		return this.ename;
	}

	public void setEname(String ename) {
		this.ename = ename;
	}

}

Step3). Now we will create a Simple Stateless SessionBean remote Interface “EmployeeServiceRemote.java” inside “/home/userone/JPA2_And_Toplink_On_AS7/src” directory as following:

package jpa;
import java.lang.Integer;
import java.util.Collection;
import javax.ejb.Remote;
@Remote

public interface EmployeeServiceRemote{
  public void doAction();
  public Employee createEmployee(Integer id, String name);
  public void removeEmployee(Integer id);
  public Employee findEmployee(Integer id);
  public Collection<Employee> findAllEmployees() ;

}

Step4). Now we will Stateless Session Bean class “EmployeeService.java” by implementing the interface “EmployeeServiceRemote.java”. Place this file as well inside the “/home/userone/JPA2_And_Toplink_On_AS7/src” directory as following:

package jpa;
import java.lang.Integer;
import java.util.Collection;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import javax.persistence.EntityTransaction;
import javax.ejb.*;

@Stateless
public class EmployeeService implements EmployeeServiceRemote {
  @PersistenceContext(unitName="EmployeeService")
  EntityManager em;

  public EmployeeService() {
	  System.out.println("ntEmployeeService  Object Created. this: "+this);
  }

  @TransactionAttribute (TransactionAttributeType.REQUIRED)
  public Employee createEmployee(Integer id, String name) {
    Employee emp = new Employee();
    emp.setEmpno(id);
    emp.setEname(name);
    System.out.println("nt[EmployeeService] Before em.persist(emp)");

    try{ 
         em.getTransaction().begin();
         em.persist(emp);
         em.flush();
         em.getTransaction().commit();
       } 
    catch(Exception e)
       {
          e.printStackTrace();
          try{   em.getTransaction().rollback();   } catch(Exception ee)  {  ee.printStackTrace();  }
       }

    System.out.println("nt[EmployeeService] Before findEmployee(id)");
    emp = findEmployee(id);
    System.out.println("nt[EmployeeService] Inside createEmployee() findEmployee result: "+emp);
    return emp;
  }

  public void removeEmployee(Integer id) {
	System.out.println("nt Inside removeEmployee("+id+")");
    Employee emp = findEmployee(id);
    if (emp != null) {
       try{ 
            em.getTransaction().begin();
            em.remove(emp);
            em.getTransaction().commit();
          } 
       catch(Exception e)
          {
             e.printStackTrace();
             try{   em.getTransaction().rollback();   } catch(Exception ee)  {  ee.printStackTrace();  }
          }
    }
  }

  public Employee findEmployee(Integer id) {
	System.out.println("nt Inside findEmployee("+id+")");
    return em.find(Employee.class, id);
  }

  @SuppressWarnings("unchecked")
  public Collection<Employee> findAllEmployees() {
	System.out.println("nt Inside findAllEmployees()");
    Query query = em.createQuery("SELECT e FROM Employee e");
    return (Collection<Employee>) query.getResultList();
  }

  public void doAction(){
  }
}


Step5). Now we will write the “persistence.xml” file inside the “/home/userone/JPA2_And_Toplink_On_AS7/src” directory as following:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.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_2_0.xsd">
  <persistence-unit name="EmployeeService">
       <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
       <jta-data-source>java:/MySqlDS</jta-data-source> 
       <class>jpa.Employee</class>

       <properties>
          <!-- Note jboss.as.jpa.providerModule property is very important -->
          <property name="jboss.as.jpa.providerModule" value="org.eclipse.persistence.jpa" />
       </properties>
  </persistence-unit>
</persistence>

NOTE: We need to make sure that this “persistence.xml” file goes inside the “${war.name}/WEB-INF/classes/META-INF” directory of our WAR file. Note jboss.as.jpa.providerModule property is very important

Step6). Now we will write a simple “index.jsp” page to just provide a some input forms so that a user can enter the employee name and id details , Place this file as well inside the “/home/userone/JPA2_And_Toplink_On_AS7/src” directory as following:

<html>
<head>
<title>JPA Demo In JBoss AS7</title>
</head>
<body>
   <form action="TestServlet">
   Enter Employee ID : <input name="empId" type="text" value="" /> <BR/>
   Enter Employee Name : <input name="empName" type="text" value="" /> <BR/>
   <input type="submit" value="Store" />
   </form>
</body>
</html>

Step7). We will write the “TestServlet.java” inside the “/home/userone/JPA2_And_Toplink_On_AS7/src” as following in order to insert the details entered by the user in previous index.jsp page.

package servlets;
import java.io.IOException;
import java.io.PrintWriter;
import java.lang.Integer;
import javax.ejb.EJB;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import javax.transaction.*;
import javax.annotation.*;
import jpa.Employee;

@WebServlet(value="/TestServlet")
public class TestServlet extends HttpServlet 
  {
	private static final long serialVersionUID = 1L;


        @Resource private UserTransaction 
        utx;
 
        @PersistenceContext(unitName="EmployeeService")
	EntityManager em;
	  
        @EJB(lookup="java:global/JPA_BASIC_Demo/EmployeeService!jpa.EmployeeServiceRemote")
        jpa.EmployeeServiceRemote remote;


	public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
                PrintWriter out=null;
		try {
			System.out.println("inside TestServlet service()");
			System.out.println("GOT the UserTransaction       :  "+utx);
			System.out.println("Got jpa.EmployeeServiceRemote :  "+remote);
			out=response.getWriter();			
			
                        remote.createEmployee(new Integer(request.getParameter("empId")),request.getParameter("empName"));

                        out.println("<html><head><title>JPA Insert</title></head><body>");
			out.println("<BR>Employee Record Inserted in the Database.<BR>");
                        out.println("<TABLE border="10%">");
                        out.println("<TR><TD>EmpID</TD><TD>EmpName</TD></TR>");
			for(Employee tmp:remote.findAllEmployees())
			{
			   out.println("<TR><TD>"+tmp.getEmpno()+"</TD><TD>"+tmp.getEname()+"</TD></TR>");
			}
                        out.println("</TABLE>");
                        out.println("<BR><BR><a href="index.jsp"> Want to insert Some More Employee Records ?</a></body></html>");
		     } 
                 catch (Exception e) 
                     {
			e.printStackTrace();
		     }
	}
}

Step8). As we created a module “org.eclipse.persistence.jpa” earlier which we are going to use in our web application. So we will need to create a “jboss-deployment-structure.xml” file as following:

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
  <deployment>
    <dependencies>
      <module name="org.eclipse.persistence.jpa" />
    </dependencies>
  </deployment>
</jboss-deployment-structure>

NOTE: Once our application is build then we should be able to see this file present inside our WebApplication “WEB-INF/jboss-deployment-structure.xml”.

Step9). Now the most important part, here we are going to develop “build.xml” ANT file, which will build, deploy our web application on the JBoss AS7.1 Beta Server, so write the following “build.xml” file inside “/home/userone/JPA2_And_Toplink_On_AS7” directory.

<project name="JPA_BASIC_Demo" default="deploy">
<property name="jboss.home" value="/NotBackedUp/JBoss_All/jboss-as-7.1.1.Final" />
<property name="jboss.module.dir" value="${jboss.home}/modules" />
<property name="basedir" value="." />
<property name="tmp.dir" value="tmp" />
<property name="output.dir" value="build" />
<property name="src.dir" value="src" />
<property name="war.name" value="JPA_BASIC_Demo.war" />
 
   <path id="jboss.classpath">
     <fileset dir="${jboss.module.dir}">
        <include name="**/*.jar"/>
     </fileset>
   </path>
 
        <target name="init">
           <delete dir="${output.dir}" />
           <mkdir dir="${output.dir}" />
           <delete dir="${tmp.dir}" />
           <mkdir dir="${tmp.dir}" />
           <mkdir dir="${tmp.dir}/WEB-INF/classes/META-INF"/>
        </target>
 
        <target name="build" depends="init">
           <javac srcdir="${src.dir}" destdir="${tmp.dir}/WEB-INF/classes"  includes="*.java" classpathref="jboss.classpath" />
           <copy todir="${tmp.dir}/WEB-INF/classes">
                <fileset dir="${src.dir}" includes="**/*.java"/>
           </copy>
           <copy file="${src.dir}/index.jsp" tofile="${tmp.dir}/index.jsp"/>
           <copy file="${src.dir}/jboss-deployment-structure.xml" tofile="${tmp.dir}/WEB-INF/jboss-deployment-structure.xml"/>

           <!-- Make Sure that the persistence.xml file is placed inside "${war.name}/WEB-INF/classes/META-INF" directory -->
           <copy file="${src.dir}/persistence.xml" tofile="${tmp.dir}/WEB-INF/classes/META-INF/persistence.xml"/>

           <jar jarfile="${tmp.dir}/${war.name}" basedir="${tmp.dir}" compress="true" />
           <copy file="${tmp.dir}/${war.name}" tofile="${output.dir}/${war.name}"/>

           <delete includeEmptyDirs="true">
              <fileset dir="${tmp.dir}"/>
           </delete>
        </target>
 
        <target name="deploy" depends="build">
            <echo message="*******************  Deploying the WAR file ${war.name} *********************" />
            <echo message="********** ${output.dir}/${war.name} to ${jboss.home}/standalone/deployments **********" />
            <copy todir="${jboss.home}/standalone/deployments/">
                <fileset dir="${output.dir}/">
                  <include name="${war.name}"/>
                </fileset>
            </copy>
            <echo message="*******************  Deployed Successfully   *********************" />
        </target>
</project>

NOTE: The only change in the above file you need to do is to change the “jboss.home” directory path in the second line of the above script to point to your own JBoss AS7 directory.

Step9). Now before running your ANT script to build and deploy the above webapplication you should have the ANT as well as JAVA set in the $PATH variable of the Shell / command prompt as following:

For Unix Based OS:
export PATH=/home/userone/jdk1.6.0_21/bin:/home/userone/org.apache.ant_1.6.5/bin:$PATH

For Windows Based OS:
set PATH=C:/jdk1.6.0_21/bin;C:/org.apache.ant_1.6.5/bin;%PATH%

Step10). Now once the PATH is set In the command/Shell prompt you can move inside the directory “/home/userone/JPA2_And_Toplink_On_AS7” and then run the ant to build the webservice. by running the command “ant deploy”

Buildfile: build.xml

init:
   [delete] Deleting directory /home/userone/JPA2_And_Toplink_On_AS7/build
    [mkdir] Created dir: /home/userone/JPA2_And_Toplink_On_AS7/build
    [mkdir] Created dir: /home/userone/JPA2_And_Toplink_On_AS7/tmp
    [mkdir] Created dir: /home/userone/JPA2_And_Toplink_On_AS7/tmp/WEB-INF/classes/META-INF

build:
    [javac] Compiling 4 source files to /home/userone/JPA2_And_Toplink_On_AS7/tmp/WEB-INF/classes
     [copy] Copying 4 files to /home/userone/JPA2_And_Toplink_On_AS7/tmp/WEB-INF/classes
     [copy] Copying 1 file to /home/userone/JPA2_And_Toplink_On_AS7/tmp
     [copy] Copying 1 file to /home/userone/JPA2_And_Toplink_On_AS7/tmp/WEB-INF
     [copy] Copying 1 file to /home/userone/JPA2_And_Toplink_On_AS7/tmp/WEB-INF/classes/META-INF
      [jar] Building jar: /home/userone/JPA2_And_Toplink_On_AS7/tmp/JPA_BASIC_Demo.war
     [copy] Copying 1 file to /home/userone/JPA2_And_Toplink_On_AS7/build

deploy:
     [echo] *******************  Deploying the WAR file JPA_BASIC_Demo.war *********************
     [echo] ********** build/JPA_BASIC_Demo.war to /home/userone/jboss-as-7.1.1.Final/standalone/deployments **********
     [copy] Copying 1 file to /home/userone/jboss-as-7.1.1.Final/standalone/deployments
     [echo] *******************  Deployed Successfully   *********************

BUILD SUCCESSFUL
Total time: 2 seconds

Step11). Now you will see the following kind of output on your JBoss AS7.1 console which means the application is deployed successfully:

17:50:06,477 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-5) JBAS015876: Starting deployment of "JPA_BASIC_Demo.war"
17:50:06,513 INFO  [org.jboss.as.jpa] (MSC service thread 1-7) JBAS011401: Read persistence.xml for EmployeeService
17:50:06,548 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-7) JNDI bindings for session bean named EmployeeService in deployment unit deployment "JPA_BASIC_Demo.war" are as follows:

	java:global/JPA_BASIC_Demo/EmployeeService!jpa.EmployeeServiceRemote
	java:app/JPA_BASIC_Demo/EmployeeService!jpa.EmployeeServiceRemote
	java:module/EmployeeService!jpa.EmployeeServiceRemote
	java:jboss/exported/JPA_BASIC_Demo/EmployeeService!jpa.EmployeeServiceRemote
	java:global/JPA_BASIC_Demo/EmployeeService
	java:app/JPA_BASIC_Demo/EmployeeService
	java:module/EmployeeService

17:50:06,608 INFO  [org.jboss.as.jpa] (MSC service thread 1-6) JBAS011402: Starting Persistence Unit Service 'JPA_BASIC_Demo.war#EmployeeService'
17:50:06,633 INFO  [org.jboss.web] (MSC service thread 1-2) JBAS018210: Registering web context: /JPA_BASIC_Demo
17:50:06,744 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 1) JBAS018565: Replaced deployment "JPA_BASIC_Demo.war" with deployment "JPA_BASIC_Demo.war"

Step12). Now access the WebApplication like following and then fill the form :
http://localhost:8080/JPA_BASIC_Demo/index.jsp

Once you hit the above URL you will see thew following kind of output in oyur JBossAS7 console:

17:52:52,442 INFO  [stdout] (http--127.0.0.1-8080-1) inside TestServlet service()
17:52:52,443 INFO  [stdout] (http--127.0.0.1-8080-1) GOT the UserTransaction       :  org.jboss.tm.usertx.client.ServerVMClientUserTransaction@566f0962
17:52:52,443 INFO  [stdout] (http--127.0.0.1-8080-1) Got jpa.EmployeeServiceRemote :  Proxy for remote EJB StatelessEJBLocator{appName='', moduleName='JPA_BASIC_Demo', distinctName='', beanName='EmployeeService', view='interface jpa.EmployeeServiceRemote'}
17:52:52,459 INFO  [stdout] (http--127.0.0.1-8080-1) 
17:52:52,459 INFO  [stdout] (http--127.0.0.1-8080-1) 	EmployeeService  Object Created. this: jpa.EmployeeService@498eba23
17:52:52,460 INFO  [stdout] (http--127.0.0.1-8080-1) Employee Object Created. this: jpa.Employee@395e758f
17:52:52,460 INFO  [stdout] (http--127.0.0.1-8080-1) 
17:52:52,461 INFO  [stdout] (http--127.0.0.1-8080-1) 	[EmployeeService] Before em.persist(emp)
17:52:52,481 INFO  [stdout] (http--127.0.0.1-8080-1) [EL Info]: 2012-06-10 17:52:52.481--ServerSession(631563432)--EclipseLink, version: Eclipse Persistence Services - 2.3.2.v20111125-r10461
17:52:52,509 INFO  [stdout] (http--127.0.0.1-8080-1) Employee Object Created. this: jpa.Employee@4a44db2a
17:52:52,510 INFO  [stdout] (http--127.0.0.1-8080-1) [EL Info]: 2012-06-10 17:52:52.51--ServerSession(631563432)--vfs:/content/JPA_BASIC_Demo.war/WEB-INF/classes/_EmployeeService login successful
17:52:52,515 INFO  [stdout] (http--127.0.0.1-8080-1) Employee Object Created. this: jpa.Employee@4542ca0
17:52:52,686 INFO  [stdout] (http--127.0.0.1-8080-1) Employee Object Created. this: jpa.Employee@43458a40
17:52:52,687 INFO  [stdout] (http--127.0.0.1-8080-1) Employee Object Created. this: jpa.Employee@3022eec5
17:52:52,687 INFO  [stdout] (http--127.0.0.1-8080-1) Employee Object Created. this: jpa.Employee@4569e033
17:52:52,687 INFO  [stdout] (http--127.0.0.1-8080-1) 
17:52:52,687 INFO  [stdout] (http--127.0.0.1-8080-1) 	[EmployeeService] Before findEmployee(id)
17:52:52,688 INFO  [stdout] (http--127.0.0.1-8080-1) 
17:52:52,688 INFO  [stdout] (http--127.0.0.1-8080-1) 	 Inside findEmployee(2223)
17:52:52,688 INFO  [stdout] (http--127.0.0.1-8080-1) 
17:52:52,689 INFO  [stdout] (http--127.0.0.1-8080-1) 	[EmployeeService] Inside createEmployee() findEmployee result: jpa.Employee@395e758f
17:52:52,690 INFO  [stdout] (http--127.0.0.1-8080-1) Employee Object Created. this: jpa.Employee@1ee69bc3
17:52:52,691 INFO  [stdout] (http--127.0.0.1-8080-1) 
17:52:52,691 INFO  [stdout] (http--127.0.0.1-8080-1) 	 Inside findAllEmployees()
17:52:52,694 INFO  [stdout] (http--127.0.0.1-8080-1) Employee Object Created. this: jpa.Employee@1b3cbd53
17:52:52,694 INFO  [stdout] (http--127.0.0.1-8080-1) Employee Object Created. this: jpa.Employee@30b1a21d
17:52:52,695 INFO  [stdout] (http--127.0.0.1-8080-1) Employee Object Created. this: jpa.Employee@5e0a36e4
17:52:52,696 INFO  [stdout] (http--127.0.0.1-8080-1) Employee Object Created. this: jpa.Employee@7099e2f7
17:52:52,696 INFO  [stdout] (http--127.0.0.1-8080-1) Employee Object Created. this: jpa.Employee@703ffe2
17:52:52,697 INFO  [stdout] (http--127.0.0.1-8080-1) Employee Object Created. this: jpa.Employee@71f1584a
17:52:52,697 INFO  [stdout] (http--127.0.0.1-8080-1) Employee Object Created. this: jpa.Employee@1bdb9cb7
.

=======================================================================

Some Issues You Might Face

=======================================================================

Issue-1

If you dont declare the property name=”jboss.as.jpa.providerModule” value=”org.eclipse.persistence.jpa” in your “persistence.xml” file then you might see following exception while deploying your Toplink JPA:

17:55:32,081 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015876: Starting deployment of "JPA_BASIC_Demo.war"
17:55:32,081 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 1) JBAS015863: Replacement of deployment "JPA_BASIC_Demo.war" by deployment "JPA_BASIC_Demo.war" was rolled back with failure message {"JBAS014671: Failed services" => {"jboss.module.service."deployment.JPA_BASIC_Demo.war".main" => "org.jboss.msc.service.StartException in service jboss.module.service."deployment.JPA_BASIC_Demo.war".main: Failed to load module: deployment.JPA_BASIC_Demo.war:main"}}
17:55:32,095 INFO  [org.jboss.as.jpa] (MSC service thread 1-8) JBAS011401: Read persistence.xml for EmployeeService
17:55:32,101 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-8) MSC00001: Failed to start service jboss.module.service."deployment.JPA_BASIC_Demo.war".main: org.jboss.msc.service.StartException in service jboss.module.service."deployment.JPA_BASIC_Demo.war".main: Failed to load module: deployment.JPA_BASIC_Demo.war:main
	at org.jboss.as.server.moduleservice.ModuleLoadService.start(ModuleLoadService.java:91) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
	at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
	at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.6.0_24]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.6.0_24]
	at java.lang.Thread.run(Thread.java:679) [rt.jar:1.6.0_24]
Caused by: org.jboss.modules.ModuleNotFoundException: Module org.eclipse.persistence:main is not found in local module loader @6da28362 (roots: /NotBackedUp/JBoss_All/jboss-as-7.1.1.Final/modules)
	at org.jboss.modules.LocalModuleLoader.findModule(LocalModuleLoader.java:126) [jboss-modules.jar:1.1.1.GA]
	at org.jboss.modules.ModuleLoader.loadModuleLocal(ModuleLoader.java:275) [jboss-modules.jar:1.1.1.GA]
	at org.jboss.modules.ModuleLoader.preloadModule(ModuleLoader.java:222) [jboss-modules.jar:1.1.1.GA]
	at org.jboss.modules.LocalModuleLoader.preloadModule(LocalModuleLoader.java:94) [jboss-modules.jar:1.1.1.GA]
	at org.jboss.modules.Module.addPaths(Module.java:841) [jboss-modules.jar:1.1.1.GA]
	at org.jboss.modules.Module.link(Module.java:1181) [jboss-modules.jar:1.1.1.GA]
	at org.jboss.modules.Module.relinkIfNecessary(Module.java:1207) [jboss-modules.jar:1.1.1.GA]
	at org.jboss.modules.ModuleLoader.loadModule(ModuleLoader.java:208) [jboss-modules.jar:1.1.1.GA]
	at org.jboss.as.server.moduleservice.ModuleLoadService.start(ModuleLoadService.java:70) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
	... 5 more

Issue-2

If you wont start a transaction like following inside your code before persisting an entity in your Database then you will see the following kind of exception in your logs (EmployeeService.java snippet):

    try{ 
         em.getTransaction().begin();
         em.persist(emp);
         em.flush();
         em.getTransaction().commit();
       } 
    catch(Exception e)
       {
          e.printStackTrace();
          try{   em.getTransaction().rollback();   } catch(Exception ee)  {  ee.printStackTrace();  }
       }

Following exceptions you will encounter …

17:57:56,475 ERROR [stderr] (http--127.0.0.1-8080-1) javax.persistence.TransactionRequiredException: 
17:57:56,476 ERROR [stderr] (http--127.0.0.1-8080-1) Exception Description: No transaction is currently active
17:57:56,476 ERROR [stderr] (http--127.0.0.1-8080-1) 	at  org.eclipse.persistence.internal.jpa.transaction.EntityTransactionWrapper.throwCheckTransactionFailedException(EntityTransactionWrapper.java:113)
17:57:56,476 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionWrapper.checkForTransaction(EntityTransactionWrapper.java:50)
17:57:56,477 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.eclipse.persistence.internal.jpa.EntityManagerImpl.checkForTransaction(EntityManagerImpl.java:1776)
17:57:56,477 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.eclipse.persistence.internal.jpa.EntityManagerImpl.flush(EntityManagerImpl.java:780)
17:57:56,477 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.jboss.as.jpa.container.AbstractEntityManager.flush(AbstractEntityManager.java:439)
17:57:56,477 ERROR [stderr] (http--127.0.0.1-8080-1) 	at jpa.EmployeeService.createEmployee(Unknown Source)
.
.
17:57:56,493 ERROR [stderr] (http--127.0.0.1-8080-1) java.lang.IllegalStateException: 
17:57:56,494 ERROR [stderr] (http--127.0.0.1-8080-1) Exception Description: No transaction is currently active
17:57:56,494 ERROR [stderr] (http--127.0.0.1-8080-1) 	at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.rollback(EntityTransactionImpl.java:122)

<property name=”eclipselink.ddl-generation” value=”create-tables” />
.
.
Thanks
Middleware Magic Team πŸ™‚


Copyright Β© 2010-2012 Middleware Magic. All rights reserved. |