Saturday, May 11, 2013

Weblogic 12.1.1 and WELD-001408 Unsatisfied dependencies for type error test

Weblogic 12.1.1  is strictly checking all injections at deployment time

Utility project  jar used by Weld must also have beans.xml file 

http://docs.jboss.org/weld/reference/1.1.0.Final/en-US/html_single/#d0e4697


Following error is thrown for failed injection validation WELD-001408 Unsatisfied dependencies for type



<May 11, 2013 7:34:08 PM CEST> <Warning> <Deployer> <BEA-149004> <Failures were detected while initiating deploy task for application "weld-ear-1.0-SNAPSHOT".> 
<May 11, 2013 7:34:08 PM CEST> <Warning> <Deployer> <BEA-149078> <Stack trace for message 149004
weblogic.management.DeploymentException: 
    at weblogic.application.internal.BaseDeployment.throwAppException(BaseDeployment.java:123)
    at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:239)
    at weblogic.application.internal.EarDeployment.prepare(EarDeployment.java:61)
    at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:158)
    at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:60)
    Truncated. see log file for complete stacktrace
Caused By: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [String] with qualifiers [@Default] at injection point [[field] @Inject private dave.TestServlet.injectedValue]
    at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:258)
    at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:105)
    at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:125)
    at org.jboss.weld.bootstrap.Validator.validateBeans(Validator.java:324)
    at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:309)
    Truncated. see log file for complete stacktrace
> 

Creating Shared Java EE Libraries and Optional Packages http://docs.oracle.com/cd/E24329_01/web.1211/e24368/libraries.htm#autoId2


https://cn.forums.oracle.com/forums/thread.jspa?threadID=2485198&start=0&tstart=1

https://forums.oracle.com/forums/thread.jspa?threadID=2506170&tstart=0

http://stackoverflow.com/questions/5060314/inject-a-stateless-ejb-with-inject-into-cdi-weld-managedbean-jsf-1-2-ejb-appli

Three projects are created:
-  Web  project using Weld injection from utility jar
- utility jar project with class for injection
- ear projected packaging war and utility jar

Create Java EE project with Maven
http://www.adam-bien.com/roller/abien/entry/creating_java_ee_6_projects

Maven Weblogic plugin
http://docs.oracle.com/cd/E21764_01/web.1111/e13702/maven_deployer.htm

ear project


[dave@dave weld-ear]$ ls -lR
.:
total 12
-rw-rw-r--. 1 dave dave 1837 May 11 18:48 pom.xml
drwxrwxr-x. 3 dave dave 4096 May 11 13:41 src
drwxrwxr-x. 4 dave dave 4096 May 11 19:35 target

./src:
total 4
drwxrwxr-x. 3 dave dave 4096 May 11 13:41 main

./src/main:
total 4
drwxrwxr-x. 3 dave dave 4096 May 11 13:41 application

./src/main/application:
total 4
drwxrwxr-x. 2 dave dave 4096 May 11 13:41 META-INF

./src/main/application/META-INF:
total 4
-rw-rw-r--. 1 dave dave 23 May 11 13:41 MANIFEST.MF

./target:
total 20
-rw-rw-r--. 1 dave dave  494 May 11 19:35 application.xml
drwxrwxr-x. 2 dave dave 4096 May 11 19:35 maven-archiver
drwxrwxr-x. 4 dave dave 4096 May 11 19:35 weld-ear-1.0-SNAPSHOT
-rw-rw-r--. 1 dave dave 6359 May 11 19:35 weld-ear-1.0-SNAPSHOT.ear

./target/maven-archiver:
total 4
-rw-rw-r--. 1 dave dave 109 May 11 19:35 pom.properties

./target/weld-ear-1.0-SNAPSHOT:
total 12
drwxrwxr-x. 2 dave dave 4096 May 11 19:35 lib
drwxrwxr-x. 2 dave dave 4096 May 11 19:35 META-INF
-rw-rw-r--. 1 dave dave 3640 May 11 19:35 weld-web.war

./target/weld-ear-1.0-SNAPSHOT/lib:
total 4
-rw-rw-r--. 1 dave dave 2294 May 11 19:35 testUtility-1.0-SNAPSHOT.jar

./target/weld-ear-1.0-SNAPSHOT/META-INF:
total 8
-rw-rw-r--. 1 dave dave 494 May 11 19:35 application.xml
-rw-rw-r--. 1 dave dave  23 May 11 19:35 MANIFEST.MF
[dave@dave weld-ear]$ 



web project

[dave@dave weld-web]$ ls -lR
.:
total 12
-rw-rw-r--. 1 dave dave 2899 May 11 19:48 pom.xml
drwxrwxr-x. 3 dave dave 4096 May 11 13:42 src
drwxrwxr-x. 8 dave dave 4096 May 11 19:20 target

./src:
total 4
drwxrwxr-x. 4 dave dave 4096 May 11 13:42 main

./src/main:
total 8
drwxrwxr-x. 3 dave dave 4096 May 11 13:42 java
drwxrwxr-x. 3 dave dave 4096 May 11 19:16 webapp

./src/main/java:
total 4
drwxrwxr-x. 2 dave dave 4096 May 11 18:26 dave

./src/main/java/dave:
total 4
-rw-rw-r--. 1 dave dave 1285 May  9 22:56 TestServlet.java

./src/main/webapp:
total 8
-rw-rw-r--. 1 dave dave  361 May 11 13:42 index.jsp
drwxrwxr-x. 2 dave dave 4096 May 11 19:17 WEB-INF

./src/main/webapp/WEB-INF:
total 4
-rw-rw-r--. 1 dave dave 269 May  9 23:06 beans.xml

./target:
total 28
drwxrwxr-x. 3 dave dave 4096 May 11 19:20 classes
drwxrwxr-x. 2 dave dave 4096 May 11 19:20 endorsed
drwxrwxr-x. 3 dave dave 4096 May 11 19:20 generated-sources
drwxrwxr-x. 2 dave dave 4096 May 11 19:20 maven-archiver
drwxrwxr-x. 2 dave dave 4096 May 11 19:20 surefire
drwxrwxr-x. 4 dave dave 4096 May 11 19:20 weld-web-1.0-SNAPSHOT
-rw-rw-r--. 1 dave dave 3640 May 11 19:20 weld-web-1.0-SNAPSHOT.war

./target/classes:
total 4
drwxrwxr-x. 2 dave dave 4096 May 11 19:20 dave

./target/classes/dave:
total 4
-rw-rw-r--. 1 dave dave 1443 May 11 19:20 TestServlet.class

./target/endorsed:
total 108
-rw-rw-r--. 1 dave dave 108093 May 11 19:20 javaee-endorsed-api-6.0.jar

./target/generated-sources:
total 4
drwxrwxr-x. 2 dave dave 4096 May 11 19:20 annotations

./target/generated-sources/annotations:
total 0

./target/maven-archiver:
total 4
-rw-rw-r--. 1 dave dave 109 May 11 19:20 pom.properties

./target/surefire:
total 0

./target/weld-web-1.0-SNAPSHOT:
total 12
-rw-rw-r--. 1 dave dave  361 May 11 13:42 index.jsp
drwxrwxr-x. 2 dave dave 4096 May 11 19:20 META-INF
drwxrwxr-x. 3 dave dave 4096 May 11 19:20 WEB-INF

./target/weld-web-1.0-SNAPSHOT/META-INF:
total 0

./target/weld-web-1.0-SNAPSHOT/WEB-INF:
total 8
-rw-rw-r--. 1 dave dave  269 May  9 23:06 beans.xml
drwxrwxr-x. 3 dave dave 4096 May 11 19:20 classes

./target/weld-web-1.0-SNAPSHOT/WEB-INF/classes:
total 4
drwxrwxr-x. 2 dave dave 4096 May 11 19:20 dave

./target/weld-web-1.0-SNAPSHOT/WEB-INF/classes/dave:
total 4
-rw-rw-r--. 1 dave dave 1443 May 11 19:20 TestServlet.class
[dave@dave weld-web]$ 


utility project

[dave@dave testUtility]$ ls -lR
.:
total 12
-rw-rw-r--. 1 dave dave  849 May 11 18:46 pom.xml
drwxrwxr-x. 4 dave dave 4096 May 11 18:43 src
drwxrwxr-x. 7 dave dave 4096 May 11 19:34 target

./src:
total 8
drwxrwxr-x. 4 dave dave 4096 May 11 19:18 main
drwxrwxr-x. 3 dave dave 4096 May 11 18:43 test

./src/main:
total 8
drwxrwxr-x. 3 dave dave 4096 May 11 18:43 java
drwxrwxr-x. 3 dave dave 4096 May 11 19:18 resources

./src/main/java:
total 4
drwxrwxr-x. 2 dave dave 4096 May 11 18:46 dave

./src/main/java/dave:
total 4
-rw-rw-r--. 1 dave dave 167 May 11 18:45 ValueProducer.java

./src/main/resources:
total 4
drwxrwxr-x. 2 dave dave 4096 May 11 19:18 META-INF

./src/main/resources/META-INF:
total 4
-rw-rw-r--. 1 dave dave 269 May 11 19:18 beans.xml

./src/test:
total 4
drwxrwxr-x. 3 dave dave 4096 May 11 18:43 java

./src/test/java:
total 4
drwxrwxr-x. 2 dave dave 4096 May 11 18:43 dave

./src/test/java/dave:
total 4
-rw-rw-r--. 1 dave dave 632 May 11 18:43 AppTest.java

./target:
total 24
drwxrwxr-x. 4 dave dave 4096 May 11 19:34 classes
drwxrwxr-x. 2 dave dave 4096 May 11 19:34 maven-archiver
drwxrwxr-x. 2 dave dave 4096 May 11 19:34 surefire
drwxrwxr-x. 2 dave dave 4096 May 11 19:34 surefire-reports
drwxrwxr-x. 3 dave dave 4096 May 11 19:34 test-classes
-rw-rw-r--. 1 dave dave 2294 May 11 19:34 testUtility-1.0-SNAPSHOT.jar

./target/classes:
total 8
drwxrwxr-x. 2 dave dave 4096 May 11 19:34 dave
drwxrwxr-x. 2 dave dave 4096 May 11 19:34 META-INF

./target/classes/dave:
total 4
-rw-rw-r--. 1 dave dave 468 May 11 19:34 ValueProducer.class

./target/classes/META-INF:
total 4
-rw-rw-r--. 1 dave dave 269 May 11 19:34 beans.xml

