Friday Nov 28, 2014

Oracle Linux Docker Base Image on Ubuntu 14.10

Oracle Linux team has been working hard to provide Docker support. You will be glad to see that they, since August, are releasing Docker binaries in Oracle Linux YUM repositories. Now recently they are also publishing the Oracle Linux Docker Base Images for OL6 and OL7! The documentation of Oracle Linux (OL6 and OL7) and Docker is also well advanced and explanatory. Keep track of everything about Docker and Oracle Linux from this yum page.

And why is this important you may ask? Well because it's definitely a required step if at some point the Fusion Middleware product teams move forward in certifying their products, such as WebLogic, on Docker as well. So if you want to work with Oracle products on Docker right now, although yet not certified nor supported, make sure you use the OL base images.

As a developer, I like to use Ubuntu Linux on my laptop. To use the OL7 Docker Base Image for example, I had to follow the following very short and easy steps:

  1. Make sure you have Docker installed on your Ubuntu environment

  2. Download the OL7 Base Image.

  3. Uncompress the file first with xz. You may find an issue where docker can't find the xz binary.
    $ sudo docker load -i oraclelinux-7.0.tar.xz
    2014/11/28 18:36:08 Error: Untar exit status 1 exec: "xz": executable file not found in $PATH

    $ unxz oraclelinux-7.0.tar.xz


  4. Load the image in your local Docker repository, as root, after extracting with xz (but keeping tar)
    $ sudo docker load -i oraclelinux-7.0.tar

  5. Check installation
    $ sudo docker images
    REPOSITORY     TAG  IMAGE ID       CREATED      VIRTUAL SIZE
    oraclelinux    7.0  5f1be1559ccf   2 weeks ago    265.2 MB


  6. Create and run a container based on this image
    $ sudo docker run -t -i oraclelinux:7.0 bash
Now have fun with Docker and Oracle Linux, and let me know if you create something cool with Fusion Middleware products!

Monday Jun 30, 2014

Docker, Java EE 7, and Maven with WebLogic 12.1.3

UPDATE March 2015 - We now officially certify and support WebLogic 12.1.3 on Docker Containers! For more information see this blog post and this whitepaper on OTN. The Docker configuration files are also now maintained on the official Oracle GitHub Docker repository.


WebLogic 12.1.3 was released and with it the support for perhaps the most important Java EE 7 APIs for database-backed Web Applications development. These are the specifications supported in this release:
As you can see above, WebLogic is bundled with the same implementations used by GlassFish 4.0, which gives you a compatible application server if you have already started developing Java EE 7 applications (well, of course limited to these APIs) and now seek for a commercially supported environment.

There are also some improvements in the Apache Maven Plugin, which makes developers' life much easier, allows for much better automated testing (Arquillian!), Continuous Integration and Delivery. IDEs that support Maven-based projects also benefit from this.

Does this makes WebLogic the best Java EE application server to run modern web HTML5/Javascript applications with RESTful and WebSockets services? Sure yes! So to give you a great way to test WebLogic, I created a Dockerfile for you to in order to create a WebLogic domain on your development environment to test it as you wish. Go to the weblogic-docker for the Developer ZIP Distro Dockerfile on the WebLogic Community GitHub repository.

Getting started with WebLogic 12.1.3, Java EE 7, Maven, and Docker

Now let's get it started. First go to Oracle.com and download WebLogic 12.1.3 ZIP Distro for Developers. Save that file for later use.

Installing WebLogic 12.1.3 without Docker (easy)
WebLogic ZIP is very easy to install:
  1. Extract the content in a folder where you want to hold the wls12130 directory that comes inside the ZIP file. On my Linux machine, I use /home/bruno/Work/tools/.
  2. Go to the wls12130 folder and run the configure.cmd (Windows) or configure.sh (Unix).
    • Creating the domain may take too long and may be seen as the installer is freezed. Make sure to configure this if you are on Linux:
      $ export CONFIG_JVM_ARGS=-Djava.security.egd=file:/dev/./urandom
  3. When the installer asks you if you want to create a domain, type [Y]
  4. Installer will ask you for username/password. On dev environments, I usually use weblogic/welcome1
  5. Installer will start WebLogic right away and you can check it running at http://localhost:7001/console

Installing WebLogic 12.1.3 with Docker (easier)

