Monday, January 18, 2016

Create Java EE7 project from JBoss Wildfly Maven archetype

JBoss Wildfly Maven plugin
https://docs.jboss.org/wildfly/plugins/maven/latest/index.html 

http://mvnrepository.com/artifact/org.wildfly.archetype/wildfly-javaee7-webapp-ear-archetype/8.2.0.Final

First try with Adam Bien's Minimalistic pom.xml
http://www.adam-bien.com/roller/abien/entry/setting_up_java_ee_7

[dave@localhost wildfly]$ mvn archetype:generate -Dfilter=com.airhacks:javaee7-essentials-archetype


Define value for property 'groupId': : dave
Define value for property 'artifactId': : dave-java-ee7-minimal
Define value for property 'version':  1.0-SNAPSHOT: : 
Define value for property 'package':  dave: : 
Confirm properties configuration:
groupId: dave
artifactId: dave-java-ee7-minimal
version: 1.0-SNAPSHOT
package: dave
 Y: : 
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Archetype: javaee7-essentials-archetype:1.3
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: dave
[INFO] Parameter: artifactId, Value: dave-java-ee7-minimal
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: package, Value: dave
[INFO] Parameter: packageInPathFormat, Value: dave
[INFO] Parameter: package, Value: dave
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: groupId, Value: dave
[INFO] Parameter: artifactId, Value: dave-java-ee7-minimal
[INFO] project created from Archetype in dir: /home/dave/git/wildfly/dave-java-ee7-minimal


Files created from Maven  archetype

[dave@localhost wildfly]$ find
.
./dave-java-ee7-minimal
./dave-java-ee7-minimal/pom.xml
./dave-java-ee7-minimal/src
./dave-java-ee7-minimal/src/main
./dave-java-ee7-minimal/src/main/webapp
./dave-java-ee7-minimal/src/main/webapp/WEB-INF
./dave-java-ee7-minimal/src/main/webapp/WEB-INF/beans.xml
./dave-java-ee7-minimal/src/main/resources
./dave-java-ee7-minimal/src/main/java
./dave-java-ee7-minimal/src/main/java/com
./dave-java-ee7-minimal/src/main/java/com/airhacks
./dave-java-ee7-minimal/src/main/java/com/airhacks/JAXRSConfiguration.java


Generated pom.xml


[dave@localhost dave-java-ee7-minimal]$ more pom.xml 
<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>dave</groupId>
    <artifactId>dave-java-ee7-minimal</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>
    <dependencies>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <version>7.0</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
    <build>
        <finalName>dave-java-ee7-minimal</finalName>
    </build>
    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <failOnMissingWebXml>false</failOnMissingWebXml>
    </properties>
</project>


Using Wildfly Maven archetype
https://docs.jboss.org/wildfly/plugins/maven/latest/index.html

[dave@localhost wildfly]$ mvn archetype:generate -Dfilter=wildfly-javaee7-webapp-ear-archetype


1: remote -> org.wildfly.archetype:wildfly-javaee7-webapp-ear-archetype (An archetype that generates a starter Java EE 7 webapp project for JBoss Wildfly. The project is an EAR, with an EJB-JAR and WAR)
Choose a number or apply filter (format: [groupId:]artifactId, case sensitive contains): : 
Choose archetype:
1: remote -> org.wildfly.archetype:wildfly-javaee7-webapp-ear-archetype (An archetype that generates a starter Java EE 7 webapp project for JBoss Wildfly. The project is an EAR, with an EJB-JAR and WAR)
Choose a number or apply filter (format: [groupId:]artifactId, case sensitive contains): : 1
Choose org.wildfly.archetype:wildfly-javaee7-webapp-ear-archetype version: 
1: 8.1.0.Final
2: 8.2.0.Final
Choose a number: 2: 2


Define value for property 'groupId': : dave
Define value for property 'artifactId': : dave-java-ee7-wildfly-full
Define value for property 'version':  1.0-SNAPSHOT: : 
Define value for property 'package':  dave: : 
Confirm properties configuration:
groupId: dave
artifactId: dave-java-ee7-wildfly-full
version: 1.0-SNAPSHOT
package: dave
 Y: : 
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Archetype: wildfly-javaee7-webapp-ear-archetype:8.2.0.Final
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: dave
[INFO] Parameter: artifactId, Value: dave-java-ee7-wildfly-full
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: package, Value: dave
[INFO] Parameter: packageInPathFormat, Value: dave
[INFO] Parameter: package, Value: dave
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: groupId, Value: dave
[INFO] Parameter: artifactId, Value: dave-java-ee7-wildfly-full
[INFO] Parent element not overwritten in /home/dave/git/wildfly/dave-java-ee7-wildfly-full/dave-java-ee7-wildfly-full-ejb/pom.xml
[INFO] Parent element not overwritten in /home/dave/git/wildfly/dave-java-ee7-wildfly-full/dave-java-ee7-wildfly-full-web/pom.xml
[WARNING] CP Don't override file /home/dave/git/wildfly/dave-java-ee7-wildfly-full/dave-java-ee7-wildfly-full-web/src/main/webapp/WEB-INF/templates/default.xhtml
[INFO] Parent element not overwritten in /home/dave/git/wildfly/dave-java-ee7-wildfly-full/dave-java-ee7-wildfly-full-ear/pom.xml
[INFO] project created from Archetype in dir: /home/dave/git/wildfly/dave-java-ee7-wildfly-full