./target/maven-archiver:
total 4
-rw-rw-r--. 1 dave dave 115 May 11 19:34 pom.properties

./target/surefire:
total 0

./target/surefire-reports:
total 12
-rw-rw-r--. 1 dave dave  257 May 11 19:34 dave.AppTest.txt
-rw-rw-r--. 1 dave dave 4145 May 11 19:34 TEST-dave.AppTest.xml

./target/test-classes:
total 4
drwxrwxr-x. 2 dave dave 4096 May 11 19:34 dave

./target/test-classes/dave:
total 4
-rw-rw-r--. 1 dave dave 588 May 11 19:34 AppTest.class
[dave@dave testUtility]$ 



[dave@dave testUtility]$ more ./src/main/java/dave/ValueProducer.java
package dave;


import javax.enterprise.inject.Produces;
 
public class ValueProducer {
 
    @Produces
    public String stringValue() {
        return "someStringValue";
    }
 
}



[dave@dave weld-web]$ more ./src/main/java/dave/TestServlet.java
package dave;

import java.io.IOException;
import java.io.PrintWriter;

import javax.inject.Inject;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class TestServlet
 */
@WebServlet("/TestServlet")
public class TestServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public TestServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

    @Inject
    private String injectedValue;
 
    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
 
        PrintWriter pw = response.getWriter();
        pw.write("injectedValue: " + injectedValue);
        pw.flush();
 
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws Servlet
Exception, IOException {
        // TODO Auto-generated method stub
    }

}



[dave@dave weld-web]$ more pom.xml 
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instanc
e"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0
.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>weld-web</groupId>
    <artifactId>weld-web</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>

    <name>weld-web</name>

    <properties>
        <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-web-api</artifactId>
            <version>6.0</version>
            <scope>provided</scope>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                    <compilerArguments>
                        <endorseddirs>${endorsed.dir}</endorseddirs>
                    </compilerArguments>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.1.1</version>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.1</version>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${endorsed.dir}</outputDirectory>
                            <silent>true</silent>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>javax</groupId>
                                    <artifactId>javaee-endorsed-api</artifactId>
                                    <version>6.0</version>
                                    <type>jar</type>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>
[dave@dave weld-web]$           



[dave@dave weld-ear]$ more pom.xml 
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instanc
e"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>weld-ear</groupId>
  <artifactId>weld-ear</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>ear</packaging>

  <name>weld-ear</name>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

<dependencies>
<dependency>
       <groupId>weld-web</groupId>
    <artifactId>weld-web</artifactId>
    <version>1.0-SNAPSHOT</version>
    <type>war</type>
</dependency>
<dependency>
       <groupId>testUtility</groupId>
    <artifactId>testUtility</artifactId>
    <version>1.0-SNAPSHOT</version>
    <type>jar</type>
</dependency>
</dependencies>
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.3.2</version>
        <configuration>
          <source>1.6</source>
          <target>1.6</target>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-ear-plugin</artifactId>
        <version>2.6</version>
        <configuration>
            <version>6</version>
            <defaultLibBundleDir>lib</defaultLibBundleDir>
             <modules>
            <webModule>
                <groupId>weld-web</groupId>
                <artifactId>weld-web</artifactId>
                <uri>weld-web.war</uri>
                <bundleFileName>weld-web.war</bundleFileName>
                <contextRoot>/weld-web</contextRoot>
            </webModule>
        </modules>
        </configuration>
      </plugin>
    </plugins>
  </build>

</project>

building ear with Maven

[dave@dave weld-ear]$ mvn clean install
/usr/java//jdk1.7.0_21
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building weld-ear 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ weld-ear ---
[INFO] Deleting /home/dave/workspace/weld-ear/target
[INFO] 
[INFO] --- maven-ear-plugin:2.6:generate-application-xml (default-generate-application-xml) @ weld-ear ---
[INFO] Generating application.xml
[INFO] 
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ weld-ear ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/dave/workspace/weld-ear/src/main/resources
[INFO] 
[INFO] --- maven-ear-plugin:2.6:ear (default-ear) @ weld-ear ---
[INFO] Copying artifact[war:weld-web:weld-web:1.0-SNAPSHOT] to[weld-web.war]
[INFO] Copying artifact[jar:testUtility:testUtility:1.0-SNAPSHOT] to[lib/testUtility-1.0-SNAPSHOT.jar]
[INFO] Copy ear sources to /home/dave/workspace/weld-ear/target/weld-ear-1.0-SNAPSHOT
[INFO] Including custom manifest file[/home/dave/workspace/weld-ear/target/weld-ear-1.0-SNAPSHOT/META-INF/MANIFEST.MF]
[INFO] Building jar: /home/dave/workspace/weld-ear/target/weld-ear-1.0-SNAPSHOT.ear
[INFO] 
[INFO] --- maven-install-plugin:2.3.1:install (default-install) @ weld-ear ---
[INFO] Installing /home/dave/workspace/weld-ear/target/weld-ear-1.0-SNAPSHOT.ear to /home/dave/.m2/repository/weld-ear/weld-ear/1.0-SNAPSHOT/weld-ear-1.0-SNAPSHOT.ear
[INFO] Installing /home/dave/workspace/weld-ear/pom.xml to /home/dave/.m2/repository/weld-ear/weld-ear/1.0-SNAPSHOT/weld-ear-1.0-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.520s
[INFO] Finished at: Sat May 11 20:15:00 CEST 2013
[INFO] Final Memory: 4M/15M
[INFO] ------------------------------------------------------------------------
[dave@dave weld-ear]$ 

generated application.xml file

[dave@dave weld-ear]$ more ./target/application.xml
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-ins
tance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/applica
tion_6.xsd" version="6">
  <display-name>weld-ear</display-name>
  <module>
    <web>
      <web-uri>weld-web.war</web-uri>
      <context-root>/weld-web</context-root>
    </web>
  </module>
  <library-directory>lib</library-directory>
</application>


ear content
[dave@dave weld-ear]$ jar tvf target/weld-ear-1.0-SNAPSHOT.ear 
     0 Sat May 11 20:15:02 CEST 2013 META-INF/
   123 Sat May 11 20:15:00 CEST 2013 META-INF/MANIFEST.MF
     0 Sat May 11 20:15:00 CEST 2013 lib/
   494 Sat May 11 20:15:00 CEST 2013 META-INF/application.xml
  2294 Sat May 11 20:15:00 CEST 2013 lib/testUtility-1.0-SNAPSHOT.jar
  3640 Sat May 11 20:15:00 CEST 2013 weld-web.war
     0 Sat May 11 20:15:02 CEST 2013 META-INF/maven/
     0 Sat May 11 20:15:02 CEST 2013 META-INF/maven/weld-ear/
     0 Sat May 11 20:15:02 CEST 2013 META-INF/maven/weld-ear/weld-ear/
  1837 Sat May 11 18:48:28 CEST 2013 META-INF/maven/weld-ear/weld-ear/pom.xml
   109 Sat May 11 20:15:00 CEST 2013 META-INF/maven/weld-ear/weld-ear/pom.properties


war content
[dave@dave weld-web]$ jar tvf target/weld-web-1.0-SNAPSHOT.war 
     0 Sat May 11 19:20:28 CEST 2013 META-INF/
   123 Sat May 11 19:20:26 CEST 2013 META-INF/MANIFEST.MF
     0 Sat May 11 19:20:28 CEST 2013 WEB-INF/
     0 Sat May 11 19:20:28 CEST 2013 WEB-INF/classes/
     0 Sat May 11 19:20:28 CEST 2013 WEB-INF/classes/dave/
   361 Sat May 11 13:43:00 CEST 2013 index.jsp
   269 Thu May 09 23:06:38 CEST 2013 WEB-INF/beans.xml
  1443 Sat May 11 19:20:24 CEST 2013 WEB-INF/classes/dave/TestServlet.class
     0 Sat May 11 19:20:28 CEST 2013 META-INF/maven/
     0 Sat May 11 19:20:28 CEST 2013 META-INF/maven/weld-web/
     0 Sat May 11 19:20:28 CEST 2013 META-INF/maven/weld-web/weld-web/
  3073 Sat May 11 19:19:30 CEST 2013 META-INF/maven/weld-web/weld-web/pom.xml
   109 Sat May 11 19:20:28 CEST 2013 META-INF/maven/weld-web/weld-web/pom.properties

utility jar content
[dave@dave testUtility]$ jar tvf target/testUtility-1.0-SNAPSHOT.jar 
     0 Sat May 11 19:34:58 CEST 2013 META-INF/
   123 Sat May 11 19:34:56 CEST 2013 META-INF/MANIFEST.MF
     0 Sat May 11 19:34:52 CEST 2013 dave/
   269 Sat May 11 19:34:50 CEST 2013 META-INF/beans.xml
   468 Sat May 11 19:34:52 CEST 2013 dave/ValueProducer.class
     0 Sat May 11 19:34:58 CEST 2013 META-INF/maven/
     0 Sat May 11 19:34:58 CEST 2013 META-INF/maven/testUtility/
     0 Sat May 11 19:34:58 CEST 2013 META-INF/maven/testUtility/testUtility/
   849 Sat May 11 18:46:42 CEST 2013 META-INF/maven/testUtility/testUtility/pom.xml
   115 Sat May 11 19:34:56 CEST 2013 META-INF/maven/testUtility/testUtility/pom.properties


deploy  project

 mvn com.oracle.weblogic:weblogic-maven-plugin:^Cploy -Dadminurl=t3://localhost:7001 -Duser=weblogic -Dpassword=weblogic123 -Dtargets=AdminServer -Dsource=target/weld-ear-1.0-SNAPSHOT.ear -Dname=weld-ear


[dave@dave weld-ear]$ mvn com.oracle.weblogic:weblogic-maven-plugin:deploy -Dadminurl=t3://localhost:7001 -Duser=weblogic -Dpassword=weblogic123 -Dtargets=AdminServer -Dsource=target/weld-ear-1.0-SNAPSHOT.ear -Dname=weld-ear
/usr/java//jdk1.7.0_21
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building weld-ear 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- weblogic-maven-plugin:12.1.1.0:deploy (default-cli) @ weld-ear ---
weblogic.Deployer invoked with options:  -noexit -adminurl t3://localhost:7001 -user weblogic -deploy -name weld-ear -source target/weld-ear-1.0-SNAPSHOT.ear -targets AdminServer
<May 11, 2013 7:36:28 PM CEST> <Info> <J2EE Deployment SPI> <BEA-260121> <Initiating deploy operation for application, weld-ear [archive: /home/dave/workspace/weld-ear/target/weld-ear-1.0-SNAPSHOT.ear], to AdminServer .> 
Task 10 initiated: [Deployer:149026]deploy application weld-ear on AdminServer.
Task 10 completed: [Deployer:149026]deploy application weld-ear on AdminServer.
Target state: deploy completed on Server AdminServer

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.317s
[INFO] Finished at: Sat May 11 19:36:30 CEST 2013
[INFO] Final Memory: 5M/15M
[INFO] ------------------------------------------------------------------------