If you work on a Linux-based machine as your development environment and you aren't familiar with Docker yet, check the What is Docker, then give it a try. Long story short: Docker is a Linux container; it is like a virtual machine, but it is not (there are people running Docker on top of Vagrant virtual machines, for example). The most important thing for us here is that it will create a virtual network interface with a virtual IP address.

My laptop runs Ubuntu 14.04, so I used this Docker Installation Instruction to set it up. I will assume you will have Docker installed on your computer somehow, following instructions for your own operational system.
  1. Download the ZIP or checkout the weblogic-docker Git repository and extract somewhere on your computer. I will use $DOCKER_HOME as a reference to that location.
  2. Copy the wls12130_dev.zip you download previously into $DOCKER_HOME/weblogic-docker/weblogic12c-zip/
  3. Call the build.sh script (as sudo) and wait for Docker to do its magic
  4. Call dockWebLogic.sh and see WebLogic going up and running on a Docker container. 
    • It will attach port 7001 to your host interfaces
  5. Open http://localhost:7001/console. Username/password are weblogic/welcome1
** Please be aware: we don't provide support for WebLogic on Docker in any environment so use this at your own risk. The developer distribution (ZIP) is only for development environments and also unsupported, as it is not patchable. If you still really want to run WebLogic 12c Full Distribution on top of Docker, here's a way to set it up.

Configuring your local Maven repository

It is now possible to use Maven without a local installation of WebLogic, which is perfect for CI environments (Hudson/Jenkins). You will still require a installation though to set up the Maven Plugin initially, but as soon you install this to your remote Maven repository for example, other developers and CI envs won't need to have WebLogic installed locally, if deploying to a remote server. For local development, you can also point to WebLogic as a "remote" server, of course. 

The steps to configure Maven are well documented and it is done by the Maven Synchronization Plug-in. After installing it to your local repository, you can call the sync goal to populate a local or remote repository. Here are the steps for a local environment:
  1. Go to the WebLogic home installation directory. For example:
    $ cd /home/bruno/Work/wls12130/
  2. Go to the subdir
    $ cd oracle_common/plugins/maven/com/oracle/maven/oracle-maven-sync/12.1.3/
  3. Execute the following command:
    $ mvn install:install-file -DpomFile=oracle-maven-sync-12.1.3.pom -Dfile=oracle-maven-sync-12.1.3.jar
  4. Finally you call the push command to upload all Maven artifacts (plugins, archetypes, etc) to your repository (local in this case)
    $ mvn com.oracle.maven:oracle-maven-sync:push -DoracleHome=/home/bruno/Work/wls12130/
If you want to setup a remote repository, check the documentation.

Create Java EE applications with WebLogic Maven Archetypes

WebLogic provides a set of archetypes that come with the Maven Plug-in pre-configured. Let's create a simple Web project by using the Basic WebApp Maven Archetype
mvn archetype:generate
    -DarchetypeGroupId=com.oracle.weblogic.archetype
    -DarchetypeArtifactId=basic-webapp
    -DarchetypeVersion=12.1.3-0-0
    -DgroupId=org.mycompany
    -DartifactId=my-basic-webapp-project
    -Dversion=1.0-SNAPSHOT
Now of course you can open this Maven project on your NetBeans, IntelliJ IDEA, Eclipse, and then setup WebLogic in your IDE. Or you can just issue the command below to build, package, and deploy this WAR artifact to the WebLogic server you have running on your computer (either using Docker or the normal installation):
mvn package pre-integration-test 
    -DoracleUsername=weblogic 
    -DoraclePassword=welcome1 
    -Dupload=true
Here we make sure to use -Dupload=true since I'm not sure if you are using Docker or not. If you are, then upload is required since the container has no access to your local file system (although possible!)

Description of wls_02.jpg follows

Now open http://localhost:7001/basicWebapp and see this sample application up and running!

Bonus!

By the way if you are an IntelliJ IDEA user you may want to watch this recent Webinar I did with JetBrains team: Developing Java EE Applications for WebLogic 12c with IntelliJ IDEA. The slides are available as well:

Check Bruno Borges slideshare repository


About


Bruno has been having fun working with Java since 2000 and now helps Oracle on sharing the technology accross all Latin America. Also plays videogames, does trekking and loves beer.

Follow me on Twitter! @brunoborges

Search

Archives
« August 2015
SunMonTueWedThuFriSat
      
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
     
Today