[dave@localhost dave-java-ee7-wildfly-full]$ find
.
./pom.xml
./README.md
./dave-java-ee7-wildfly-full-ear
./dave-java-ee7-wildfly-full-ear/pom.xml
./dave-java-ee7-wildfly-full-ear/src
./dave-java-ee7-wildfly-full-ear/src/main
./dave-java-ee7-wildfly-full-ear/src/main/application
./dave-java-ee7-wildfly-full-ear/src/main/application/META-INF
./dave-java-ee7-wildfly-full-ear/src/main/application/META-INF/dave-java-ee7-wildfly-full-ds.xml
./dave-java-ee7-wildfly-full-ejb
./dave-java-ee7-wildfly-full-ejb/pom.xml
./dave-java-ee7-wildfly-full-ejb/src
./dave-java-ee7-wildfly-full-ejb/src/main
./dave-java-ee7-wildfly-full-ejb/src/main/resources
./dave-java-ee7-wildfly-full-ejb/src/main/resources/import.sql
./dave-java-ee7-wildfly-full-ejb/src/main/resources/META-INF
./dave-java-ee7-wildfly-full-ejb/src/main/resources/META-INF/persistence.xml
./dave-java-ee7-wildfly-full-ejb/src/main/resources/META-INF/beans.xml
./dave-java-ee7-wildfly-full-ejb/src/main/java
./dave-java-ee7-wildfly-full-ejb/src/main/java/dave
./dave-java-ee7-wildfly-full-ejb/src/main/java/dave/model
./dave-java-ee7-wildfly-full-ejb/src/main/java/dave/model/Member.java
./dave-java-ee7-wildfly-full-ejb/src/main/java/dave/service
./dave-java-ee7-wildfly-full-ejb/src/main/java/dave/service/MemberRegistration.java
./dave-java-ee7-wildfly-full-ejb/src/main/java/dave/data
./dave-java-ee7-wildfly-full-ejb/src/main/java/dave/data/MemberListProducer.java
./dave-java-ee7-wildfly-full-ejb/src/main/java/dave/data/MemberRepository.java
./dave-java-ee7-wildfly-full-ejb/src/main/java/dave/util
./dave-java-ee7-wildfly-full-ejb/src/main/java/dave/util/Resources.java
./dave-java-ee7-wildfly-full-ejb/src/test
./dave-java-ee7-wildfly-full-ejb/src/test/resources
./dave-java-ee7-wildfly-full-ejb/src/test/resources/arquillian.xml
./dave-java-ee7-wildfly-full-ejb/src/test/resources/META-INF
./dave-java-ee7-wildfly-full-ejb/src/test/resources/META-INF/test-persistence.xml
./dave-java-ee7-wildfly-full-ejb/src/test/resources/test-ds.xml
./dave-java-ee7-wildfly-full-ejb/src/test/java
./dave-java-ee7-wildfly-full-ejb/src/test/java/dave
./dave-java-ee7-wildfly-full-ejb/src/test/java/dave/test
./dave-java-ee7-wildfly-full-ejb/src/test/java/dave/test/MemberRegistrationTest.java
./dave-java-ee7-wildfly-full-web
./dave-java-ee7-wildfly-full-web/pom.xml
./dave-java-ee7-wildfly-full-web/src
./dave-java-ee7-wildfly-full-web/src/main
./dave-java-ee7-wildfly-full-web/src/main/webapp
./dave-java-ee7-wildfly-full-web/src/main/webapp/resources
./dave-java-ee7-wildfly-full-web/src/main/webapp/resources/css
./dave-java-ee7-wildfly-full-web/src/main/webapp/resources/css/screen.css
./dave-java-ee7-wildfly-full-web/src/main/webapp/resources/gfx
./dave-java-ee7-wildfly-full-web/src/main/webapp/resources/gfx/asidebkg.png
./dave-java-ee7-wildfly-full-web/src/main/webapp/resources/gfx/dualbrand_logo.png
./dave-java-ee7-wildfly-full-web/src/main/webapp/resources/gfx/bkg-blkheader.png
./dave-java-ee7-wildfly-full-web/src/main/webapp/resources/gfx/wildfly_400x130.jpg
./dave-java-ee7-wildfly-full-web/src/main/webapp/resources/gfx/headerbkg.png
./dave-java-ee7-wildfly-full-web/src/main/webapp/index.xhtml
./dave-java-ee7-wildfly-full-web/src/main/webapp/index.html
./dave-java-ee7-wildfly-full-web/src/main/webapp/WEB-INF
./dave-java-ee7-wildfly-full-web/src/main/webapp/WEB-INF/templates
./dave-java-ee7-wildfly-full-web/src/main/webapp/WEB-INF/templates/default.xhtml
./dave-java-ee7-wildfly-full-web/src/main/webapp/WEB-INF/faces-config.xml
./dave-java-ee7-wildfly-full-web/src/main/webapp/WEB-INF/beans.xml
./dave-java-ee7-wildfly-full-web/src/main/java
./dave-java-ee7-wildfly-full-web/src/main/java/dave
./dave-java-ee7-wildfly-full-web/src/main/java/dave/controller
./dave-java-ee7-wildfly-full-web/src/main/java/dave/controller/MemberController.java
./dave-java-ee7-wildfly-full-web/src/main/java/dave/util
./dave-java-ee7-wildfly-full-web/src/main/java/dave/util/WebResources.java
./dave-java-ee7-wildfly-full-web/src/main/java/dave/rest
./dave-java-ee7-wildfly-full-web/src/main/java/dave/rest/MemberResourceRESTService.java
./dave-java-ee7-wildfly-full-web/src/main/java/dave/rest/JaxRsActivator.java
./dave-java-ee7-wildfly-full-web/src/test
./dave-java-ee7-wildfly-full-web/src/test/java