Test application at  http://localhost:7001/weld-web/TestServlet










Thursday, April 4, 2013

Weblogic 12.1.1 Java EE 6 CDI Weld requires patches

CDI  Weld patches are required on Java EE 6 Weblogic 12.1.1

 Caused By: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type
https://forums.oracle.com/forums/thread.jspa?messageID=10760194

http://biemond.blogspot.cz/2012/01/jsf-20-managed-bean-annotations-and-cdi.html

https://forums.oracle.com/forums/thread.jspa?threadID=2391298

Check installed patches with bsu utility
http://docs.oracle.com/cd/E14759_01/doc.32/e14143/commands.htm#i1071660

Patches delivered with installation from otn
-report
    

Generates a report showing the applied patches and associated file changes in a Middleware home directory.


[dave@dave weblogic]$ cd utils/bsu/
[dave@dave bsu]$ ./bsu.sh -report
Patch Report
============
  Report Info
    Report Options
      bea_home.................. ### OPTION NOT SET
      product_mask.............. ### OPTION NOT SET
      release_mask.............. ### OPTION NOT SET
      profile_mask.............. ### OPTION NOT SET
      patch_id_mask............. ### OPTION NOT SET
    Report Messages
  BEA Home.................. /opt/weblogic
  
  Product Description
  Product Name.............. WebLogic Server
  Product Version........... 12.1.1.0
  Installed Components...... Core Application Server, Administration Console, Configuration Wizard and Upgrade Framework, Web 2.0 HTTP Pub-Sub Server, WebLogic SCA, WebLogic JDBC Drivers, Third Party JDBC Drivers, WebLogic Server Clients, Xquery Support, Evaluation Database, Workshop Code Completion Support
  Product Install Directory. /opt/weblogic/wlserver_12.1
  Java Home................. /opt/weblogic/jdk160_29
  Jave Vendor............... Sun
  Java Version.............. 1.6.0_29
  Patch Directory........... /opt/weblogic/patch_wls1211
    
    Profile................... Default
      
      Patch ID.................. 97L5
      CR(s)..................... 
      Description............... SERVLET 3.0 FILE UPLOAD BREAKS OTHER FILE UPLOAD FRAMEWORKS
SERVLET 3.0 FILE UPLOAD BREAKS OTHER FILE UPLOAD FRAMEWORKS
      Classpath
        Classpath type............ SYSTEM
        Classpath control jar..... weblogic_patch.jar
          Jar....................... BUG13657792_1211.jar
            File...................... META-INF/MANIFEST.MF
            File...................... weblogic/servlet/internal/ServletRegistrationImpl.class
            File...................... weblogic/servlet/internal/ServletRequestImpl$1.class
            File...................... weblogic/servlet/internal/ServletRequestImpl$AuthenticateResponseWrapper.class
            File...................... weblogic/servlet/internal/ServletRequestImpl$CookieKey.class
            File...................... weblogic/servlet/internal/ServletRequestImpl$ExtraIncludeParams.class
            File...................... weblogic/servlet/internal/ServletRequestImpl$ExtraParams.class
            File...................... weblogic/servlet/internal/ServletRequestImpl$RequestInputHelper.class
            File...................... weblogic/servlet/internal/ServletRequestImpl$RequestParameters.class
            File...................... weblogic/servlet/internal/ServletRequestImpl$SessionHelper.class
            File...................... weblogic/servlet/internal/ServletRequestImpl.class
            File...................... weblogic/servlet/internal/ServletStubFactory.class
            File...................... weblogic/servlet/internal/ServletStubImpl$1.class
            File...................... weblogic/servlet/internal/ServletStubImpl.class
      
      Patch ID.................. NST7
      CR(s)..................... 
      Description............... UNCAUGHT EXCEPTION IN SERVER HANDLERJAVAX.NET.SSL.SSLEXCEPTION: ERROR GENERATING
UNCAUGHT EXCEPTION IN SERVER HANDLERJAVAX.NET.SSL.SSLEXCEPTION: ERROR GENERATING
      Classpath
        Classpath type............ SYSTEM
        Classpath control jar..... weblogic_patch.jar
          Jar....................... BUG13421471_1211.jar
            File...................... META-INF/MANIFEST.MF
            File...................... weblogic/security/utils/KeyStoreInstall.class
      
      Patch ID.................. 4331
      CR(s)..................... 
      Description............... WEB SERVICE THAT IMPLEMENTS PROVIDER INTERFACE CANNOT BE GENERATED A
WEB SERVICE THAT IMPLEMENTS PROVIDER INTERFACE CANNOT BE GENERATED A
      Classpath
        Classpath type............ SYSTEM
        Classpath control jar..... weblogic_patch.jar
          Jar....................... BUG13361720_1211.jar
            File...................... META-INF/MANIFEST.MF
            File...................... weblogic/wsee/tools/jws/build/JwsCompiler.class
      
      Patch ID.................. RCMZ
      CR(s)..................... 
      Description............... UNDEPLOYING A SUBMODULE JMS FAILS
UNDEPLOYING A SUBMODULE JMS FAILS
      Classpath
        Classpath type............ SYSTEM
        Classpath control jar..... weblogic_patch.jar
          Jar....................... BUG13424251_1211.jar
            File...................... META-INF/MANIFEST.MF
            File...................... weblogic/cluster/migration/MigrationManager$1.class
            File...................... weblogic/cluster/migration/MigrationManager.class
      
      Patch ID.................. 53JP
      CR(s)..................... 
      Description............... MERGE LABEL REQUEST ON TOP OF 12.1.1 FOR CDI BUGS
MERGE LABEL REQUEST ON TOP OF 12.1.1 FOR CDI BUGS
      Classpath
        Classpath type............ SYSTEM
        Classpath control jar..... weblogic_patch.jar
          Jar....................... BUG13603813_1211.jar
            File...................... META-INF/MANIFEST.MF
            File...................... com/oracle/injection/integration/CDIAppDeploymentExtension$1.class
            File...................... com/oracle/injection/integration/CDIAppDeploymentExtension.class
            File...................... com/oracle/injection/integration/CDIModuleExtension$RarModuleInjectionArchive.class
            File...................... com/oracle/injection/integration/CDIModuleExtension$WebInfLibInjectionArchive.class
            File...................... com/oracle/injection/integration/CDIModuleExtension.class
            File...................... com/oracle/injection/integration/CDIUtils.class
            File...................... com/oracle/injection/provider/weld/BasicDeployment$1.class
            File...................... com/oracle/injection/provider/weld/BasicDeployment$NullJpaInjectionServicesAdapter.class
            File...................... com/oracle/injection/provider/weld/BasicDeployment$RootBeanDeploymentArchive.class
            File...................... com/oracle/injection/provider/weld/BasicDeployment.class
            File...................... com/oracle/injection/provider/weld/WeldValidationServicesAdapter.class
            File...................... weblogic/application/internal/flow/TailVersionLifecycleFlow.class
            File...................... weblogic/application/ModuleManager.class
            File...................... weblogic/transaction/internal/ServerSCInfo$1.class
            File...................... weblogic/transaction/internal/ServerSCInfo$2.class
            File...................... weblogic/transaction/internal/ServerSCInfo$3.class
            File...................... weblogic/transaction/internal/ServerSCInfo$CallAfterCompletionsAction.class
            File...................... weblogic/transaction/internal/ServerSCInfo$CallBeforeCompletionsAction.class
            File...................... weblogic/transaction/internal/ServerSCInfo$ForceLocalCommitAction.class
            File...................... weblogic/transaction/internal/ServerSCInfo$ForceLocalRollbackAction.class
            File...................... weblogic/transaction/internal/ServerSCInfo$GetPropertiesAction.class
            File...................... weblogic/transaction/internal/ServerSCInfo$NonXAResourceCommitAction.class
            File...................... weblogic/transaction/internal/ServerSCInfo$RecoverAction.class
            File...................... weblogic/transaction/internal/ServerSCInfo$RegisteredSync.class
            File...................... weblogic/transaction/internal/ServerSCInfo$RollbackAction.class
            File...................... weblogic/transaction/internal/ServerSCInfo$StartCommitAction.class
            File...................... weblogic/transaction/internal/ServerSCInfo$StartPrepareAction.class
            File...................... weblogic/transaction/internal/ServerSCInfo$StartPrePrepareAndChain.class
            File...................... weblogic/transaction/internal/ServerSCInfo$StartRollbackAction.class
            File...................... weblogic/transaction/internal/ServerSCInfo.class
      
      Patch ID.................. 1U7B
      CR(s)..................... 
      Description............... VERBOSE SUPPORT DOESN'T SUPPORT NOT WITH WILDCARD ALWAYS DUMPS THE SOAP MESSAGE
VERBOSE SUPPORT DOESN'T SUPPORT NOT WITH WILDCARD ALWAYS DUMPS THE SOAP MESSAGE
      Classpath
        Classpath type............ SYSTEM
        Classpath control jar..... weblogic_patch.jar
          Jar....................... BUG13641115_1211.jar
            File...................... META-INF/MANIFEST.MF
            File...................... weblogic/wsee/util/Verbose$1.class
            File...................... weblogic/wsee/util/Verbose.class
      
      Patch ID.................. B33B
      CR(s)..................... 
      Description............... CANNOT CREATE "OTHER" DATASOURCE IN CONSOLE.
CANNOT CREATE "OTHER" DATASOURCE IN CONSOLE.
      Other artifacts
        Destination............... $WLS_INSTALL_DIR$/server/lib/consoleapp/webapp/WEB-INF/lib/console.jar
      
      Patch ID.................. WC8G
      CR(s)..................... 
      Description............... WEBLOGIC 12C REFERENCING SHARED EE LIBRARIES DOES NOT WORK
WEBLOGIC 12C REFERENCING SHARED EE LIBRARIES DOES NOT WORK
      Classpath
        Classpath type............ SYSTEM
        Classpath control jar..... weblogic_patch.jar
          Jar....................... BUG13516712_1211.jar
            File...................... META-INF/MANIFEST.MF
            File...................... weblogic/application/internal/library/EarLibraryDefinition.class
      
      Patch ID.................. B84Y
      CR(s)..................... 
      Description............... WSEE TESTS FAILING WITH SSL ISSUES ON JDK 7 (7U2)
WSEE TESTS FAILING WITH SSL ISSUES ON JDK 7 (7U2)
      Classpath
        Classpath type............ SYSTEM
        Classpath control jar..... weblogic_patch.jar
          Jar....................... BUG13391585_1211.jar
            File...................... META-INF/MANIFEST.MF
            File...................... weblogic/net/http/MessageHeader.class
      
      Patch ID.................. 8PE3
      CR(s)..................... 
      Description............... CAN'T DEPLOY APP WITH WEB SERVICE WHEN WEBLOGIC DOMAIN IS LOCATED ON THE NETWORK
CAN'T DEPLOY APP WITH WEB SERVICE WHEN WEBLOGIC DOMAIN IS LOCATED ON THE NETWORK
      Classpath
        Classpath type............ SYSTEM
        Classpath control jar..... weblogic_patch.jar
          Jar....................... BUG13019800_1211.jar
            File...................... META-INF/MANIFEST.MF
            File...................... weblogic/utils/zip/Handler.class
            File...................... weblogic/utils/zip/NullZipEntry.class
            File...................... weblogic/utils/zip/ZipFactory.class
            File...................... weblogic/utils/zip/ZipURLConnection.class
      
      Patch ID.................. H675
      CR(s)..................... 
      Description............... PSR:DEVX:WLS DEPLOYMENT REGRESSIONS IN 12.1.1
PSR:DEVX:WLS DEPLOYMENT REGRESSIONS IN 12.1.1
      Classpath
        Classpath type............ SYSTEM
        Classpath control jar..... weblogic_patch.jar
          Jar....................... BUG13340309_1211.jar
            File...................... META-INF/MANIFEST.MF
            File...................... com/oracle/pitchfork/server/Bootstrap.class
            File...................... com/oracle/pitchfork/server/ContainerBootstrap.class
            File...................... com/oracle/pitchfork/server/DefaultContainerBootstrap.class
            File...................... weblogic/application/internal/flow/EnvContextFlow$1.class
            File...................... weblogic/application/internal/flow/EnvContextFlow$AppEnvironmentBeanProvider.class
            File...................... weblogic/application/internal/flow/EnvContextFlow.class
            File...................... weblogic/application/naming/Environment$EnvType.class
            File...................... weblogic/application/naming/Environment$ResourceDescriptionData.class
            File...................... weblogic/application/naming/Environment.class
            File...................... weblogic/application/naming/EnvironmentBeanProvider.class
            File...................... weblogic/application/naming/EnvironmentBuilder$1.class
            File...................... weblogic/application/naming/EnvironmentBuilder.class
            File...................... weblogic/application/naming/EnvironmentBuilderManager$1.class
            File...................... weblogic/application/naming/EnvironmentBuilderManager.class
            File...................... weblogic/application/naming/EnvironmentException.class
            File...................... weblogic/application/naming/EnvUtils$1.class
            File...................... weblogic/application/naming/EnvUtils$InterfacesList.class
            File...................... weblogic/application/naming/EnvUtils.class
            File...................... weblogic/corba/rmic/StubGenerator.class
            File...................... weblogic/ejb/container/compliance/EJBObjectClassChecker.class
            File...................... weblogic/ejb/container/deployer/EJBDeployer$1.class
            File...................... weblogic/ejb/container/deployer/EJBDeployer$DeployedManagers.class
            File...................... weblogic/ejb/container/deployer/EJBDeployer$InjectionBasedEjbComponentContributorFactory.class
            File...................... weblogic/ejb/container/deployer/EJBDeployer.class
            File...................... weblogic/ejb/container/deployer/EJBModule$1.class
            File...................... weblogic/ejb/container/deployer/EJBModule.class
            File...................... weblogic/ejb/container/metadata/EjbDescriptorReaderImpl$NoCloseInputStream.class
            File...................... weblogic/ejb/container/metadata/EjbDescriptorReaderImpl$NonClosingClassFinder.class
            File...................... weblogic/ejb/container/metadata/EjbDescriptorReaderImpl.class
            File...................... weblogic/ejb/container/metadata/EjbJarLoader.class
            File...................... weblogic/ejb/container/metadata/WeblogicEjbJarLoader.class
            File...................... weblogic/ejb/container/persistence/InstalledPersistence.class
            File...................... weblogic/j2ee/managedbean/ManagedBeanModuleExtensionFactory.class
            File...................... weblogic/jndi/internal/ApplicationNamingNode$1.class
            File...................... weblogic/jndi/internal/ApplicationNamingNode$CacheInvalidationListener.class
            File...................... weblogic/jndi/internal/ApplicationNamingNode.class
            File...................... weblogic/jndi/internal/BasicNamingNode$1.class
            File...................... weblogic/jndi/internal/BasicNamingNode$2.class
            File...................... weblogic/jndi/internal/BasicNamingNode.class
            File...................... weblogic/jndi/internal/RootNamingNode.class
            File...................... weblogic/jndi/internal/ServerNamingNode.class
            File...................... weblogic/jndi/internal/WLNameParser.class
            File...................... weblogic/rmi/extensions/server/RMIDDParser.class
            File...................... weblogic/rmi/internal/BasicRuntimeDescriptor.class
            File...................... weblogic/rmi/internal/BasicServerRef$1.class
            File...................... weblogic/rmi/internal/BasicServerRef$ErrorReporter.class
            File...................... weblogic/rmi/internal/BasicServerRef$OIDManagerMaker.class
            File...................... weblogic/rmi/internal/BasicServerRef$UnreferencedExecuteRequest.class
            File...................... weblogic/rmi/internal/BasicServerRef.class
            File...................... weblogic/rmi/internal/DescriptorManager.class
            File...................... weblogic/rmi/internal/MethodDescriptor.class
            File...................... weblogic/servlet/provider/WlsJNDIProvider.class
            File...................... weblogic/utils/CharUtils.class
            File...................... weblogic/utils/classfile/AttributeTable.class
            File...................... weblogic/utils/classfile/Bytecodes.class
            File...................... weblogic/utils/classfile/ClassFile.class
            File...................... weblogic/utils/classfile/CodeAttribute$exception_struct.class
            File...................... weblogic/utils/classfile/CodeAttribute.class
            File...................... weblogic/utils/classfile/CodeGenHelper.class
            File...................... weblogic/utils/classfile/cp/ConstantPool.class
            File...................... weblogic/utils/classfile/expr/InvokeExpression.class
            File...................... weblogic/utils/classfile/expr/MemberVarExpression.class
            File...................... weblogic/utils/classfile/MethodInfo.class
            File...................... weblogic/utils/classfile/Scope$LocalVar.class
            File...................... weblogic/utils/classfile/Scope.class
            File...................... weblogic/utils/classfile/utils/CodeGenerator.class
            File...................... weblogic/utils/classloaders/CodeGenClassFinder.class
            File...................... weblogic/utils/classloaders/GenericClassLoader$1.class
            File...................... weblogic/utils/classloaders/GenericClassLoader$GetClassLoaderParentAction.class
            File...................... weblogic/utils/classloaders/GenericClassLoader.class
            File...................... weblogic/utils/compiler/CodeGenerator.class
            File...................... weblogic/utils/io/FilenameEncoder$UnsafeFilenameException.class
            File...................... weblogic/utils/io/FilenameEncoder.class
            File...................... weblogic/utils/StringUtils$1.class
            File...................... weblogic/utils/StringUtils$ReflectedStringMaker.class
            File...................... weblogic/utils/StringUtils$StringMaker.class
            File...................... weblogic/utils/StringUtils.class
            File...................... weblogic/validation/injection/ValidationManager$1.class
            File...................... weblogic/validation/injection/ValidationManager$ValidationBean.class
            File...................... weblogic/validation/injection/ValidationManager.class
            File...................... weblogic/work/ServerWorkManagerFactory.class
            File...................... weblogic/work/WorkManagerFactory.class
            File...................... weblogic/wsee/wsdl/internal/WsdlExtensibleImpl.class
            File...................... weblogic/wsee/wsdl/internal/WsdlSchemaImpl.class
            File...................... weblogic/xml/babel/baseparser/BaseParser.class
            File...................... weblogic/xml/babel/baseparser/CharDataElement.class
            File...................... weblogic/xml/babel/reader/XmlChars.class
            File...................... weblogic/xml/babel/scanner/CharData.class
            File...................... weblogic/xml/babel/scanner/CloseTag.class
            File...................... weblogic/xml/babel/scanner/IntegerQueue.class
            File...................... weblogic/xml/babel/scanner/Name.class
            File...................... weblogic/xml/babel/scanner/Scanner.class
            File...................... weblogic/xml/babel/scanner/ScannerState.class
  
  Product Description
  Product Name.............. Oracle Coherence
  Product Version........... 3.7.1.1
  Installed Components...... Coherence Product Files
  Product Install Directory. /opt/weblogic/coherence_3.7
  Java Home................. null
  Jave Vendor............... null
  Java Version.............. null
  Patch Directory........... /opt/weblogic/patch_ocp371
  
  Product Description
  Product Name.............. Oracle Enterprise Pack for Eclipse
  Product Version........... 1.0.1.20120312.0
  Installed Components...... Common Files
  Product Install Directory. /opt/weblogic/oepe_12.1.1.0.1
  Java Home................. /opt/weblogic/jdk160_29
  Jave Vendor............... Sun
  Java Version.............. 1.6.0_29
  Patch Directory........... /opt/weblogic/patch_oepe101
Paste your text here.

Saturday, March 30, 2013

Maven JPA project with alternative JPA provider - persistence-eclipselink.xml and persiste-hibernate.xml

We want to provide alternative persistence.xml files to test alternative JPA providers in same project
persistence-eclipselink.xml and persiste-hibernate.xml will be created

Use Maven archetype JPA project  for start
http://www.mastertheboss.com/maven-hibernate-jpa/maven-and-jpa-tutorial


Create project from archetype