Generated pom.xml
[dave@localhost dave-java-ee7-wildfly-full]$ more pom.xml 
<?xml version="1.0" encoding="UTF-8"?>
<!--
    JBoss, Home of Professional Open Source
    Copyright 2013, Red Hat, Inc. and/or its affiliates, and individual
    contributors by the @authors tag. See the copyright.txt in the
    distribution for a full listing of individual contributors.

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at
    http://www.apache.org/licenses/LICENSE-2.0
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-->
<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/maven-v4_0_0.xsd">
    <name>dave-java-ee7-wildfly-full</name>
    <modelVersion>4.0.0</modelVersion>
    <groupId>dave</groupId>
    <artifactId>dave-java-ee7-wildfly-full</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>pom</packaging>

    <url>http://wildfly.org</url>
    <licenses>
        <license>
            <name>Apache License, Version 2.0</name>
            <distribution>repo</distribution>
            <url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
        </license>
    </licenses>
    <modules>
        <module>dave-java-ee7-wildfly-full-ejb</module>
        <module>dave-java-ee7-wildfly-full-web</module>
        <module>dave-java-ee7-wildfly-full-ear</module>
    </modules>

    <properties>
        <!-- Explicitly declaring the source encoding eliminates the following 
            message: -->
        <!-- [WARNING] Using platform encoding (UTF-8 actually) to copy filtered 
            resources, i.e. build is platform dependent! -->
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

        <!-- JBoss dependency versions -->
        
        <version.wildfly.maven.plugin>1.0.2.Final</version.wildfly.maven.plugin>

        <!-- Define the version of the JBoss BOMs we want to import to specify tested stacks. -->
        <version.jboss.bom>8.2.1.Final</version.jboss.bom>
        <version.wildfly>9.0.0.Alpha1</version.wildfly>


        <!-- other plugin versions -->
        <version.compiler.plugin>3.1</version.compiler.plugin>
        <version.ear.plugin>2.10</version.ear.plugin>
        <version.ejb.plugin>2.3</version.ejb.plugin>
        <version.surefire.plugin>2.16</version.surefire.plugin>
        <version.war.plugin>2.5</version.war.plugin>

        <!-- maven-compiler-plugin -->
        <maven.compiler.target>1.7</maven.compiler.target>
        <maven.compiler.source>1.7</maven.compiler.source>
    </properties>

    <dependencyManagement>
        <dependencies>

            <!-- Define the version of the EJB jar so that we don't need 
                to repeat ourselves in every module -->
            <dependency>
                <groupId>dave</groupId>
                <artifactId>dave-java-ee7-wildfly-full-ejb</artifactId>
                <version>${project.version}</version>
                <type>ejb</type>
            </dependency>
            
            <!-- Define the version of the WAR so that we don't need to repeat 
                ourselves in every module -->
            <dependency>
                <groupId>dave</groupId>
                <artifactId>dave-java-ee7-wildfly-full-web</artifactId>
                <version>${project.version}</version>
                <type>war</type>
                <scope>compile</scope>
            </dependency>

            <!-- JBoss distributes a complete set of Java EE 7 APIs including
                a Bill of Materials (BOM). A BOM specifies the versions of a "stack" (or 
                a collection) of artifacts. We use this here so that we always get the correct 
                versions of artifacts. Here we use the jboss-javaee-7.0-with-tools stack
                (you can read this as the JBoss stack of the Java EE 7 APIs, with some extras
                tools for your project, such as Arquillian for testing) and the jboss-javaee-7.0-with-hibernate
                stack you can read this as the JBoss stack of the Java EE 7 APIs, with extras
                from the Hibernate family of projects) -->
            <dependency>
                <groupId>org.wildfly.bom</groupId>
                <artifactId>jboss-javaee-7.0-with-tools</artifactId>
                <version>${version.jboss.bom}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

            <dependency>
                <groupId>org.wildfly.bom</groupId>
                <artifactId>jboss-javaee-7.0-with-hibernate</artifactId>
                <version>${version.jboss.bom}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

        </dependencies>
    </dependencyManagement>

    <build>
        <pluginManagement>
            <plugins>
                <!-- The WildFly plugin deploys your ear to a local JBoss
                    AS container -->
                <!-- Due to Maven's lack of intelligence with EARs we need 
                    to configure the wildfly maven plugin to skip deployment for all modules.
                    We then enable it specifically in the ear module. -->
                <plugin>
                    <groupId>org.wildfly.plugins</groupId>
                    <artifactId>wildfly-maven-plugin</artifactId>
                    <version>${version.wildfly.maven.plugin}</version>
                    <inherited>true</inherited>
                    <configuration>
                        <skip>true</skip>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

</project>


Download latest Wildfly AS here http://wildfly.org/downloads/

Deploy application to Wildfly using wildfly:deploy

mvn clean package wildfly:deploy


Access application using URL http://localhost:8080/dave-java-ee7-wildfly-full-web.


Using Maven to create EJB project on Weblogic 12.2.1

First setup Maven for Oracle Weblogic plugin - http://danielveselka.blogspot.com/2016/01/using-maven-on-weblogic-1221-with-java.html 

Building Java EE Projects for WebLogic Server with Maven

http://docs.oracle.com/middleware/1221/core/MAVEN/weblogic_maven.htm#MAVEN8803

Create project from archetype
[dave@localhost weblogic]$ mvn archetype:generate -DarchetypeGroupId=com.oracle.weblogic.archetype -DarchetypeArtifactId=basic-webapp-ejb -DarchetypeVersion=12.2.1-0-0 -DgroupId=dave -DartifactId=dave-basic-webapp-ejb-project -Dversion=1.0-SNAPSHOT

Generated code
https://github.com/dveselka/weblogic