[dave@dave workspace]$ mvn archetype:generate -DarchetypeGroupId=com.github.lalyos -DarchetypeArtifactId=standalone-jpa-eclipselink-archetype -DgroupId=com.mastertheboss -DartifactId=EclipseJPAExample -Dversion=1.0-SNAPSHOT -Dpackage=com.mastertheboss -DinteractiveMode=false
/usr/java//jdk1.7.0_13
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] >>> maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom >>>
[INFO] 
[INFO] <<< maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom <<<
[INFO] 
[INFO] --- maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom ---
[INFO] Generating project in Batch mode
[INFO] Archetype [com.github.lalyos:standalone-jpa-eclipselink-archetype:0.0.2] found in catalog remote
Downloading: http://repo.maven.apache.org/maven2/com/github/lalyos/standalone-jpa-eclipselink-archetype/0.0.2/standalone-jpa-eclipselink-archetype-0.0.2.jar
Downloaded: http://repo.maven.apache.org/maven2/com/github/lalyos/standalone-jpa-eclipselink-archetype/0.0.2/standalone-jpa-eclipselink-archetype-0.0.2.jar (5 KB at 6.0 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/com/github/lalyos/standalone-jpa-eclipselink-archetype/0.0.2/standalone-jpa-eclipselink-archetype-0.0.2.pom
Downloaded: http://repo.maven.apache.org/maven2/com/github/lalyos/standalone-jpa-eclipselink-archetype/0.0.2/standalone-jpa-eclipselink-archetype-0.0.2.pom (3 KB at 4.0 KB/sec)
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Archetype: standalone-jpa-eclipselink-archetype:0.0.2
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: com.mastertheboss
[INFO] Parameter: artifactId, Value: EclipseJPAExample
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: package, Value: com.mastertheboss
[INFO] Parameter: packageInPathFormat, Value: com/mastertheboss
[INFO] Parameter: package, Value: com.mastertheboss
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: groupId, Value: com.mastertheboss
[INFO] Parameter: artifactId, Value: EclipseJPAExample
[INFO] project created from Archetype in dir: /home/dave/workspace/EclipseJPAExample
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.438s
[INFO] Finished at: Sat Mar 30 07:52:16 CET 2013
[INFO] Final Memory: 8M/21M
[INFO] ------------------------------------------------------------------------


Files in created project

[dave@dave workspace]$ ls -lR  EclipseJPAExample/
EclipseJPAExample/:
total 20
-rw-rw-r--. 1 dave dave   70 Mar 30 07:52 ij.properties
-rw-rw-r--. 1 dave dave 1206 Mar 30 07:52 pom.xml
-rw-rw-r--. 1 dave dave   69 Mar 30 07:52 run.sh
-rw-rw-r--. 1 dave dave  107 Mar 30 07:52 show-derby.sh
drwxrwxr-x. 3 dave dave 4096 Mar 30 07:52 src

EclipseJPAExample/src:
total 4
drwxrwxr-x. 4 dave dave 4096 Mar 30 07:52 main

EclipseJPAExample/src/main:
total 8
drwxrwxr-x. 3 dave dave 4096 Mar 30 07:52 java
drwxrwxr-x. 3 dave dave 4096 Mar 30 07:52 resources

EclipseJPAExample/src/main/java:
total 4
drwxrwxr-x. 3 dave dave 4096 Mar 30 07:52 com

EclipseJPAExample/src/main/java/com:
total 4
drwxrwxr-x. 4 dave dave 4096 Mar 30 07:52 mastertheboss

EclipseJPAExample/src/main/java/com/mastertheboss:
total 8
drwxrwxr-x. 2 dave dave 4096 Mar 30 07:52 domain
drwxrwxr-x. 2 dave dave 4096 Mar 30 07:52 jpa

EclipseJPAExample/src/main/java/com/mastertheboss/domain:
total 8
-rw-rw-r--. 1 dave dave  937 Mar 30 07:52 Department.java
-rw-rw-r--. 1 dave dave 1001 Mar 30 07:52 Employee.java

EclipseJPAExample/src/main/java/com/mastertheboss/jpa:
total 4
-rw-rw-r--. 1 dave dave 1624 Mar 30 07:52 JpaTest.java

EclipseJPAExample/src/main/resources:
total 4
drwxrwxr-x. 2 dave dave 4096 Mar 30 07:52 META-INF

EclipseJPAExample/src/main/resources/META-INF:
total 4
-rw-rw-r--. 1 dave dave 1229 Mar 30 07:52 persistence.xml
[dave@dave workspace]$ 


Run project with EclipseLink

[dave@dave EclipseJPAExample]$ mvn compile exec:java -Dexec.mainClass=com.mastertheboss.jpa.JpaTest
/usr/java//jdk1.7.0_13
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building EclipseJPAExample 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ EclipseJPAExample ---
[debug] execute contextualize
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ EclipseJPAExample ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] >>> exec-maven-plugin:1.2.1:java (default-cli) @ EclipseJPAExample >>>
[INFO] 
[INFO] <<< exec-maven-plugin:1.2.1:java (default-cli) @ EclipseJPAExample <<<
[INFO] 
[INFO] --- exec-maven-plugin:1.2.1:java (default-cli) @ EclipseJPAExample ---
[EL Finest]: 2013-03-30 08:06:21.895--ServerSession(18985176)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--Begin predeploying Persistence Unit persistenceUnit; session file:/home/dave/workspace/EclipseJPAExample/target/classes/_persistenceUnit; state Initial; factoryCount 0
[EL Finest]: 2013-03-30 08:06:21.92--ServerSession(18985176)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--property=eclipselink.orm.throw.exceptions; default value=true
[EL Finest]: 2013-03-30 08:06:21.956--ServerSession(18985176)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--property=eclipselink.jpa.uppercase-column-names; default value=false
[EL Finer]: 2013-03-30 08:06:21.957--ServerSession(18985176)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--Searching for default mapping file in file:/home/dave/workspace/EclipseJPAExample/target/classes/
[EL Finer]: 2013-03-30 08:06:21.961--ServerSession(18985176)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--Searching for default mapping file in file:/home/dave/workspace/EclipseJPAExample/target/classes/
[EL Config]: 2013-03-30 08:06:22.164--ServerSession(18985176)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--The access type for the persistent class [class com.mastertheboss.domain.Employee] is set to [FIELD].
[EL Config]: 2013-03-30 08:06:22.235--ServerSession(18985176)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--The target entity (reference) class for the many to one mapping element [field department] is being defaulted to: class com.mastertheboss.domain.Department.
[EL Config]: 2013-03-30 08:06:22.238--ServerSession(18985176)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--The access type for the persistent class [class com.mastertheboss.domain.Department] is set to [FIELD].
[EL Config]: 2013-03-30 08:06:22.26--ServerSession(18985176)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--The target entity (reference) class for the one to many mapping element [field employees] is being defaulted to: class com.mastertheboss.domain.Employee.
[EL Config]: 2013-03-30 08:06:22.261--ServerSession(18985176)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--The alias name for the entity class [class com.mastertheboss.domain.Employee] is being defaulted to: Employee.
[EL Config]: 2013-03-30 08:06:22.266--ServerSession(18985176)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--The table name for entity [class com.mastertheboss.domain.Employee] is being defaulted to: EMPLOYEE.
[EL Config]: 2013-03-30 08:06:22.298--ServerSession(18985176)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--The column name for element [field id] is being defaulted to: ID.
[EL Config]: 2013-03-30 08:06:22.301--ServerSession(18985176)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--The column name for element [field name] is being defaulted to: NAME.
[EL Config]: 2013-03-30 08:06:22.303--ServerSession(18985176)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--The alias name for the entity class [class com.mastertheboss.domain.Department] is being defaulted to: Department.
[EL Config]: 2013-03-30 08:06:22.304--ServerSession(18985176)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--The table name for entity [class com.mastertheboss.domain.Department] is being defaulted to: DEPARTMENT.
[EL Config]: 2013-03-30 08:06:22.309--ServerSession(18985176)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--The column name for element [field id] is being defaulted to: ID.
[EL Config]: 2013-03-30 08:06:22.31--ServerSession(18985176)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--The column name for element [field name] is being defaulted to: NAME.
[EL Config]: 2013-03-30 08:06:22.364--ServerSession(18985176)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--The primary key column name for the mapping element [field department] is being defaulted to: ID.
[EL Config]: 2013-03-30 08:06:22.365--ServerSession(18985176)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--The foreign key column name for the mapping element [field department] is being defaulted to: DEPARTMENT_ID.
[EL Finest]: 2013-03-30 08:06:22.418--ServerSession(18985176)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--End predeploying Persistence Unit persistenceUnit; session file:/home/dave/workspace/EclipseJPAExample/target/classes/_persistenceUnit; state Predeployed; factoryCount 0
[EL Finer]: 2013-03-30 08:06:22.419--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--JavaSECMPInitializer - transformer is null.
[EL Finest]: 2013-03-30 08:06:22.419--ServerSession(18985176)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--Begin predeploying Persistence Unit persistenceUnit; session file:/home/dave/workspace/EclipseJPAExample/target/classes/_persistenceUnit; state Predeployed; factoryCount 0
[EL Finest]: 2013-03-30 08:06:22.419--ServerSession(18985176)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--End predeploying Persistence Unit persistenceUnit; session file:/home/dave/workspace/EclipseJPAExample/target/classes/_persistenceUnit; state Predeployed; factoryCount 1
[EL Finest]: 2013-03-30 08:06:22.425--ServerSession(18985176)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--Begin deploying Persistence Unit persistenceUnit; session file:/home/dave/workspace/EclipseJPAExample/target/classes/_persistenceUnit; state Predeployed; factoryCount 1
[EL Finer]: 2013-03-30 08:06:22.454--ServerSession(18985176)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--Could not initialize Validation Factory. Encountered following exception: java.lang.NoClassDefFoundError: javax/validation/Validation
[EL Finest]: 2013-03-30 08:06:22.467--ServerSession(18985176)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--property=eclipselink.logging.level; value=FINEST; translated value=FINEST
[EL Finest]: 2013-03-30 08:06:22.467--ServerSession(18985176)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--property=eclipselink.logging.level; value=FINEST; translated value=FINEST
[EL Finest]: 2013-03-30 08:06:22.468--ServerSession(18985176)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--property=javax.persistence.jdbc.user; value=EclipseJPAExample
[EL Finest]: 2013-03-30 08:06:22.468--ServerSession(18985176)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--property=javax.persistence.jdbc.password; value=xxxxxx
[EL Finest]: 2013-03-30 08:06:23.403--ServerSession(18985176)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--property=javax.persistence.jdbc.driver; value=org.apache.derby.jdbc.EmbeddedDriver
[EL Finest]: 2013-03-30 08:06:23.403--ServerSession(18985176)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--property=javax.persistence.jdbc.url; value=jdbc:derby:simpleDb;create=true
[EL Info]: 2013-03-30 08:06:23.404--ServerSession(18985176)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--EclipseLink, version: Eclipse Persistence Services - 2.2.1.v20110722-r9776
[EL Finest]: 2013-03-30 08:06:26.359--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--DBPlatform: org.eclipse.persistence.platform.database.HSQLPlatform, RegularExpression: (?i)hsql.*.
[EL Finest]: 2013-03-30 08:06:26.359--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--DBPlatform: org.eclipse.persistence.platform.database.InformixPlatform, RegularExpression: (?i)informix.*.
[EL Finest]: 2013-03-30 08:06:26.359--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--DBPlatform: org.eclipse.persistence.platform.database.PointBasePlatform, RegularExpression: (?i)pointbase.*.
[EL Finest]: 2013-03-30 08:06:26.36--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--DBPlatform: org.eclipse.persistence.platform.database.DB2Platform, RegularExpression: (?i).*db2.*.
[EL Finest]: 2013-03-30 08:06:26.36--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--DBPlatform: org.eclipse.persistence.platform.database.SQLServerPlatform, RegularExpression: (?i)microsoft.*.
[EL Finest]: 2013-03-30 08:06:26.36--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--DBPlatform: org.eclipse.persistence.platform.database.PostgreSQLPlatform, RegularExpression: (?i)postgresql.*.
[EL Finest]: 2013-03-30 08:06:26.36--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--DBPlatform: org.eclipse.persistence.platform.database.MaxDBPlatform, RegularExpression: SAP DB.
[EL Finest]: 2013-03-30 08:06:26.36--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--DBPlatform: org.eclipse.persistence.platform.database.H2Platform, RegularExpression: (?i)h2.*.
[EL Finest]: 2013-03-30 08:06:26.361--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--DBPlatform: org.eclipse.persistence.platform.database.SybasePlatform, RegularExpression: (?i)(sybase.*)|(adaptive server enterprise.*)|(SQL Server).
[EL Finest]: 2013-03-30 08:06:26.361--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--DBPlatform: org.eclipse.persistence.platform.database.FirebirdPlatform, RegularExpression: (?i)firebird.*.
[EL Finest]: 2013-03-30 08:06:26.361--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--DBPlatform: org.eclipse.persistence.platform.database.JavaDBPlatform, RegularExpression: (?i).*derby.
[EL Fine]: 2013-03-30 08:06:26.361--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--Detected Vendor platform: org.eclipse.persistence.platform.database.JavaDBPlatform
[EL Config]: 2013-03-30 08:06:26.387--ServerSession(18985176)--Connection(30138829)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--connecting(DatabaseLogin(
    platform=>JavaDBPlatform
    user name=> "EclipseJPAExample"
    datasource URL=> "jdbc:derby:simpleDb;create=true"
))
[EL Config]: 2013-03-30 08:06:26.394--ServerSession(18985176)--Connection(5592751)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--Connected: jdbc:derby:simpleDb
    User: EclipseJPAExample
    Database: Apache Derby  Version: 10.8.2.2 - (1181258)
    Driver: Apache Derby Embedded JDBC Driver  Version: 10.8.2.2 - (1181258)