[INFO] Generating project in Interactive mode
[INFO] Archetype repository missing. Using the one from [com.oracle.weblogic.archetype:basic-webapp-ejb:12.2.1-0-0] found in catalog local
[INFO] Using property: groupId = dave
[INFO] Using property: artifactId = dave-basic-webapp-ejb-project
[INFO] Using property: version = 1.0-SNAPSHOT
[INFO] Using property: package = dave
Confirm properties configuration:
groupId: dave
artifactId: dave-basic-webapp-ejb-project
version: 1.0-SNAPSHOT
package: dave
 Y: : 
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Archetype: basic-webapp-ejb:12.2.1-0-0
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: dave
[INFO] Parameter: artifactId, Value: dave-basic-webapp-ejb-project
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: package, Value: dave
[INFO] Parameter: packageInPathFormat, Value: dave
[INFO] Parameter: package, Value: dave
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: groupId, Value: dave
[INFO] Parameter: artifactId, Value: dave-basic-webapp-ejb-project
[INFO] project created from Archetype in dir: /home/dave/git/weblogic/dave-basic-webapp-ejb-project



[dave@localhost weblogic]$ find
.
./dave-basic-webapp-ejb-project
./dave-basic-webapp-ejb-project/pom.xml
./dave-basic-webapp-ejb-project/src
./dave-basic-webapp-ejb-project/src/main
./dave-basic-webapp-ejb-project/src/main/webapp
./dave-basic-webapp-ejb-project/src/main/webapp/css
./dave-basic-webapp-ejb-project/src/main/webapp/css/bootstrap.css
./dave-basic-webapp-ejb-project/src/main/webapp/index.xhtml
./dave-basic-webapp-ejb-project/src/main/webapp/WEB-INF
./dave-basic-webapp-ejb-project/src/main/webapp/WEB-INF/web.xml
./dave-basic-webapp-ejb-project/src/main/webapp/WEB-INF/beans.xml
./dave-basic-webapp-ejb-project/src/main/webapp/template.xhtml
./dave-basic-webapp-ejb-project/src/main/resources
./dave-basic-webapp-ejb-project/src/main/resources/META-INF
./dave-basic-webapp-ejb-project/src/main/resources/META-INF/persistence.xml
./dave-basic-webapp-ejb-project/src/main/java
./dave-basic-webapp-ejb-project/src/main/java/dave
./dave-basic-webapp-ejb-project/src/main/java/dave/entity
./dave-basic-webapp-ejb-project/src/main/java/dave/entity/Account.java
./dave-basic-webapp-ejb-project/src/main/java/dave/service
./dave-basic-webapp-ejb-project/src/main/java/dave/service/AccountManagerImpl.java
./dave-basic-webapp-ejb-project/src/main/java/dave/service/AccountManager.java
./dave-basic-webapp-ejb-project/src/main/java/dave/service/AccountBean.java
./dave-basic-webapp-ejb-project/src/main/java/dave/interceptor
./dave-basic-webapp-ejb-project/src/main/java/dave/interceptor/OnDeposit.java
./dave-basic-webapp-ejb-project/src/main/java/dave/interceptor/LogInterceptor.java
./dave-basic-webapp-ejb-project/src/main/scripts
./dave-basic-webapp-project
./dave-basic-webapp-project/pom.xml
./dave-basic-webapp-project/src
./dave-basic-webapp-project/src/main
./dave-basic-webapp-project/src/main/webapp
./dave-basic-webapp-project/src/main/webapp/css
./dave-basic-webapp-project/src/main/webapp/css/bootstrap.css
./dave-basic-webapp-project/src/main/webapp/index.xhtml
./dave-basic-webapp-project/src/main/webapp/WEB-INF
./dave-basic-webapp-project/src/main/webapp/WEB-INF/web.xml
./dave-basic-webapp-project/src/main/webapp/WEB-INF/beans.xml
./dave-basic-webapp-project/src/main/webapp/template.xhtml
./dave-basic-webapp-project/src/main/java
./dave-basic-webapp-project/src/main/java/dave
./dave-basic-webapp-project/src/main/java/dave/AccountBean.java

Code generated from Maven archetype is here https://bitbucket.org/daniel_veselka/weblogic

Start Weblogic console using http://localhost:7001/console/

Check what is the Context Root in Deployments section:  /basicWebappEjb

Connect to application using http://localhost:7001/basicWebappEjb/

Sunday, January 17, 2016

Using Maven on Weblogic 12.2.1.2 with Java EE7

HOWTO
 

wls-maven-plugin deprecated 


The wls-maven-plugin plug-in delivered in WebLogic Server 11g Release 1 is deprecated as of release 12.1.2. Oracle recommends that you instead use the WebLogic Server Maven plug-in introduced in version 12.1.2. See "Using the WebLogic Development Maven Plug-in" in Developing Applications for Oracle WebLogic Server for complete documentation.


Configuring the WebLogic Maven Plug-In

 
Change directory to Maven plugin in WLS12.2.1.2 installation 
Install the Oracle Maven sync plug-in


[dave@localhost weblogic-12.2.1]$ find . -name   oracle*maven-*.jar
./oracle_common/plugins/maven/com/oracle/maven/oracle-maven-sync/12.2.1/oracle-maven-sync-12.2.1.jar
[dave@localhost weblogic-12.2.1]$ cd ./oracle_common/plugins/maven/com/oracle/maven/oracle-maven-sync/12.2.1
[dave@localhost 12.2.1]$ mvn install:install-file -DpomFile=oracle-maven-sync-12.2.1.pom -Dfile=oracle-maven-sync-12.2.1.jar


Install Oracle Maven jars into local repository


mvn com.oracle.maven:oracle-maven-sync:push -DoracleHome=/app/weblogic-12.2.1/

Validate Maven artifact are properly installed
mvn help:describe -DgroupId=com.oracle.weblogic -DartifactId=weblogic-maven-plugin -Dversion=12.2.1-2-0

Name: weblogic-maven-plugin
Description: The Oracle WebLogic Server 12.2.1 Maven plugin
Group Id: com.oracle.weblogic
Artifact Id: weblogic-maven-plugin
Version: 12.2.1-2-0
Goal Prefix: weblogic

This plugin has 23 goals:

weblogic:appc
  Description: This goal is a wrapper for the weblogic.appc compiler.

weblogic:create-domain
  Description: Create a domain for WebLogic Server using the default domain
    template. For more complex domain creation use the WLST goal. Note:
    Starting in WLS 12.2.1, there is a single unified version of WLST that
    automatically includes the WLST environment from all products in the
    ORACLE_HOME.

weblogic:deploy
  Description: Deploys an application to WebLogic Server (supports all
    formats WAR, JAR, RAR, EAR, etc.)

weblogic:distribute-app
  Description: Prepares deployment files for deployment by copying deployment
    files to target servers and validating them.

weblogic:install
  Description: Installs WebLogic Server

weblogic:list-apps
  Description: Lists the deployment names for applications and stand-alone
    modules deployed distributed, or installed to the domain

weblogic:purge-tasks
  Description: Flushes out retired deployment tasks

weblogic:redeploy
  Description: Redeploys a running application or part of a running
    application

weblogic:remove-domain
  Description: This class provides basic capabilities to remove a domain
    directory.

weblogic:start-app
  Description: Starts an application

weblogic:start-server
  Description: Starts WebLogic Server.

weblogic:stop-app
  Description: Stops an application

weblogic:stop-server
  Description: This goals run a stop script to stop WebLogic Server.

weblogic:undeploy
  Description: Stops the deployment unit and removes staged files from target
    servers

weblogic:uninstall
  Description: Uninstalls WebLogic Server

weblogic:update-app
  Description: Updates an application's deployment plan by redistributing the
    plan files and reconfiguring the application based on the new plan
    contents.

weblogic:wlst
  Description: This goal is a wrapper for the WLST scripting tool.
    Note: Starting in WLS 12.2.1, there is a single unified version of WLST
    that automatically includes the WLST environment from all products in the
    ORACLE_HOME.

weblogic:wlst-client
  Description: WLST wrapper for Maven that does not require a server install
    for WLST online commands.

weblogic:ws-clientgen
  Description: A Maven goal to generate client web service artifacts from a
    WSDL Note the differences between clientgen Ant task and Maven goal:
    clientgen goal only generates JAXWS web service artifacts, while Ant task
    has JAXRPC as the default. At the moment there is no way to direct
    clientgen goal to also compile and package generated artifacts.
  Deprecated. No reason given

weblogic:ws-jwsc
  Description: This goal builds a JAX-WS web service, generates source code,
    data binding artifacts, deployment descriptors, and so on into an output
    directory.
  Deprecated. No reason given

weblogic:ws-wsdlc
  Description: This goal generates, from an existing WSDL file, a set of
    artifacts that together provide a partial Java implementation of the Web
    Service described by the WSDL file.
  Deprecated. No reason given

weblogic:wsgen
  Description: Reads a JAX-WS service endpoint implementation class and
    generates all of the portable artifacts for a JAX-WS web service.

weblogic:wsimport
  Description: Parses wsdl and binding files and generates Java code needed
    to access it.

For more information, run 'mvn help:describe [...] -Ddetail'


Building Java EE Projects for WebLogic Server with Maven



 Create app from Maven archetype
Choose one of following:
11: local -> com.oracle.weblogic.archetype:basic-mdb (basicMDB)
12: local -> com.oracle.weblogic.archetype:basic-websocket-emulation (cdi)
13: local -> com.oracle.weblogic.archetype:basic-websocket (cdi)
14: local -> com.oracle.weblogic.archetype:basic-serversentevent (cdi)
15: local -> com.oracle.weblogic.archetype:basic-webapp (basicJsf)
16: local -> com.oracle.weblogic.archetype:basic-webservice (basicWebservice)
17: local -> com.oracle.weblogic.archetype:basic-webapp-ejb (cdi)

 
[dave@localhost weblogic]$ mvn archetype:generate -DarchetypeGroupId=com.oracle.weblogic.archetype -DarchetypeArtifactId=basic-webapp -DarchetypeVersion=12.2.1-2-0 -DgroupId=dave -DartifactId=dave-basic-webapp-project -Dversion=1.0-SNAPSHOT
[INFO] Using property: groupId = dave
[INFO] Using property: artifactId = dave-basic-webapp-project
[INFO] Using property: version = 1.0-SNAPSHOT
[INFO] Using property: package = dave
Confirm properties configuration:
groupId: dave
artifactId: dave-basic-webapp-project
version: 1.0-SNAPSHOT
package: dave
 Y: : 
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Archetype: basic-webapp:12.2.1-0-0
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: dave
[INFO] Parameter: artifactId, Value: dave-basic-webapp-project
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: package, Value: dave
[INFO] Parameter: packageInPathFormat, Value: dave
[INFO] Parameter: package, Value: dave
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: groupId, Value: dave
[INFO] Parameter: artifactId, Value: dave-basic-webapp-project
[INFO] project created from Archetype in dir: /home/dave/git/weblogic/dave-basic-webapp-project
[dave@localhost weblogic]$ find
.
./dave-basic-webapp-project
./dave-basic-webapp-project/pom.xml
./dave-basic-webapp-project/src
./dave-basic-webapp-project/src/main
./dave-basic-webapp-project/src/main/webapp
./dave-basic-webapp-project/src/main/webapp/css
./dave-basic-webapp-project/src/main/webapp/css/bootstrap.css
./dave-basic-webapp-project/src/main/webapp/index.xhtml
./dave-basic-webapp-project/src/main/webapp/WEB-INF
./dave-basic-webapp-project/src/main/webapp/WEB-INF/web.xml
./dave-basic-webapp-project/src/main/webapp/WEB-INF/beans.xml
./dave-basic-webapp-project/src/main/webapp/template.xhtml
./dave-basic-webapp-project/src/main/java
./dave-basic-webapp-project/src/main/java/dave
./dave-basic-webapp-project/src/main/java/dave/AccountBean.java


 Main pom.xml