[EL Finest]: 2013-03-30 08:06:26.395--ServerSession(18985176)--Connection(5592751)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--Connection acquired from connection pool [default].
[EL Finest]: 2013-03-30 08:06:26.395--ServerSession(18985176)--Connection(5592751)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--Connection released to connection pool [default].
[EL Finest]: 2013-03-30 08:06:26.428--ServerSession(18985176)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--sequencing connected, state is Preallocation_Transaction_NoAccessor_State
[EL Finest]: 2013-03-30 08:06:26.428--ServerSession(18985176)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--sequence SEQUENCE: preallocation size 50
[EL Finest]: 2013-03-30 08:06:26.428--ServerSession(18985176)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--sequence SEQ_GEN: preallocation size 50
[EL Info]: 2013-03-30 08:06:26.517--ServerSession(18985176)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--file:/home/dave/workspace/EclipseJPAExample/target/classes/_persistenceUnit login successful
[EL Finest]: 2013-03-30 08:06:26.555--ServerSession(18985176)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--Execute query DataModifyQuery(sql="CREATE TABLE EMPLOYEE (ID BIGINT NOT NULL, NAME VARCHAR(255), DEPARTMENT_ID BIGINT, PRIMARY KEY (ID))")
[EL Finest]: 2013-03-30 08:06:26.557--ServerSession(18985176)--Connection(5592751)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-30 08:06:26.557--ServerSession(18985176)--Connection(5592751)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--CREATE TABLE EMPLOYEE (ID BIGINT NOT NULL, NAME VARCHAR(255), DEPARTMENT_ID BIGINT, PRIMARY KEY (ID))
[EL Fine]: 2013-03-30 08:06:27.223--ServerSession(18985176)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--VALUES(1)
[EL Finest]: 2013-03-30 08:06:27.366--ServerSession(18985176)--Connection(5592751)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--Connection released to connection pool [default].
[EL Warning]: 2013-03-30 08:06:27.367--ServerSession(18985176)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.2.1.v20110722-r9776): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Table/View 'EMPLOYEE' already exists in Schema 'ECLIPSEJPAEXAMPLE'.
Error Code: 30000
Call: CREATE TABLE EMPLOYEE (ID BIGINT NOT NULL, NAME VARCHAR(255), DEPARTMENT_ID BIGINT, PRIMARY KEY (ID))
Query: DataModifyQuery(sql="CREATE TABLE EMPLOYEE (ID BIGINT NOT NULL, NAME VARCHAR(255), DEPARTMENT_ID BIGINT, PRIMARY KEY (ID))")
[EL Finest]: 2013-03-30 08:06:27.369--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--The table (EMPLOYEE) is already in the database, and wont be created.
[EL Finest]: 2013-03-30 08:06:27.37--ServerSession(18985176)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--Execute query DataModifyQuery(sql="CREATE TABLE DEPARTMENT (ID BIGINT NOT NULL, NAME VARCHAR(255), PRIMARY KEY (ID))")
[EL Finest]: 2013-03-30 08:06:27.37--ServerSession(18985176)--Connection(5592751)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-30 08:06:27.37--ServerSession(18985176)--Connection(5592751)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--CREATE TABLE DEPARTMENT (ID BIGINT NOT NULL, NAME VARCHAR(255), PRIMARY KEY (ID))
[EL Fine]: 2013-03-30 08:06:27.587--ServerSession(18985176)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--VALUES(1)
[EL Finest]: 2013-03-30 08:06:27.588--ServerSession(18985176)--Connection(5592751)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--Connection released to connection pool [default].
[EL Warning]: 2013-03-30 08:06:27.588--ServerSession(18985176)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.2.1.v20110722-r9776): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Table/View 'DEPARTMENT' already exists in Schema 'ECLIPSEJPAEXAMPLE'.
Error Code: 30000
Call: CREATE TABLE DEPARTMENT (ID BIGINT NOT NULL, NAME VARCHAR(255), PRIMARY KEY (ID))
Query: DataModifyQuery(sql="CREATE TABLE DEPARTMENT (ID BIGINT NOT NULL, NAME VARCHAR(255), PRIMARY KEY (ID))")
[EL Finest]: 2013-03-30 08:06:27.589--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--The table (DEPARTMENT) is already in the database, and wont be created.
[EL Finest]: 2013-03-30 08:06:27.59--ServerSession(18985176)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--Execute query DataModifyQuery(sql="ALTER TABLE EMPLOYEE ADD CONSTRAINT MPLOYEEDPARTMENTID FOREIGN KEY (DEPARTMENT_ID) REFERENCES DEPARTMENT (ID)")
[EL Finest]: 2013-03-30 08:06:27.59--ServerSession(18985176)--Connection(5592751)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-30 08:06:27.59--ServerSession(18985176)--Connection(5592751)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--ALTER TABLE EMPLOYEE ADD CONSTRAINT MPLOYEEDPARTMENTID FOREIGN KEY (DEPARTMENT_ID) REFERENCES DEPARTMENT (ID)
[EL Fine]: 2013-03-30 08:06:27.709--ServerSession(18985176)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--VALUES(1)
[EL Finest]: 2013-03-30 08:06:27.711--ServerSession(18985176)--Connection(5592751)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--Connection released to connection pool [default].
[EL Warning]: 2013-03-30 08:06:27.711--ServerSession(18985176)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.2.1.v20110722-r9776): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Constraint 'MPLOYEEDPARTMENTID' already exists in Schema 'ECLIPSEJPAEXAMPLE'.
Error Code: 30000
Call: ALTER TABLE EMPLOYEE ADD CONSTRAINT MPLOYEEDPARTMENTID FOREIGN KEY (DEPARTMENT_ID) REFERENCES DEPARTMENT (ID)
Query: DataModifyQuery(sql="ALTER TABLE EMPLOYEE ADD CONSTRAINT MPLOYEEDPARTMENTID FOREIGN KEY (DEPARTMENT_ID) REFERENCES DEPARTMENT (ID)")
[EL Finest]: 2013-03-30 08:06:27.713--ServerSession(18985176)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--Execute query DataModifyQuery(sql="CREATE TABLE SEQUENCE (SEQ_NAME VARCHAR(50) NOT NULL, SEQ_COUNT DECIMAL(15), PRIMARY KEY (SEQ_NAME))")
[EL Finest]: 2013-03-30 08:06:27.714--ServerSession(18985176)--Connection(5592751)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-30 08:06:27.714--ServerSession(18985176)--Connection(5592751)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--CREATE TABLE SEQUENCE (SEQ_NAME VARCHAR(50) NOT NULL, SEQ_COUNT DECIMAL(15), PRIMARY KEY (SEQ_NAME))
[EL Fine]: 2013-03-30 08:06:27.853--ServerSession(18985176)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--VALUES(1)
[EL Finest]: 2013-03-30 08:06:27.854--ServerSession(18985176)--Connection(5592751)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--Connection released to connection pool [default].
[EL Warning]: 2013-03-30 08:06:27.855--ServerSession(18985176)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.2.1.v20110722-r9776): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Table/View 'SEQUENCE' already exists in Schema 'ECLIPSEJPAEXAMPLE'.
Error Code: 30000
Call: CREATE TABLE SEQUENCE (SEQ_NAME VARCHAR(50) NOT NULL, SEQ_COUNT DECIMAL(15), PRIMARY KEY (SEQ_NAME))
Query: DataModifyQuery(sql="CREATE TABLE SEQUENCE (SEQ_NAME VARCHAR(50) NOT NULL, SEQ_COUNT DECIMAL(15), PRIMARY KEY (SEQ_NAME))")
[EL Finest]: 2013-03-30 08:06:27.856--ServerSession(18985176)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--Execute query DataReadQuery(sql="SELECT * FROM SEQUENCE WHERE SEQ_NAME = 'SEQ_GEN'")
[EL Finest]: 2013-03-30 08:06:27.857--ServerSession(18985176)--Connection(5592751)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-30 08:06:27.857--ServerSession(18985176)--Connection(5592751)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--SELECT * FROM SEQUENCE WHERE SEQ_NAME = SEQ_GEN
[EL Finest]: 2013-03-30 08:06:27.933--ServerSession(18985176)--Connection(5592751)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--Connection released to connection pool [default].
[EL Finer]: 2013-03-30 08:06:27.96--ServerSession(18985176)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--Canonical Metamodel class [com.mastertheboss.domain.Department_] not found during initialization.
[EL Finer]: 2013-03-30 08:06:27.96--ServerSession(18985176)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--Canonical Metamodel class [com.mastertheboss.domain.Employee_] not found during initialization.
[EL Finest]: 2013-03-30 08:06:27.96--ServerSession(18985176)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--End deploying Persistence Unit persistenceUnit; session file:/home/dave/workspace/EclipseJPAExample/target/classes/_persistenceUnit; state Deployed; factoryCount 1
[EL Finer]: 2013-03-30 08:06:27.991--ServerSession(18985176)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--client acquired: 7982406
[EL Finer]: 2013-03-30 08:06:28.031--ClientSession(7982406)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--acquire unit of work: 13165575
[EL Finer]: 2013-03-30 08:06:28.565--UnitOfWork(13165575)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--begin unit of work flush
[EL Finer]: 2013-03-30 08:06:28.568--UnitOfWork(13165575)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--end unit of work flush
[EL Finest]: 2013-03-30 08:06:28.568--UnitOfWork(13165575)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--Execute query ReadAllQuery(referenceClass=Employee sql="SELECT ID, NAME, DEPARTMENT_ID FROM EMPLOYEE")
[EL Finest]: 2013-03-30 08:06:28.571--ServerSession(18985176)--Connection(5592751)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-30 08:06:28.571--ServerSession(18985176)--Connection(5592751)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--SELECT ID, NAME, DEPARTMENT_ID FROM EMPLOYEE
[EL Finest]: 2013-03-30 08:06:28.584--ServerSession(18985176)--Connection(5592751)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--Connection released to connection pool [default].
[EL Finest]: 2013-03-30 08:06:28.593--ServerSession(18985176)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--Execute query ReadObjectQuery(name="department" referenceClass=Department )
[EL Finest]: 2013-03-30 08:06:28.594--ServerSession(18985176)--Connection(5592751)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-30 08:06:28.594--ServerSession(18985176)--Connection(5592751)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--SELECT ID, NAME FROM DEPARTMENT WHERE (ID = ?)
    bind => [1]