[dave@localhost dave-basic-webapp-project]$ more pom.xml 
<?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>dave</groupId>
  <artifactId>dave-basic-webapp-project</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>war</packaging>
  <name>basicWebapp</name>
[dave@localhost dave-basic-webapp-project]$ more pom.xml 
<?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>dave</groupId>
  <artifactId>dave-basic-webapp-project</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>war</packaging>
  <name>basicWebapp</name>
 
  <parent>
    <groupId>com.oracle.weblogic.archetype</groupId>
    <artifactId>wls-common</artifactId>
    <version>12.2.1-0-0</version>
  </parent>
  <dependencies>
    <dependency>
      <groupId>javax</groupId>
      <artifactId>javaee-web-api</artifactId>
      <version>6.0</version>
      <scope>provided</scope>
    </dependency>
  </dependencies>
  <build>
    <finalName>basicWebapp</finalName>
    <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-war-plugin</artifactId>
        <version>2.1.1</version>
        <configuration>
          <failOnMissingWebXml>false</failOnMissingWebXml>
        </configuration>
      </plugin>
      <plugin>
        <groupId>com.oracle.weblogic</groupId> 
        <artifactId>weblogic-maven-plugin</artifactId> 
        <version>12.2.1-0-0</version> 
        <!--
        You can find and redefine the following variables in the parent pom file arccording to your environment.
  
        oracleMiddlewareHome
        oracleServerUrl
        oracleUsername
        oraclePassword
        oracleServerName
        -->
        <configuration> 
          <middlewareHome>${oracleMiddlewareHome}</middlewareHome>
        </configuration> 
        <executions>
          <!--Deploy the application to the server-->
          <execution>
            <phase>pre-integration-test</phase> 
            <goals> 
              <goal>deploy</goal> 
            </goals>
            <configuration> 
              <!--The admin URL where the app is deployed. Here use the plugin's default value t3://localhost:7001-->
              <!--adminurl>${oracleServerUrl}</adminurl-->
              <user>${oracleUsername}</user> 
              <password>${oraclePassword}</password>
              <!--The location of the file or directory to be deployed-->
              <source>${project.build.directory}/${project.build.finalName}.${project.packaging}</source>
              <!--The target servers where the application is deployed. Here use the plugin's default value AdminServer-->
              <!--targets>${oracleServerName}</targets-->
              <verbose>true</verbose> 
              <name>${project.build.finalName}</name>
            </configuration> 
          </execution> 
        </executions>
      </plugin>
    </plugins>
  </build>
</project>



mvn compile

mvn package



mvn package 


INFO] Packaging webapp
[INFO] Assembling webapp [dave-basic-webapp-project] in [/home/dave/git/weblogic/dave-basic-webapp-project/target/basicWebapp]
[INFO] Processing war project
[INFO] Copying webapp resources [/home/dave/git/weblogic/dave-basic-webapp-project/src/main/webapp]
[INFO] Webapp assembled in [69 msecs]
[INFO] Building war: /home/dave/git/weblogic/dave-basic-webapp-project/target/basicWebapp.war
[INFO] WEB-INF/web.xml already added, skipping




Edit  in pom.xml ( or settings.xml ) weblogic username and password to be able to deploy
ERROR] Failed to execute goal com.oracle.weblogic:weblogic-maven-plugin:12.2.1-0-0:deploy (default) on project dave-basic-webapp-project: org.apache.maven.plugin.MojoExecutionException: user/password or userConfigFile/userKeyFile must be specified

To deploy the deployment archive using Maven, use the following command:

mvn pre-integration-test


[INFO] Packaging webapp
[INFO] Assembling webapp [dave-basic-webapp-project] in [/home/dave/git/weblogic/dave-basic-webapp-project/target/basicWebapp]
[INFO] Processing war project
[INFO] Copying webapp resources [/home/dave/git/weblogic/dave-basic-webapp-project/src/main/webapp]
[INFO] Webapp assembled in [31 msecs]
[INFO] Building war: /home/dave/git/weblogic/dave-basic-webapp-project/target/basicWebapp.war
[INFO] WEB-INF/web.xml already added, skipping
[INFO] 
[INFO] --- weblogic-maven-plugin:12.2.1-0-0:deploy (default) @ dave-basic-webapp-project ---
[INFO] Command flags are: -noexit -deploy -username weblogic -password ******* -name basicWebapp -source /home/dave/git/weblogic/dave-basic-webapp-project/target/basicWebapp.war -verbose -adminurl t3://localhost:7001
weblogic.Deployer invoked with options:  -noexit -deploy -username weblogic -name basicWebapp -source /home/dave/git/weblogic/dave-basic-webapp-project/target/basicWebapp.war -verbose -adminurl t3://localhost:7001
<Jan 17, 2016 12:52:54 PM CET> <Info> <J2EE Deployment SPI> <BEA-260121> <Initiating deploy operation for application, basicWebapp [archive: /home/dave/git/weblogic/dave-basic-webapp-project/target/basicWebapp.war], to configured targets.> 
Task 0 initiated: [Deployer:149026]deploy application basicWebapp on AdminServer.
Task 0 completed: [Deployer:149026]deploy application basicWebapp on AdminServer.
Target state: deploy completed on Server AdminServer