[EL Finest]: 2013-03-30 08:06:28.613--ServerSession(18985176)--Connection(5592751)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--Connection released to connection pool [default].
[EL Finest]: 2013-03-30 08:06:28.62--UnitOfWork(13165575)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--Register the existing object com.mastertheboss.domain.Department@94fb9d
[EL Finest]: 2013-03-30 08:06:28.623--ServerSession(18985176)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--Execute query ReadObjectQuery(name="department" referenceClass=Department )
[EL Finest]: 2013-03-30 08:06:28.623--UnitOfWork(13165575)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--Register the existing object com.mastertheboss.domain.Department@94fb9d
[EL Finer]: 2013-03-30 08:06:28.624--UnitOfWork(13165575)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--begin unit of work commit
[EL Finer]: 2013-03-30 08:06:28.627--UnitOfWork(13165575)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--end unit of work commit
[EL Finer]: 2013-03-30 08:06:28.627--UnitOfWork(13165575)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--resume unit of work
[EL Finest]: 2013-03-30 08:06:28.628--UnitOfWork(13165575)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--Execute query ReadAllQuery(referenceClass=Employee sql="SELECT ID, NAME, DEPARTMENT_ID FROM EMPLOYEE")
[EL Finest]: 2013-03-30 08:06:28.628--ServerSession(18985176)--Connection(5592751)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-30 08:06:28.628--ServerSession(18985176)--Connection(5592751)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--SELECT ID, NAME, DEPARTMENT_ID FROM EMPLOYEE
[EL Finest]: 2013-03-30 08:06:28.629--ServerSession(18985176)--Connection(5592751)--Thread(Thread[com.mastertheboss.jpa.JpaTest.main(),5,com.mastertheboss.jpa.JpaTest])--Connection released to connection pool [default].
num of employess:2
next employee: Employee [id=3, name=Captain Nemo, department=java]
next employee: Employee [id=2, name=Jakab Gipsz, department=java]
.. done
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.653s
[INFO] Finished at: Sat Mar 30 08:06:28 CET 2013
[INFO] Final Memory: 20M/48M
[INFO] ------------------------------------------------------------------------
[dave@dave EclipseJPAExample]$ 


Add hibernate dependency

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <groupId>com.mastertheboss</groupId>
        <artifactId>EclipseJPAExample</artifactId>
        <version>1.0-SNAPSHOT</version>
        <repositories>
                <repository>
                        <id>EclipseLink Repo</id>
                        <url>http://download.eclipse.org/rt/eclipselink/maven.repo</url>
                        <name>EclipseLink Repo</name>
                </repository>
        </repositories>
        <dependencies>
                <dependency>
                        <groupId>org.apache.derby</groupId>
                   
     <artifactId>derby</artifactId>
                        <version>10.8.2.2</version>
                </dependency>
                <dependency>
                        <groupId>org.apache.derby</groupId>
                        <artifactId>derbytools</artifactId>
                        <version>10.8.2.2</version>
                </dependency>
                <dependency>
                        <groupId>org.eclipse.persistence</groupId>
                        <artifactId>eclipselink</artifactId>
                        <version>2.2.1</version>
                </dependency>
                <dependency>
                        <groupId>org.eclipse.persistence</groupId>
                        <artifactId>javax.persistence</artifactId>
                        <version>2.0.3</version>
                </dependency>
                <dependency>
                        <groupId>org.hibernate.javax.persistence</groupId>
                        <artifactId>hibernate-jpa-2.0-api</artifactId>
                        <version>1.0.1.Final</version>
                </dependency>
                <dependency>
                        <groupId>org.hibernate</groupId>
                        <artifactId>hibernate-entitymanager</artifactId>
                        <version>4.0.1.Final</version>
                </dependency>
        </dependencies>
</project>


Add profiles for alternative JPA providers
Inspired by Geronimo tests - use profiles for alternative JPA providers
http://svn.apache.org/repos/asf/geronimo/samples/tags/samples-parent-3.0-beta-1/samples/javaee6/jpa20demo-javaee6/jpa20demo-javaee6-war/
  <profiles>
        <profile>
            <id>openjpa</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <executions>
                            <execution>
                                <phase>process-resources</phase>
                                <id>rename-persistence-file</id>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <tasks>
                                        <echo>Rename persistence-openjpa.xml to persistence.xml</echo>
                                        <copy file="${basedir}/src/main/resources/META-INF/persistence_openjpa.xml" tofile="${project.build.directory}/${pom.artifactId}-${version}/WEB-INF/classes/META-INF/persistence.xml" overwrite="true" />
                                    </tasks>
                                </configuration>
                           </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>hibernate</id>
            <activation>
                <activeByDefault>false</activeByDefault>
                <property>
                    <name>JPAProvider</name>
                    <value>hibernate</value>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <executions>
                            <execution>
                                <phase>process-resources</phase>
                                <id>rename-persistence-file</id>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
nfiguration>
                                    <tasks>
                                        <echo>Rename persistence-hibernate.xml to persistence.xml</echo>
                                        <copy file="${basedir}/src/main/resources/META-INF/persistence_hibernate.xml" tofile="${project.build.directory}/${pom.artifactId}-${version}/WEB-INF/classes/META-INF/persistence.xml" overwrite="true" />
                                    </tasks>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>eclipselink</id>
            <activation>
                <activeByDefault>false</activeByDefault>
                <property>
                    <name>JPAProvider</name>
                    <value>eclipselink</value>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
 <executions>
                            <execution>
                                <phase>process-resources</phase>
                                <id>rename-persistence-file</id>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <tasks>
                                        <echo>Rename persistence-eclipselink.xml to persistence.xml</echo>
                                        <copy file="${basedir}/src/main/resources/META-INF/persistence_eclipselink.xml" tofile="${project.build.directory}/${pom.artifactId}-${version}/WEB-INF/classes/META-INF/persistence.xml" overwrite="true" />
                                    </tasks>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>




Maven dependency list

[dave@dave EclipseJPAExample]$ mvn dependency::list
/usr/java//jdk1.7.0_13
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building EclipseJPAExample 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-dependency-plugin:2.1:list (default-cli) @ EclipseJPAExample ---
[INFO] 
[INFO] The following files have been resolved:
[INFO]    antlr:antlr:jar:2.7.7:compile
[INFO]    commons-collections:commons-collections:jar:3.2.1:compile
[INFO]    dom4j:dom4j:jar:1.6.1:compile
[INFO]    org.apache.derby:derby:jar:10.8.2.2:compile
[INFO]    org.apache.derby:derbytools:jar:10.8.2.2:compile
[INFO]    org.eclipse.persistence:eclipselink:jar:2.2.1:compile
[INFO]    org.eclipse.persistence:javax.persistence:jar:2.0.3:compile
[INFO]    org.hibernate:hibernate-core:jar:4.0.1.Final:compile
[INFO]    org.hibernate:hibernate-entitymanager:jar:4.0.1.Final:compile
[INFO]    org.hibernate.common:hibernate-commons-annotations:jar:4.0.1.Final:compile
[INFO]    org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.1.Final:compile
[INFO]    org.javassist:javassist:jar:3.15.0-GA:compile
[INFO]    org.jboss.logging:jboss-logging:jar:3.1.0.CR2:compile
[INFO]    org.jboss.spec.javax.transaction:jboss-transaction-api_1.1_spec:jar:1.0.0.Final:compile
[INFO]    xml-apis:xml-apis:jar:1.0.b2:compile
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.760s
[INFO] Finished at: Sat Mar 30 08:35:54 CET 2013
[INFO] Final Memory: 6M/15M
[INFO] ------------------------------------------------------------------------
[dave@dave EclipseJPAExample]$ 

Create alternative persistence.xml files
[dave@dave EclipseJPAExample]$ ls -l ./src/main/resources/META-INF
total 8
-rw-rw-r--. 1 dave dave 1230 Mar 30 08:06 persistence-eclipselink.xml
-rw-rw-r--. 1 dave dave 1067 Mar 30 08:19 persistence-hibernate.xml

[dave@dave EclipseJPAExample]$ more ./src/main/resources/META-INF/persistence-eclipselink.xml
<?xml version="1.0" encoding="UTF-8" ?>
<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/persiste
nce/persistence_2_0.xsd"
    version="2.0" xmlns="http://java.sun.com/xml/ns/persistence">
    <persistence-unit name="persistenceUnit" transaction-type="RESOURCE_LOCAL">
        <!-- shouldn't be valid for java SE per specification, but it works for EclipseLink ..
. -->
        <exclude-unlisted-classes>false</exclude-unlisted-classes>
        <properties>
        
            <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.Em
beddedDriver" />
            <property name="javax.persistence.jdbc.url" value="jdbc:derby:simpleDb;create=
true" />
            <property name="javax.persistence.jdbc.user" value="EclipseJPAExample" />
            <property name="javax.persistence.jdbc.password" value="EclipseJPAExample" />

            <!-- EclipseLink should create the database schema automatically -->
            <property name="eclipselink.ddl-generation" value="create-tables" />
            <property name="eclipselink.ddl-generation.output-mode" value="database" />
            <property name="eclipselink.logging.level" value="FINEST"/>            
        </properties>

    </persistence-unit>
</persistence>

[dave@dave EclipseJPAExample]$ more ./src/main/resources/META-INF/persistence-hibernate.xml<?xml version="1.0" encoding="UTF-8" ?>
<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/pers
istence_2_0.xsd"
version="2.0" xmlns="http://java.sun.com/xml/ns/persistence">
    <persistence-unit name="persistenceUnit" transaction-type="RESOURCE_LOCAL">
    
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
    
        <class>com.mastertheboss.domain.Employee</class>
        <class>com.mastertheboss.domain.Department</class>
    <properties>
               <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDri
ver" />
               <property name="javax.persistence.jdbc.url" value="jdbc:derby:simpleDb;create=true" />
               <property name="javax.persistence.jdbc.user" value="EclipseJPAExample" />
               <property name="javax.persistence.jdbc.password" value="EclipseJPAExample" />


        <property name="hbm2ddl.auto" value="create" />

        <property name="hibernate.dialect" value="org.hibernate.dialect.DerbyDialect" />
        <property name="hibernate.show_sql" value="true" />
        <property name="hibernate.format_sql" value="true" />
    </properties>
 
    </persistence-unit>
</persistence>

Run project with Hibernate as JPA provider
[dave@dave EclipseJPAExample]$ mvn compile exec:java -Dexec.mainClass=com.mastertheboss.jpa.JpaTest
/usr/java//jdk1.7.0_13
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building EclipseJPAExample 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ EclipseJPAExample ---
[debug] execute contextualize
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 3 resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ EclipseJPAExample ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] >>> exec-maven-plugin:1.2.1:java (default-cli) @ EclipseJPAExample >>>
[INFO] 
[INFO] <<< exec-maven-plugin:1.2.1:java (default-cli) @ EclipseJPAExample <<<
[INFO] 
[INFO] --- exec-maven-plugin:1.2.1:java (default-cli) @ EclipseJPAExample ---
Mar 30, 2013 8:48:53 AM org.hibernate.annotations.common.Version <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
Mar 30, 2013 8:48:53 AM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.0.1.Final}
Mar 30, 2013 8:48:53 AM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
Mar 30, 2013 8:48:53 AM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
Mar 30, 2013 8:48:54 AM org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000402: Using Hibernate built-in connection pool (not for production use!)
Mar 30, 2013 8:48:54 AM org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000115: Hibernate connection pool size: 20
Mar 30, 2013 8:48:54 AM org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000006: Autocommit mode: true
Mar 30, 2013 8:48:54 AM org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000401: using driver [org.apache.derby.jdbc.EmbeddedDriver] at URL [jdbc:derby:simpleDb;create=true]
Mar 30, 2013 8:48:54 AM org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000046: Connection properties: {user=EclipseJPAExample, password=****, autocommit=true, release_mode=auto}
Mar 30, 2013 8:48:56 AM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.DerbyDialect
Mar 30, 2013 8:48:56 AM org.hibernate.dialect.DerbyDialect <init>
WARN: HHH000430: The DerbyDialect dialect has been deprecated; use one of the version-specific dialects instead
Mar 30, 2013 8:48:56 AM org.hibernate.engine.transaction.internal.TransactionFactoryInitiator initiateService
INFO: HHH000268: Transaction strategy: org.hibernate.engine.transaction.internal.jdbc.JdbcTransactionFactory
Mar 30, 2013 8:48:56 AM org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory <init>
INFO: HHH000397: Using ASTQueryTranslatorFactory
Hibernate: 
    select
        employee0_.id as id0_,
        employee0_.department_id as department3_0_,
        employee0_.name as name0_ 
    from
        Employee employee0_
Hibernate: 
    select
        department0_.id as id1_0_,
        department0_.name as name1_0_ 
    from
        Department department0_ 
    where
        department0_.id=?
Hibernate: 
    select
        employee0_.id as id0_,
        employee0_.department_id as department3_0_,
        employee0_.name as name0_ 
    from
        Employee employee0_
num of employess:2
next employee: Employee [id=3, name=Captain Nemo, department=java]
next employee: Employee [id=2, name=Jakab Gipsz, department=java]
.. done
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.995s
[INFO] Finished at: Sat Mar 30 08:48:57 CET 2013
[INFO] Final Memory: 10M/24M
[INFO] ------------------------------------------------------------------------
[dave@dave EclipseJPAExample]$ 

Add profiles for persistence providers into pom.xml
      <profile>
            <id>eclipselink</id>
            <activation>
                <activeByDefault>true</activeByDefault>
                <property>
                    <name>JPAProvider</name>
                    <value>eclipselink</value>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <executions>
<execution>
                                <phase>process-resources</phase>
                                <id>rename-persistence-file</id>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <tasks>
                                        <echo>Rename persistence-eclipselink.xml to persistence.xml</echo>
                                        <copy file="${basedir}/src/main/resources/META-INF/persistence-eclipselink.xml" tofile="${project.build.directory}/classes/META-INF/persistence.xml" overwrite="true" />
                                    </tasks>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
   


When run with -Peclipselink or -Phibernate following action is triggered
[INFO] Executing tasks
     [echo] Rename persistence-eclipselink.xml to persistence.xml
     [copy] Copying 1 file to /home/dave/workspace/EclipseJPAExample/target/classes/META-INF


Dependencies can be optional based on profile
EclipseLink is set as active profile by default
This will allow to run alternative unit tests for different JPA providers

[dave@dave EclipseJPAExample]$ mvn dependency::list
/usr/java//jdk1.7.0_13
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building EclipseJPAExample 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-dependency-plugin:2.1:list (default-cli) @ EclipseJPAExample ---
[INFO] 
[INFO] The following files have been resolved:
[INFO]    org.apache.derby:derby:jar:10.8.2.2:compile
[INFO]    org.apache.derby:derbytools:jar:10.8.2.2:compile
[INFO]    org.eclipse.persistence:eclipselink:jar:2.2.1:compile
[INFO]    org.eclipse.persistence:javax.persistence:jar:2.0.3:compile
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.506s
[INFO] Finished at: Sat Mar 30 09:23:06 CET 2013
[INFO] Final Memory: 6M/15M
[INFO] ------------------------------------------------------------------------
[dave@dave EclipseJPAExample]$ mvn dependency::list -Phibernate
/usr/java//jdk1.7.0_13
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building EclipseJPAExample 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-dependency-plugin:2.1:list (default-cli) @ EclipseJPAExample ---
[INFO] 
[INFO] The following files have been resolved:
[INFO]    antlr:antlr:jar:2.7.7:compile
[INFO]    commons-collections:commons-collections:jar:3.2.1:compile
[INFO]    dom4j:dom4j:jar:1.6.1:compile
[INFO]    org.apache.derby:derby:jar:10.8.2.2:compile
[INFO]    org.apache.derby:derbytools:jar:10.8.2.2:compile
[INFO]    org.hibernate:hibernate-core:jar:4.0.1.Final:compile
[INFO]    org.hibernate:hibernate-entitymanager:jar:4.0.1.Final:compile
[INFO]    org.hibernate.common:hibernate-commons-annotations:jar:4.0.1.Final:compile
[INFO]    org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.1.Final:compile
[INFO]    org.javassist:javassist:jar:3.15.0-GA:compile
[INFO]    org.jboss.logging:jboss-logging:jar:3.1.0.CR2:compile
[INFO]    org.jboss.spec.javax.transaction:jboss-transaction-api_1.1_spec:jar:1.0.0.Final:compile
[INFO]    xml-apis:xml-apis:jar:1.0.b2:compile
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.562s
[INFO] Finished at: Sat Mar 30 09:23:22 CET 2013
[INFO] Final Memory: 6M/15M
[INFO] ------------------------------

Modified pom.xml with dependencies inside profile
   <profiles>
        <profile>
            <id>hibernate</id>
            <activation>
                <activeByDefault>false</activeByDefault>
                <property>
                    <name>JPAProvider</name>
                    <value>hibernate</value>
                </property>
            </activation>
        <dependencies>
                <dependency>
                        <groupId>org.hibernate.javax.persistence</groupId>
                        <artifactId>hibernate-jpa-2.0-api</artifactId>
                        <version>1.0.1.Final</version>
                </dependency>
                <dependency>
                        <groupId>org.hibernate</groupId>
                        <artifactId>hibernate-entitymanager</artifactId>
                        <version>4.0.1.Final</version>
                </dependency>
        </dependencies>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <executions>
                            <execution>
 <phase>process-resources</phase>
                                <id>rename-persistence-file</id>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <tasks>
                                        <echo>Rename persistence-hibernate.xml to persistence.xml</echo>
                                        <copy file="${basedir}/src/main/resources/META-INF/persistence-hibernate.xml" tofile="${project.build.directory}/classes/META-INF/persistence.xml" overwrite="true" />
                                    </tasks>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>