Start Weblogic console http://localhost:7001/console

Check the the WebApp Context Root: in Deployments

Start application in the browser using http://localhost:7001/basicWebapp/


If you Maven repository issues add artifacts into local Maven repository - see the HOWTO here for details http://middlewaremagic.com/weblogic/?p=8294

[dave@localhost 12.2.1]$ export M2_REPO=/home/dave/.m2/repository
[dave@localhost 12.2.1]$ mvn deploy:deploy-file -DpomFile=oracle-maven-sync-12.2.1.pom -Dfile=oracle-maven-sync-12.2.1.jar -Durl=file://${M2_REPO}

dave@localhost 12.2.1]$ mvn com.oracle.maven:oracle-maven-sync:12.2.1-0-0:push -Doracle-maven-sync.oracleHome=$MW_HOME -DtestingOnly=false

mvn archetype:crawl -Dcatalog=$HOME/.m2/archetype-catalog.xml




Friday, January 8, 2016

Weblogic 12.2.1 - Java EE 7 installation

Java EE 7 - Tested Configurations,  Oracle Weblogic Server 12.2.1

http://www.oracle.com/technetwork/java/javaee/overview/oracleweblogic1211-2769862.html

Oracle WebLogic Server (WLS) 12cR2 (12.2.1) Installation Guide

https://oracle-base.com/articles/12c/weblogic-installation-on-oracle-linux-6-and-7-1221

Using 64 bit Java SE 8
[dave@localhost app]$ java -version
java version "1.8.0_66"
Java(TM) SE Runtime Environment (build 1.8.0_66-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.66-b17, mixed mode)

Running generic installer
[dave@localhost app]$ java -jar fmw_12.2.1.0.0_wls.jar 
Launcher log file is /tmp/OraInstall2016-01-08_07-28-44AM/launcher2016-01-08_07-28-44AM.log.


Checking requirements
Starting Oracle Universal Installer

Checking if CPU speed is above 300 MHz.   Actual 2900.000 MHz    Passed
Checking monitor: must be configured to display at least 256 colors.   Actual 16777216    Passed
Checking swap space: must be greater than 512 MB.   Actual 3855 MB    Passed
Checking if this platform requires a 64-bit JVM.   Actual 64    Passed (64-bit not required)
Checking temp space: must be greater than 300 MB.   Actual 1123 MB    Passed


Preparing to launch the Oracle Universal Installer from /tmp/OraInstall2016-01-08_07-28-44AM


Select installation home












Create domain
[dave@localhost bin]$ pwd
/app/weblogic-12.2.1/oracle_common/common/bin
[dave@localhost bin]$ ./config.sh

Start created domain
[dave@localhost bin]$ pwd
/app/domains/base_domain/bin
[dave@localhost bin]$ ./startWebLogic.sh 


Admin server log
[dave@localhost bin]$ ./startWebLogic.sh 
.
.
JAVA Memory arguments: -Xms256m -Xmx512m -XX:CompileThreshold=8000
.
CLASSPATH=/usr/java/jdk1.8.0_66/lib/tools.jar:/home/app/weblogic-12.2.1/wlserver/server/lib/weblogic.jar:/home/app/weblogic-12.2.1/wlserver/../oracle_common/modules/net.sf.antcontrib_1.1.0.0_1-0b3/lib/ant-contrib.jar:/home/app/weblogic-12.2.1/wlserver/modules/features/oracle.wls.common.nodemanager.jar:/home/app/weblogic-12.2.1/wlserver/../oracle_common/modules/com.oracle.cie.config-wls-online_8.2.0.0.jar::/home/app/weblogic-12.2.1/wlserver/common/derby/lib/derbynet.jar:/home/app/weblogic-12.2.1/wlserver/common/derby/lib/derbyclient.jar:/home/app/weblogic-12.2.1/wlserver/common/derby/lib/derby.jar:.:/app/antlr-4.4-complete.jar:
.
PATH=/app/domains/base_domain/bin:/home/app/weblogic-12.2.1/wlserver/server/bin:/home/app/weblogic-12.2.1/wlserver/../oracle_common/modules/org.apache.ant_1.9.2/bin:/usr/java/jdk1.8.0_66/jre/bin:/usr/java/jdk1.8.0_66/bin:/usr/java/jdk1.8.0_66/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/home/dave/.local/bin:/home/dave/bin
.
***************************************************
*  To start WebLogic Server, use a username and   *
*  password assigned to an admin-level user.  For *
*  server administration, use the WebLogic Server *
*  console at http://hostname:port/console        *
***************************************************
Starting WLS with line:
/usr/java/jdk1.8.0_66/bin/java -server   -Xms256m -Xmx512m -XX:CompileThreshold=8000 -Dweblogic.Name=AdminServer -Djava.security.policy=/home/app/weblogic-12.2.1/wlserver/server/lib/weblogic.policy  -Xverify:none -Djava.system.class.loader=com.oracle.classloader.weblogic.LaunchClassLoader  -javaagent:/home/app/weblogic-12.2.1/wlserver/server/lib/debugpatch-agent.jar -da -Dwls.home=/home/app/weblogic-12.2.1/wlserver/server -Dweblogic.home=/home/app/weblogic-12.2.1/wlserver/server      weblogic.Server
<Jan 8, 2016 8:00:47 AM CET> <Info> <Security> <BEA-090905> <Disabling the CryptoJ JCE Provider self-integrity check for better startup performance. To enable this check, specify -Dweblogic.security.allowCryptoJDefaultJCEVerification=true.> 
<Jan 8, 2016 8:00:47 AM CET> <Info> <Security> <BEA-090906> <Changing the default Random Number Generator in RSA CryptoJ from ECDRBG128 to HMACDRBG. To disable this change, specify -Dweblogic.security.allowCryptoJDefaultPRNG=true.> 
<Jan 8, 2016 8:00:48 AM CET> <Info> <WebLogicServer> <BEA-000377> <Starting WebLogic Server with Java HotSpot(TM) 64-Bit Server VM Version 25.66-b17 from Oracle Corporation.> 
<Jan 8, 2016 8:00:48 AM CET> <Info> <RCM> <BEA-2165021> <"ResourceManagement" is not enabled in this JVM. Enable "ResourceManagement" to use the WebLogic Server "Resource Consumption Management" feature. To enable "ResourceManagement", you must specify the following JVM options in the WebLogic Server instance in which the JVM runs: -XX:+UnlockCommercialFeatures -XX:+ResourceManagement.> 
<Jan 8, 2016 8:00:49 AM CET> <Info> <Management> <BEA-141107> <Version: WebLogic Server 12.2.1.0.0 Tue Oct  6 10:05:47 PDT 2015 1721936> 
<Jan 8, 2016 8:00:51 AM CET> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to STARTING.> 
<Jan 8, 2016 8:00:51 AM CET> <Info> <WorkManager> <BEA-002900> <Initializing self-tuning thread pool.> 
<Jan 8, 2016 8:00:51 AM CET> <Info> <WorkManager> <BEA-002942> <CMM memory level becomes 0. Setting standby thread pool size to 256.> 
<Jan 8, 2016 8:00:53 AM CET> <Notice> <Log Management> <BEA-170019> <The server log file weblogic.logging.FileStreamHandler instance=2056123022
Current log file=/home/app/domains/base_domain/servers/AdminServer/logs/AdminServer.log
Rotation dir=/home/app/domains/base_domain/servers/AdminServer/logs
 is opened. All server side log events will be written to this file.> 
<Jan 8, 2016 8:00:53 AM CET> <Notice> <Security> <BEA-090946> <Security pre-initializing using security realm: myrealm> 
<Jan 8, 2016 8:00:56 AM CET> <Notice> <Security> <BEA-090947> <Security post-initializing using security realm: myrealm> 
<Jan 8, 2016 8:00:57 AM CET> <Notice> <Security> <BEA-090082> <Security initialized using administrative security realm: myrealm> 
<Jan 8, 2016 8:01:05 AM CET> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to STANDBY.> 
<Jan 8, 2016 8:01:05 AM CET> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to STARTING.> 
<Jan 8, 2016 8:01:05 AM CET> <Notice> <Log Management> <BEA-170036> <The Logging monitoring service timer has started to check for logged message counts every 30 seconds.> 
<Jan 8, 2016 8:01:05 AM CET> <Notice> <Log Management> <BEA-170027> <The server has successfully established a connection with the Domain level Diagnostic Service.> 
<Jan 8, 2016 8:01:06 AM CET> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to ADMIN.> 
<Jan 8, 2016 8:01:06 AM CET> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to RESUMING.> 
<Jan 8, 2016 8:01:06 AM CET> <Warning> <Server> <BEA-002611> <The hostname "localhost", maps to multiple IP addresses: 127.0.0.1, 0:0:0:0:0:0:0:1.> 
<Jan 8, 2016 8:01:06 AM CET> <Notice> <Server> <BEA-002613> <Channel "Default" is now listening on 127.0.0.1:7001 for protocols iiop, t3, ldap, snmp, http.> 
<Jan 8, 2016 8:01:06 AM CET> <Notice> <Server> <BEA-002613> <Channel "Default[2]" is now listening on 192.168.0.102:7001 for protocols iiop, t3, ldap, snmp, http.> 
<Jan 8, 2016 8:01:06 AM CET> <Notice> <Server> <BEA-002613> <Channel "Default[3]" is now listening on 0:0:0:0:0:0:0:1%lo:7001 for protocols iiop, t3, ldap, snmp, http.> 
<Jan 8, 2016 8:01:06 AM CET> <Notice> <Server> <BEA-002613> <Channel "Default[1]" is now listening on 192.168.122.1:7001 for protocols iiop, t3, ldap, snmp, http.> 
<Jan 8, 2016 8:01:06 AM CET> <Notice> <WebLogicServer> <BEA-000331> <Started the WebLogic Server Administration Server "AdminServer" for domain "base_domain" running in development mode.> 
<Jan 8, 2016 8:01:06 AM CET> <Notice> <Server> <BEA-002613> <Channel "Default" is now listening on 127.0.0.1:7001 for protocols iiop, t3, ldap, snmp, http.> 
<Jan 8, 2016 8:01:06 AM CET> <Notice> <Server> <BEA-002613> <Channel "Default[2]" is now listening on 192.168.0.102:7001 for protocols iiop, t3, ldap, snmp, http.> 
<Jan 8, 2016 8:01:06 AM CET> <Notice> <Server> <BEA-002613> <Channel "Default[3]" is now listening on 0:0:0:0:0:0:0:1%lo:7001 for protocols iiop, t3, ldap, snmp, http.> 
<Jan 8, 2016 8:01:06 AM CET> <Notice> <Server> <BEA-002613> <Channel "Default[1]" is now listening on 192.168.122.1:7001 for protocols iiop, t3, ldap, snmp, http.> 
<Jan 8, 2016 8:01:06 AM CET> <Notice> <WebLogicServer> <BEA-000360> <The server started in RUNNING mode.> 
<Jan 8, 2016 8:01:06 AM CET> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to RUNNING.>