Sunday Sep 21, 2014

WebLogic Encrypt Tool Script for Remote and Cloud Servers

One of the upcoming offerings of Oracle Java Cloud Service is a fully manageable instance of Oracle WebLogic in the Cloud. The service allows customers to manage a full instance of WebLogic the way they want. To do some tasks though, customers must connect through SSH to the server. Since security is important to us, WebLogic server is running Production Mode, and thus developers and operators are by default not allowed to use plain text passwords when executing WLST scripts, or deploying artifacts such as JDBC resources containing such plain text sensitive informations (you know... like... passwords!).

I've created this script to facilitate the encryption, and I'm quite sure it will be very useful to those Cloud operators and developers, but also for On Premise deployments where plain text passwords shouldn't be stored around on scripts and XML files. 

1 2 3 4 5 6 7 8 9 10 11 12 13 14
#!/bin/sh
# Util script to encrypt a password on a remote WebLogic domain through SSH
 
REMOTE_DOMAIN_HOME=/home/bruno/Work/tools/oracle/mw1212/user_projects/domains/base_domain
 
DIR="$( cd "$( dirname "$0" )" && pwd )"
 
PRIVATE_KEYFILE=~/.ssh/id_rsa
 
ssh bruno@localhost -i $PRIVATE_KEYFILE DOMAIN_HOME=$REMOTE_DOMAIN_HOME PASSWORD=$1 '/bin/bash -s' <<'ENDSSHSESSION'
cd $DOMAIN_HOME/bin
source setDomainEnv.sh
java weblogic.security.Encrypt $PASSWORD
ENDSSHSESSION

Let me know what you think! 

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


Wednesday Mar 26, 2014

Migrating JDBC Resources from GlassFish to WebLogic

Following up with my series of articles about Migrating from GlassFish to WebLogic, this time I want to cover the migration of a very common resource used by every Java EE developer: JDBC resources, or simply, DataSources. And in case you haven't read yet the first article, here it is: Migrating a Java EE App from GlassFish to WebLogic. That one will walk you through redeploying a simple yet almost complete Java EE 6 application on WebLogic, without any code change nor specific deployment descriptors, and still taking advantage of the enhanced Maven Plugin in WebLogic 12c.

It is easy to migrate resources by using the Web consoles of both WebLogic and GlassFish. Just open one browser window for each server, put them side-by-side, and follow the UI menus. Most of the properties are the same. But if you walkthrough the full article below, you will not only learn the concepts and what is required to migrate JDBC resources, but also how to migrate things using Command-line Interface (asadmin from GlassFish; wlst from WebLogic). So in order to understand what I'm doing here, I strongly recommend you to read, at least the introduction of, these two docs below in case you are not familiar with asadmin or wlst:


Oracle WebLogic Types of JDBC Data Sources

WebLogic offers three types of DataSources. For this migration, the type we will use will be "Generic". To know more about each type, click on the links below:

  • Generic Data Source
    • the type you are most familiar with; we will focus on this one
  • GridLink Data Source
    • in case you have an Oracle RAC Database, this is an optimal data source with HA and Failover features
  • Multi Data Source
    • abstracts two or more Generic Data Sources; works like a 'pool of data sources' so you can use it for either failover or load balancing



JDBC Resources: DataSources and Connection Pools

In the first article this was sort of covered from a Java EE Standard point of view. I simply took advantage of the @DataSourceDefinition annotation type, which allows developers to define JDBC DataSources directly from the Java source code, and requires no vendor-specific deployment descriptors nor manual previous configuration of the application server.

Now in case you have a legacy application or you are not using @DataSourceDefinition, you will be required to migrate these resources by hand. This will require three (plus one optional) simple steps:

  1. List JDBC resources from a GlassFish domain
  2. (optional; see below) Install 3rd-party JDBC drivers in WebLogic
  3. Extract and convert relevant and required information by WebLogic
  4. Create datasources inside WebLogic
Oracle WebLogic 12c already comes with JDBC drivers for Oracle DB 11g, MySQL 5.1.x, and Derby DB, so you won't need to do anything for these databases. For more information, read the docs JDBC Drivers Installed with WebLogic Server. In this doc you will also learn how to update the versions already provided by WebLogic, for example if you want to take advantage of the new features in Oracle DB 12c

If you are using Microsoft SQL Server, PostgreSQL, or any other database, check the Setting the Environment for a Thirdy-Party JDBC Driver for more information on how to install these drivers.

Concepts of JDBC Resources

We should also learn one difference between the concept of JDBC Resources in GlassFish 3 versus WebLogic 12c. In GlassFish, there are two types of JDBC Resources:
  • JDBC Connection Pools
  • JDBC Resources (aka DataSources)
On the other hand, WebLogic treats JDBC Resources as one single thing: Data Sources. The connection pool is part of the data source definition where in GlassFish, the Data Source is a separate artifact, which allows enabling/disabling the object, and also provides the JNDI name to a specific Connection Pool. In few words, when migrating a data source from GlassFish to WebLogic, you will only care about the JDBC Connection Pool and the JNDI name given at the JDBC Resource item.

Listing JDBC Resources from a GlassFish domain

First, let's list all JDBC Resources (datasources) in our GlassFish server. Connect with asadmin and execute thelist-jdbc-resources command:

asadmin> list-jdbc-resources
jdbc/__TimerPool
jdbc/__default
jdbc/gf2wls
Command list-jdbc-resources executed successfully.

Let's focus on our example: the jdbc/gf2wls datasource. This will be the DataSource we will migrate from GlassFish to WebLogic. Now let's list all Connection Pools in this GlassFish domain by using asadmin list-jdbc-connection-pools:

asadmin> list-jdbc-connection-pools
__TimerPool
DerbyPool
mysql_gf2wls_gf2wlsPool
Command list-jdbc-connection-pools executed successfully.

Now of course in case you have dozens of connection pools created in your GlassFish domain, it would be easier to issue a command that shows you which connection pool is associated to the Data Source you want to migrate. To do this, let's use the asadmin get command:

asadmin> get resources.jdbc-resource.jdbc/gf2wls.*
resources.jdbc-resource.jdbc/gf2wls.enabled=true
resources.jdbc-resource.jdbc/gf2wls.jndi-name=jdbc/gf2wls
resources.jdbc-resource.jdbc/gf2wls.object-type=user
resources.jdbc-resource.jdbc/gf2wls.pool-name=mysql_gf2wls_gf2wlsPool

We not only got which connection pool is associated to this data source but also its JNDI name, because the name of the resource may not be exactly the same as the JNDI name. 

Extracting GlassFish's JDBC Connection Pool data

Next step is to get all properties of your Connection Pool. Let's issue the asadmin get command again:

asadmin> get resources.jdbc-connection-pool.mysql_gf2wls_gf2wlsPool.*
resources.jdbc-connection-pool.mysql_gf2wls_gf2wlsPool.property.portNumber=3306
resources.jdbc-connection-pool.mysql_gf2wls_gf2wlsPool.property.serverName=localhost
resources.jdbc-connection-pool.mysql_gf2wls_gf2wlsPool.property.databaseName=gf2wls
resources.jdbc-connection-pool.mysql_gf2wls_gf2wlsPool.property.User=gf2wls
resources.jdbc-connection-pool.mysql_gf2wls_gf2wlsPool.property.URL=jdbc:mysql://localhost:3306/gf2wls?zeroDateTimeBehavior=convertToNull
resources.jdbc-connection-pool.mysql_gf2wls_gf2wlsPool.property.driverClass=com.mysql.jdbc.Driver
resources.jdbc-connection-pool.mysql_gf2wls_gf2wlsPool.property.Password=gf2wls
Command get executed successfully.

Easy, isn't? Now, let's focus on the minimum required properties we need to create this DataSource in WebLogic 12c. They are under resources.jdbc-connection-pool.mysql_gf2wls_gf2wlsPool.property.* , so if you want to list only these, change the asadmin method above to the following: asadmin get resources.jdbc-connection-pool.mysql_gf2wls_gf2wlsPool.property.*

Create the Data Source in WebLogic using WLST

To help you witht he final step, I've created a sample WLST script to create a Data Source in WebLogic. In this script, there are a few variables you must define. To call this script, go to your WebLogic installation directory and, if you are on Linux, call $ source setDomainEnv.sh (or the proper script for your environment). Then execute the WLST script: $ java weblogic.WLST ds_gf2wls.py

You should see the following output:

$ java weblogic.WLST ds_gf2wls.py
Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

Connecting to t3://localhost:7001 with userid weblogic ...
...
Starting an edit session ...
Started edit session, please be sure to save and activate your 
changes once you are done.
Saving all your changes ...
Saved all your changes successfully.
Activating all your changes, this may take a while ... 
The edit lock associated with this edit session is released 
once the activation is completed.
Activation completed

That's it. Check your WebLogic Console, by going to the Data Sources page.

Extending and improving the migration process

Now you may be wondering how to improve the process by automating everything, right? Yes you can do that! Since we have been using CLI commands, it all depends now on you by tweaking and coding some bash scripts. For example, you can use asadmin to get the information of all Data Sources, generate a bunch of files, usesed to, you know, hack the output files, then loop through them and call a more dynamic WLST script. If you want to read files from WLST, here's a fragment you can use:

from java.io import FileInputStream

propIS = FileInputStream("MyGFDS.properties")
configDS = Properties()
configDS.load(propIS)

dsName=configDS.get("dsName")
dsFileName=configDS.get("dsFileName")
dsDatabaseName=configDS.get("dsDataBaseName")
datasourceTarget=configDS.get("datasourceTarget")
dsJNDIName=configDS.get("dsJNDIName")
dsDriverName=configDS.get("dsDriverName")
dsURL=configDS.get("dsURL")
dsUserName=configDS.get("dsUserName")
dsPassword=configDS.get("dsPassword")
dsTestQuery=configDS.get("dsTestQuery")

Migrating Advanced Settings

If you want to migrate advanced settings of the Connection Pool, take a look at the full list of properties I extracted from GlassFish in my sample Data Source. To change for example the Max Pool Size, tweak the WLST script and add the following:

dsMaxPoolSize=25

cd('/JDBCSystemResources/' + dsName + '/JDBCResource/' + dsName + '/JDBCConnectionPoolParams/' + dsName)
cmo.setMaxCapacity(dsMaxPoolSize)

Again, you can do whatever you want in WLST.

There you go! If you come up with a super awesome script to automate the whole process, let me know!

Monday Mar 03, 2014

Migrating a Java EE App from GlassFish to WebLogic

WebLogic is Oracle's strategic application server for the Java EE Platform. Since Oracle decided to focus on it for commercial support, and decided to leave GlassFish free of any ties with commercial decisions, I decided to bring this type of content to help GlassFish customers as well users to experiment, try, and evaluate Oracle WebLogic 12c (Java EE 6 certified).



But before getting down to the migration part, first thing you should learn is How to Install WebLogic 12c. For this migration tutorial in a developer environment, we will be using the Developer installation, but for production environments, we recommend the Full installation.

Full Installation
For full installation that can be used either in a production environment or in a developer environment, download the WebLogic Generic Installer and follow the steps descriped in the documentation for 12.1.2 on how to install WebLogic.

The difference between full and dev, is that full is targeted for any environment, and dev is well, for developers only. Oracle always recommend the full installation, but usually and specially for Java EE applications in a dev environment, the Development installation is enough. The good thing about it is the download size: less than 200Mb, and still you also get Oracle Coherence to play with. By the way, there is no licensing requirements for development purposes (either full or dev install), because WebLogic (and other Oracle products) are free for developers.

Required software

For this series of Migrating from GlassFish to WebLogic, I will be using NetBeans 8.0, GlassFish 3.1.2.2Oracle JDK 7, Oracle MySQL Community 5.6, and WebLogic 12.1.2. So make sure you have that software (except WLS for now) installed and configured in your system.

Developer Installation of WebLogic 12c

Let's get started by first installing WebLogic 12c for Developers. Instructions here are for Linux, but it is not that much different for Windows or Mac.
  1. Download WebLogic 12c ZIP Distribution for Developers (latest version: 12.1.2)
  2. Unzip it somewhere, for example:
    $ unzip wls1212_dev.zip -d /opt
  3. Go into the newly created directory
    $ cd /opt/wls12120
  4. Let's unpack the JAR files that were optimally compressed with pack200
    $ sh configure.sh    // for Windows, call configure.cmd
  5. After the uncompression, configure script will ask you if you want to create a new domain. Say "yes" by pressing 'y', then [enter]
  6. Provide a username, a password, and then confirm again the password
  7. Wait for the domain to be created and started
In just a few minutes you will have WebLogic installed, configured, and running!

Test your WebLogic 12c Developer Installation

At this point, you should have a WebLogic domain configured, up, and running. You can access the Admin Web Console at the following URL: http://localhost:7001/console. It will ask for username/password you typed during install. Take a moment to explore the Admin Console. You can find more information at the official documentation for 12.1.2.

You may also find very useful to know you can manipulate all domain settings through the WebLogic Scripting Tool, a command-line interface for you to code in Python, and issue commands to view and edit all settings. In an upcoming version of WebLogic we will also provide a REST interface.

I will use WLST in the next posts in this series, so maybe you want to read more later.

How to Start/Stop WebLogic 12c

In order to start and stop correctly your WebLogic domain, you can either do that from an IDE such as NetBeans, or by running specific scripts. These scripts are located under the following path location:

/opt/wls12120/user_projects/domains/mydomain/bin
  • $ sh startWebLogic.sh
  • $ sh stopWebLogic.sh

The Beauty of Java EE 6

Now, instead of going through the process of creating a Java EE application, I coded a small application that covers a large set of Java EE 6 APIs and pushed it to this GitHub repository. It is an application using the following APIs:
  • CDI 1.0
  • JSF 2.1
  • Bean Validation 1.0
  • EJB 3.1
  • JPA 2.0
  • JAX-WS 2.2
  • JAXB 2.2
  • JAX-RS 1.1
The beauty of Java EE is that you will learn from this migration how good it is when you follow standards, and also the value of the platform. Simply put: we will migrate this application without touching any code. At least not for now. Let's first set some infrastructure requirements. For now, we must have a database.

JPA and Database setup

To facilitate things, and before you can run this application, make sure you have MySQL installed and running onlocalhost, and with a database named gf2wls with username/password gf2wls with all privileges. The project comes with a drop-and-create configuration when JPA (through EclipseLink) is initialized.

To setup this, connect as root to your local MySQL server and issue the following two commands:
  1. $ mysql -u root -p
  2. mysql> create database gf2wls;
  3. mysql> grant all privileges on gf2wls.* to gf2wls@localhost identified by 'gf2wls';
And you are set!

Import project to NetBeans, setup MySQL driver, and run it on GlassFish 3.1.2.2

Since this is an article about migrating from GlassFish to WebLogic, I will assume you know how to get this application running on GlassFish 3.1.2.2 from NetBeans. But I will provide some highlights to make it work smoothless.



In order for the @DataSourceDefinition entry inside class InitializeSampleDataSessionBean work fine and connect to your MySQL database in GlassFish, make sure you have copied MySQL JDBC Driver into glassfish3/glassfish/domains/domain/domain1/lib/ext/ of course, before starting it up. In WebLogic, you don't need to do this since MySQL Connector/J is already part of the default installation.

Download the project 'bookmark-javaee6' to your local machine by either cloning the GitHub repository locally, or by downloading the zip and extracting somewhere. This is an Apache Maven project, so don't worry about environment. Just make sure you have this project up and running on a GlassFish domain.

Import the project bookmark-javaee6 into your NetBeans environment. Right click on bookmark-javaee6 project and select Run. Test the application by going to http://localhost:8080/bookmark-javaee6.

You should by now looking at the following screen:


Test the Bookmark WebService with a simple client

The sample Bookmark application comes with a JAX-WS WebService.

  1. You can test this WebService in many ways, but I will give you three main options: one is to try SoapUI
  2. Another option is to right click on the WebService in NetBeans, and select Test WebService
  3. Last option is to run the bookmark-javaee6-wsclient that comes with JUnit Test Cases. 
Make your choice, and see it working!

Running the sample Java EE 6 application in WebLogic 12c

Before we go to a pure Maven description on how to do this, let's give NetBeans a try. Now that you have everything ready (a Java EE 6 application running on GlassFish 3.1.2.2), with source code as a Maven project in NetBeans, let's add WebLogic as a Server to it.

  1. Go to the Services tab in NetBeans, and right click in Servers, then select Add Server....
  2. Select Oracle WebLogic Server
  3. Insert the path location of your recently installed WebLogic server. Remember to select the subfolderwlserver. If you installed as described in the beginning, you should try /opt/wls12120/wlserver
  4. Type your username and password of your WebLogic domain
  5. Finish this wizard
Now we must change from GlassFish to WebLogic in Project Properties. Select bookmark-javaee6 project and right click on it. Go to Run and select your newly created WebLogic 12.1.2 server. Press OK. See the picture below to understand what has to be done:



Start your project by right clicking in it, and select Run! Test your application running on WebLogic by going to the following location: http://localhost:7001/bookmark-javaee6


In case you had any problem, try these two articles:


Success! You have now the same application running on WebLogic 12c! Without any code change!

WebLogic understands GlassFish Deployment Descriptor

I haven't mentioned this before because I wanted you to see the sample application up and running on WebLogic, but what you can do in this application is to remove src/main/webapp/WEB-INF/weblogic.xml, and change the context-root inside glassfish-web.xml. What will happened if you redeploy this application without weblogic.xml, is that the application will start just fine, but in a different context-root: the one you typed inside glassfish-web.xml.

The reason for this is well documented on Support for GlassFish Deployment Descriptors. Give it a look in case you want to know what else does WebLogic understands from GlassFish's DD.

Now, let's try something different. Let's now use pure Apache Maven to compile and run the application on your WebLogic installation! For that, we will first need to configure the plugin.

Configuring the WebLogic Development Maven Plugin

Before you can use the plugin, you must install it in your local or remote Maven repository. Feel free to follow official instructions for WebLogic 12.1.2. But in case you want to just get it done, here's the short version:

  1. Go to your WLS installation. It is probably located here:
    /opt/wls12120
  2. Now change to the following directory:
    $ cd oracle_common/plugins/maven/com/oracle/maven/oracle-maven-sync/12.1.2
  3. Issue the following command to sync WLS Maven Plugin into your local repository:
    $ mvn com.oracle.maven:oracle-maven-sync:push -Doracle-maven-sync.oracleHome=/opt/wls12120/oracle_home/.
You have now successfully installed WLS Maven Plugin. To validate the installation, type:
$ mvn help:describe -DgroupId=com.oracle.weblogic-DartifactId=weblogic-maven-plugin -Dversion=12.1.2-0-0

To continue, let's configure the plugin onto our bookmark-javaee6 sample application, and then deploy the package into WebLogic
  1. Open the POM file of bookmark-javaee6 project
  2. Uncomment the WebLogic Maven Plugin definition
  3. Make sure to enter the same username and password as your domain when you installed and configured WebLogic
  4. Make sure WebLogic is running
  5. Make sure there's no other bookmark-jaavaee6 project deployed on your WebLogic instance
  6. Execute the following command:
    $ mvn package pre-integration-test
  7. Check your logs and try http://localhost:7001/bookmark-javaee6!

Conclusion

As you could see, if you are working with a Java EE 6 project 100% standardized, and perhaps Maven, you will find no problems at migrating this project to WebLogic 12c. In fact, if you are using Maven it will be as simple as adding a new plugin just to facilitate deployment. But even this you won't have to do in case you have a binary only. Just open the Admin Web Console, and fire a deployment from there!

And by the way, WebLogic is not that heavyweight and unproductive application server developers thought it still is. For more information about Developer Productivity with WebLogic 12c, read my entry "WebLogic in Comparison: RebelLabs and the Java App Server Debate".

Caveats for Java EE projects, road ahead for migrations

In the next blog posts of this series, I will cover how to work around some common issues when your project is not exactly following, or taking advantage of all standards defined in the Java EE 6 platform, or simply using extra features, customizations of GlassFish.

Here's a sneak peek of what's coming next:
  • How to Migrate JDBC DataSources from GlassFish to WebLogic
  • How to Define, Deploy, and Use JMS resources
  • How to Migrate JMS resources from GlassFish to WebLogic
  • How to Add and Isolate (classpath of) 3rd-party libraries (for example PrimeFaces)
And many more things to come!
  • Applying a GlassFish Domain Topology to a WebLogic Domain (clustering, etc)
  • Migrating Security Realms
  • Migrating Custom Login Modules
If there's any other subject you'd like to see, please post a comment!

Cheers!

Wednesday Jan 08, 2014

WebLogic in Comparison: RebelLabs Java Servers Report

RebelLabs did a great job comparing the main Java servers out there, where some are pure Servlet/JSP containers, others are full Java EE compliant. But they didn't want to include in the list Oracle WebLogic nor IBM WebSphere apparently for no logical reason but "they are suited for large enterprise production environments", and because the report is focused on developers.

"The Great Java Application Servers Debate"

So, I decided to write this blog post to include detailed information about WebLogic, since WLS is free for developers, even if you are going to deploy GlassFish/JBoss/Whatever in production. Which is why I didn't get why RebelLabs didn't want to compare WebLogic.

Remember, I will detail WebLogic from a "developer point of view", using the same categories RebelLabs used in their report. Here we go:


Download & Installation

WebLogic 12c is certified for Java EE 6, and 12.1.1 was released on Dec 2011. The second release is 12.1.2 and is from July 2013, part of the full Cloud Application Foundation 12c release. For developers, there is a ZIP distribution sized at 184Mb.
  1. Accept Licence agreement
  2. Download installation package *
  3. Extract the archive
  4. Run configure.sh (Linux/Mac) or configure.cmd (Windows)
  5. You are ready to go!
* you must have an OTN account, required for other things like access Oracle Forums

The configure.sh script will ask you if you want to create a domain. Say "yes". Then you are asked to provide username/password for it, because we do care about default security. And right after the script finishes creating the domain, you can point to http://localhost:7001/console, because the script will automatically start WebLogic for you. To start WebLogic again, just call: 
$ cd user_projects/domains/mydomain; sh startWebLogic.sh
Conclusion: License accepted only once. Bigger than others indeed but enhanced default security. Starts server automatically right after creating domain.


Tooling support

The RebelLabs report says WebLogic is only integrated with JDeveloper. But that's a big mistake. WebLogic is well integrated with NetBeans, Eclipse, IntelliJ, and can even be used with Apache Maven and Ant. For a "big fat bloated enterprise production-only app server", I would say WebLogic is in very good shape for development environments.

Eclipse: you can either download Oracle Enterprise Pack for Eclipse bundled with Eclipse, or just the update by either downloading the repository, or pointing to the repository URL.

NetBeans: support comes out of the box since version 7.1 (released in January 2012). Here's an article hosted on netbeans.org about NetBeans and WebLogic.

IntelliJ IDEA: Jetbrains comes with native support for WebLogic not only version 12, but also older versions. 

Apache Maven: in release 12.1.2, Oracle WebLogic has an enhanced Maven support with more goals and easier installation into Maven repositories. Check the documentation to learn more.

Apache Ant: for several versions WebLogic has been coming with Ant support. And continues to do so. Check the documentation for 12.1.2

If you are developing with Eclipse, NetBeans, or JDeveloper, you can even enable FastSwap, a feature that reloads changed classes on the fly. I've blogged about how to enable and use FastSwap with NetBeans a while ago.

Conclusion: has support for 99,9999% of tools used by developers. FastSwap for on-the-fly class update. IntelliJ and NetBeans with OOTB support. Eclipse plugin or full distribution with OOTB support.


Server Configuration

In the report, RebelLabs gave GlassFish a score of 3, which is weird because the way they described this section, seems like everything is perfect. The "Reason" line gives no negative reason at all! So I asked them on Twitter.

In WebLogic, you can basically do everything through the Web console available in the Admin Server. From there you can create clusters, create new managed servers, add Java EE resources like JMS queues, Data Sources. You can create Work Managers, do Security management. Anything. But for developers that don't want to follow steps documented in Word files full of screenshots of all these Web interfaces, they can simply write a Python script, and whenever they have to configure something [again], all they need to do is to run the script. The feature is calledWebLogic Scripting Tool, or simply WLST, and several companies have been using this for many years. It's great for configuration automation and also manageability. If you want to record the commands you type in the WLST shell for future executions, call startRecording(). If you don't want to write a script from scratch, the Adminstration Web console comes with a "Recording" feature that will record all your actions and create the script for future executions. And you can also connect through JMX.

If you are really into XML configuration, you can access the domain folder, then edit theconfig/config.xml file and do your magic. But they will only take effect after a restart.

And finally, most changes don't require a server restart.

Conclusion: Python scripts. JMX. Rich web console. Recording features. XML. Most changes go live without restart.


Documentation & Community

Documentation for WebLogic is very complete, and the new 12.1.2 documentation website has an updated Look & Feel. It is easy to navigate and comes with a search (basic and advanced) feature. The community is not as small as you may think. Oracle runs the Oracle ACE program and highlights outstanding professionals all around the world. The Oracle Partner Network is also big, with several folks running meetings, bootcamps, hackathons, etc. Take for example the last edition of UK OUG Tech 13, where attendees developed Puppet modules during a WebLogic Hackathon. And finally there's an Oracle Forum for WebLogic which is ran by the Oracle Technology Network team. 

Community is not related to only Open Source products. Doesn't matter if it's Open Source or not, if there's enough people working with a product, there's a chance for a community be born.

Conclusion: There is a community. Not as know as Open Source ones. Widespread around the world. Decentralized.


Features & Open Standards compliance

WebLogic 12c is Java EE 6 Full profile certified. Customers can also develop rich web applications with Oracle ADF, and they also get extra features/support for TopLink, like Oracle Coherence Integration. TopLink can be seen as an extension of EclipseLink, the Open Source JPA implementation, maintained at the Eclipse Foundation, but with great contribution from Oracle. WebLogic 12c has also support for OSGi bundles.

For administrators and devops, in addition licensed customers gain several other products and support. So for example, if you are comparing WebLogic Standard Edition with JBoss, don't forget that WLS SE comes bundled with support for: 
  • Oracle HTTP Server (enhanced Apache)
  • Oracle TopLink/ADF
  • Configuration Wizard / Upgrade Framework / OPatch
  • Oracle Java SE
  • Oracle WebLogic Management Framework
  • WebLogic JDBC Drivers, Server Clients, Apache Plugin
  • HTTP Pub-Sub Server
If you want more details about what you get by buying WebLogic, see this table. It will show also what other flavours of WebLogic (Enterprise/Suite) have to offer.

Conclusion: of course 1 apple will be cheaper than 4. :-)

Conclusion: Java EE 6 and OSGi. Extra features/products for licensed customers starting since WebLogic Standard Edition. Most complete application server, with support for all products involved in a basic infrastructure for running server-side Java applications.


Administration & Management/UI

As I pointed in the "Server Configuration", WebLogic has several ways for the developer to configure whatever the dev wants. But to give you an impression, here's a screenshot of the Admin Console, to create a JDBC Data Source:
Conclusion: Rich web console. Allows to control, from the Admin Server, all resources, as well monitor and manage servers in one or more clusters.


Cost $$$ / Licensing

The pricelist is available publicly and can be easily googled. No secrets, full transparency, from how much you pay (at maximum, since there's always a conversation with the sales rep), to what you get in exchange. Remember: when you license and contract support for WebLogic Standard Edition, you pay per processor socket (not per core), and you get support for Oracle Java SE (JVM), Oracle HTTP Server (Apache), and several other features/products. Other editions are priced differently but come with even more features.

But anyway, WebLogic comes with no charge for developers.

Conclusion:  When comparing cost to other application servers, remember that WebLogic comes with supported JVM (Oracle HotSpot), support of an enhanced Apache (Oracle HTTP Server), and other things that most application servers don't offer when you license or subscribe for support.


The Results

I've seen developers running Tomcat or JBoss or GlassFish, and going into production with WebSphere or WebLogic. But with the information above, I say that, overall,  WebLogic has evolved a lot especially in the new 12c version, with a smaller ZIP distribution, easy and secure installation, enhanced Maven support, great features for managing, awesome tooling support, and most important, free for developers. And don't forget the community! 

If a developer wants to develop pure Java EE applications, WebLogic is a very strong candidate. Even if the customer is running WebSphere in production :-)

Thursday Dec 05, 2013

WebLogic agora é grátis para desenvolvedores!

Uma ótima notícia, que não é mais tão notícia assim, para todas as empresas desenvolvedoras de software, ISVs, fábricas de software, parceiros e não-parceiros Oracle. O WebLogic, servidor de aplicação Java EE líder de mercado pode ser baixado gratuitamente e utilizado em ambientes de desenvolvimento sem qualquer custo, através da licença da OTN. Conforme licença publicada no site, o trecho mais importante é este:

"[...] deploy the programs only on your single developer desktop computer (of any type, including physical, virtual or remote virtual), to be used and accessed by only (1) named developer."

Até então era comum acreditar que para desenvolver para uma grande empresa que adquiriu o WebLogic, seria necessário a empresa prestadora de serviço adquirir também o produto. Um exemplo comum é de empresas que desenvolvem software para outras empresas em forma de projetos (fábricas de software); estas empresas podem utilizar o WebLogic nas máquinas dos desenvolvedores sem qualquer custo Outro trecho interessante na licença da OTN é este:

"You may continue to develop, test, prototype and demonstrate your application with the programs under this license after you have deployed the application for any internal data processing, commercial or production purposes"
Veja a licença OTN completa para maiores informações

Se a sua empresa está em São Paulo, e vocês desenvolvem software para outras empresas que utilizam o WebLogic em produção, entre em contato para conhecer mais sobre o novo Oracle WebLogic 12c: bruno dot borges at oracle dot com.

Se ainda restam dúvidas sobre a simplicidade de instalar o WebLogic em ambientes de desenvolvimento, veja este outro blog post (em inglês) sobre como configurar o WebLogic distribuído em formato ZIP: How To Install WebLogic Zip on Linux!

Thursday Nov 14, 2013

O futuro do WebLogic 12c

Antes de falar do WebLogic 12c, uma informação importante é que prorrogamos o suporte do WebLogic 11g (versão 10.3.6) até 2018, e o suporte estendido até 2021. Isto dará maior tranquilidade aos clientes a planejarem suas migrações, reduzindo assim riscos e custos, principalmente aos clientes de Fusion Apps e SOA Suite/BPM. 

A versão atual do WebLogic 12c é a 12.1.2, lançada este ano em Junho, juntamente com todo o Cloud Application Foundation 12c (Coherence, Oracle HTTP Server, Tuxedo, etc). A versão anterior 12.1.1 já era certificada em Java EE 6, e agora esta nova versão traz uma série de recursos e funcionalidades para integrar suas aplicações com o banco de dados Oracle 12c, facilitar o operacional através de Dynamic Clustering e Elastic JMS, mais otimizações para Exalogic e JMS, administração do Oracle Coherence pelo console administrativo do WebLogic, plugins para desenvolvimento de projetos com Apache Maven, geração automática de serviços REST para seus projetos JPA com o TopLink RESTful Data Services, e muito mais.

O WebLogic 12.1.2 também substituiu o antigo instalador da BEA e os utilitários de patch BSU com o Oracle Universal Installer e o utilitário opatch para a aplicação de patches. Muitos clientes Oracle já conhecem estas ferramentas, que já eram utilizadas para outros produtos, como o próprio Banco de Dados.

Ou seja, uma série de novidades que justificam a liderança do WebLogic no mercado de Application Servers. Mas ao olhar os próximos passos e o roadmap para as versões do WebLogic 12.1.3 e 12.1.4, há motivo de sobra para se interessar na versão 12c.

A versão WebLogic 12.1.3 deverá ser a primeira homologada para diversos produtos 12c do FMW como SOA Suite 12c. Além disso, alguns novos recursos serão incluídos para melhorar ainda mais a experiência do administrador de infraestrutura para escalar ambientes com mais servidores. Por exemplo, a feature de Elastic JMS permitirá o uso do Server Migration sem perder mensagens durante esta execução. Estamos trabalhando para oferecer na versão 12.1.4 o suporte para auto-scaling de clusters dinâmicos, com base em limites e métricas definidas pelo usuário. O WebLogic 12.1.4 também deverá ter uma API para controlar os clusters dinâmicos. Desta forma, os usuários poderão facilmente programar a hora de parar, iniciar ou remover nós de um cluster dinâmico.

O WebLogic 12c conta com o driver JDBC 12c, oferecendo melhor integração com o Oracle DB 12c, e uma destas features é chamada de "Application Continuity". Esta feature permite que após uma falha de comunicação com um nó de um Oracle RAC, a transação com o banco de dados seja transferida sem qualquer efeito colateral para outro nó do cluster, garantindo disponibilidade. Na versão WebLogic 12.1.4, será introduzido também um novo recurso chamado de Multitenant Applications. Desta forma usuários poderão definir um modelo WebLogic para uma aplicação, para um ou mais clientes desta aplicação, que terá o seu próprio cluster, etc.

O conteúdo acima foi originalmente postado aqui.

AVISO LEGAL: O texto acima visa delinear nossa direção geral dos produtos. Destina-se apenas para fins informativos, e não pode ser incorporado em qualquer contrato. Não é um compromisso e não deve ser usado na tomada de decisões de compra. O desenvolvimento, lançamento e tempo dos recursos ou funcionalidades descritos para os produtos da Oracle permanecem a critério exclusivo da Oracle.

Wednesday Nov 06, 2013

6 Facts About GlassFish Announcement

Since Oracle announced the end of commercial support for future Oracle GlassFish Server versions, the Java EE world has started wondering what will happen to GlassFish Server Open Source Edition. Unfortunately, there's a lot of misleading information going around. So let me clarify some things with facts, not FUD.


Fact #1 - GlassFish Open Source Edition is not dead

GlassFish Server Open Source Edition will remain the reference implementation of Java EE. The current trunk is where an implementation for Java EE 8 will flourish, and this will become the future GlassFish 5.0. Calling "GlassFish is dead" does no good to the Java EE ecosystem. The GlassFish Community will remain strong towards the future of Java EE. Without revenue-focused mind, this might actually help the GlassFish community to shape the next version, and set free from any ties with commercial decisions.


Fact #2 - OGS support is not over

As I said before, GlassFish Server Open Source Edition will continue. Main change is that there will be no more future commercial releases of Oracle GlassFish Server. New and existing OGS 2.1.x and 3.1.x commercial customers will continue to be supported according to the Oracle Lifetime Support Policy. In parallel, I believe there's no other company in the Java EE business that offers commercial support to more than one build of a Java EE application server. This new direction can actually help customers and partners, simplifying decision through commercial negotiations.


Fact #3 - WebLogic is not always more expensive than OGS

Oracle GlassFish Server ("OGS") is a build of GlassFish Server Open Source Edition bundled with a set of commercial features called GlassFish Server Control and license bundles such as Java SE Support. OGS has at the moment of this writing the pricelist of U$ 5,000 / processor. One information that some bloggers are mentioning is that WebLogic is more expensive than this. Fact 3.1: it is not necessarily the case. The initial edition of WebLogic is called "Standard Edition" and falls into a policy where some “Standard Edition” products are licensed on a per socket basis. As of current pricelist, US$ 10,000 / socket. If you do the math, you will realize that WebLogic SE can actually be significantly more cost effective than OGS, and a customer can save money if running on a CPU with 4 cores or more for example. Quote from the price list:


“When licensing Oracle programs with Standard Edition One or Standard Edition in the product name (with the exception of Java SE Support, Java SE Advanced, and Java SE Suite), a processor is counted equivalent to an occupied socket; however, in the case of multi-chip modules, each chip in the multi-chip module is counted as one occupied socket.”


For more details speak to your Oracle sales representative - this is clearly at list price and every customer typically has a relationship with Oracle (like they do with other vendors) and different contractual details may apply.


And although OGS has always been production-ready for Java EE applications, it is no secret that WebLogic has always been more enterprise, mission critical application server than OGS since BEA. Different editions of WLS provide features and upgrade irons like the WebLogic Diagnostic Framework, Work Managers, Side by Side Deployment, ADF and TopLink bundled license, Web Tier (Oracle HTTP Server) bundled licensed, Fusion Middleware stack support, Oracle DB integration features, Oracle RAC features (such as GridLink), Coherence Management capabilities, Advanced HA (Whole Service Migration and Server Migration), Java Mission Control, Flight Recorder, Oracle JDK support, etc.

Update 24-11-2013:  clustering support is available on WebLogic Enterprise and Suite editions.

Fact #4 - There’s no major vendor supporting community builds of Java EE app servers

There are no major vendors providing support for community builds of any Open Source application server. For example, IBM used to provide community support for builds of Apache Geronimo, not anymore. Red Hat does not commercially support builds of WildFly and if I remember correctly, never supported community builds of former JBoss AS. Oracle has never commercially supported GlassFish Server Open Source Edition builds. Tomitribe appears to be the exception to the rule, offering commercial support for Apache TomEE.


Fact #5 - WebLogic and GlassFish share several Java EE implementations

It has been no secret that although GlassFish and WebLogic share some JSR implementations (as stated in the The Aquarium announcement: JPA, JSF, WebSockets, CDI, Bean Validation, JAX-WS, JAXB, and WS-AT) and WebLogic understands GlassFish deployment descriptors, they are not from the same codebase.


Fact #6 - WebLogic is not for GlassFish what JBoss EAP is for WildFly

WebLogic is closed-source offering. It is commercialized through a license-based plus support fee model. OGS although from an Open Source code, has had the same commercial model as WebLogic. Still, one cannot compare GlassFish/WebLogic to WildFly/JBoss EAP. It is simply not the same case, since Oracle has had two different products from different codebases. The comparison should be limited to GlassFish Open Source / Oracle GlassFish Server versus WildFly / JBoss EAP.


But the message now is much clear: Oracle will commercially support only the proprietary product WebLogic, and invest on GlassFish Server Open Source Edition as the reference implementation for the Java EE platform and future Java EE 8, as a developer-friendly community distribution, and encourages community participation through Adopt a JSR and contributions to GlassFish.


In comparison

Oracle's decision has pretty much the same goal as to when IBM killed support for Websphere Community Edition; and to when Red Hat decided to change the name of JBoss Community Edition to WildFly, simplifying and clarifying marketing message and leaving the commercial field wide open to JBoss EAP only. Oracle can now, as any other vendor has already been doing, focus on only one commercial offer.


Some users are saying they will now move to WildFly, but it is important to note that Red Hat does not offer commercial support for WildFly builds. Although the future JBoss EAP versions will come from the same codebase as WildFly, the builds will definitely not be the same, nor sharing 100% of their functionalities and bug fixes. This means there will be no company running a WildFly build in production with support from Red Hat.


This discussion has also raised an important and interesting information: Oracle offers a free for developers OTN License for WebLogic. For other environments this is different, but please note this is the same policy Red Hat applies to JBoss EAP, as stated in their download page and terms. Oracle had the same policy for OGS.


TL;DR;

GlassFish Server Open Source Edition isn’t dead. Current and new OGS 2.x/3.x customers will continue to have support (respecting LSP). WebLogic is not necessarily more expensive than OGS. Oracle will focus on one commercially supported Java EE application server, like other vendors also limit themselves to support one build/product only. Community builds are hardly supported. Commercially supported builds of Open Source products are not exactly from the same codebase as community builds.


What's next for GlassFish and the Java EE community?

There are conversations in place to tackle some of the community desires, most of them stated by Markus Eisele in his blog post. We will keep you posted.

Thursday Mar 28, 2013

[pt_BR] Redeploy de aplicações em produção no WebLogic

O WebLogic oferece uma função que permite você atualizar aplicações em ambiente de produção, com zero-downtime. Funciona assim: usuários que estão conectados na sua aplicação, continuarão conectados na versão antiga, mas quem se conectar depois do deploy da nova versão, será direcionado para o novo deploy. Assim, nenhum usuário sofrerá com um erro 404 (conteúdo inexistente), ou será prejudicado no meio de um processo (por exemplo, consultas ou relatórios). Isso permite roll-out de novas versões em horário comercial, sem necessidade de uma janela de atualização, para por exemplo, corrigir falhas no sistema que afetam somente uma parte da aplicação.

Agora para que isso seja possível, é necessário configurar o que chamamos de Application Version Identifier. Esta informação pode ser passada de duas formas:

  1. Por linha de comando:
    java weblogic.Deployer -adminurl http://localhost:7001 -user weblogic
         -password weblogic -deploy -name myTestDeployment 
         -source /myDeployments/myApplication/91Beta
         -targets myCluster -stage -appversion .91Beta
  2. Configurado no MANIFEST.MF do pacote (EAR/WAR) da aplicação
    Manifest-Version: 1.0
         Created-By: 1.4.1_05-b01 (Sun Microsystems Inc.)
         Weblogic-Application-Version: v920.beta

Apache Maven
Se você utiliza Maven para criar o pacote da aplicação, basta configurar no plugin (war ou ear), o parâmetro do Manifest:

<plugin>
  <artifactId>maven-ear-plugin</artifactId>
  <configuration>
    <archive>
      <manifestEntries>
        <WebLogic-Application-Version>${project.version}</WebLogic-Application-Version>
      </manifestEntries>
    </archive>
  ... 
</plugin>

Deu erro na versão nova? Rollback!
Se aconteceu alguma coisa com a versão nova, é só reativar a versão antiga para que novos usuários sejam direcionados a ela. Em seguida remova a versão nova. 

Removendo a versão antiga
Depois de ter a versão nova no ar, o WebLogic vai monitorar as sessões ainda abertas na versão antiga. Quando todas as sessões finalizarem (via timeout), a aplicação irá para o status retired. Caso isso demore para acontecer devido a sessões longas (usuário que esqueceu o navegador aberto em uma tela com função auto-refresh), você pode forçar esta etapa pelo console administrativo.

Se precisar de maiores informações, consulte a documentação do WebLogic 12c.

Monday Sep 17, 2012

WebLogic Application Server: free for developers!

Great news! Oracle WebLogic Server is now free for developers! What does this mean for you? That you as a developer is permited to use the application server on your computer to develop, test, prototype and demonstrate applications with Oracle software that is offered with the OTN Free Developer License. Read the full license agreement here.

If you want to take advantage of this licensing change and start developing Java EE applications with the #1 Application Server in the world, read now the previous post, How To Install WebLogic Zip on Linux!

Monday Sep 03, 2012

How to Install WebLogic 12c ZIP on Linux

UPDATE July 1st 2014 - See recent post about WebLogic 12.1.3 and its Maven integration, support of key Java EE 7 APIs and configuration using Docker.

I knew that WebLogic had this small ZIP distribution, of only 184M, but what I didn't know was that it is so easy to install it on Linux machines, specially for development purposes, that I thought I had to blog about it.

You may want to check this blog, where I found the missing part on this how to, but I'm blogging this again because I wanted to put it in a simpler way, straight to the point. And if you are looking for a how to for Mac, check Arun Gupta's post.

 So, here's the step-by-step:

  1. Download the ZIP distribution
    Don't forget to accept the OTN Free Developer License Agreement!
  2. Unzip the content of the file exactly where you want to keep your local installation of WebLogic 12c
  3. Make sure you have JAVA_HOME environment variable pointing to a local install of Oracle JDK 7
    • For example: export JAVA_HOME=/usr/lib/jvm/java-7-oracle
  4. Open your terminal and go to that directory
  5. Set the following environment variable
    • $ export CONFIG_JVM_ARGS=-Djava.security.egd=file:/dev/./urandom
  6. Call configure.sh
  7. When asked, say [Y] to create a default domain, and then provide a username and password
  8. Domain will be automatically started after created
  9. Go to http://localhost:7001/console

 

Enjoy!

Friday Aug 10, 2012

WebLogic 12c Overview - OTN Tour 2012

I had the pleasure to be part of the OTN Tour 2012 Latin America, that is going on right now (August 2012) and to know some folks from Oracle HQ, but more importantly, to present architects, administrators, DBAs and software developers a little bit of Oracle WebLogic 12c and its great integrations with other Oracle products, specially Oracle RAC with its Active GridLink, Coherence Data Grid and of course, Oracle Exalogic.

If you couldn't come to the OTN Tour in Buenos Aires and Montevideo, don't worry. The slides are right here! :-)

Hope you enjoy!

Friday Aug 03, 2012

Issue dev'ing RESTful JSON services on NetBeans

Here is a tricky issue that you may find if you are developing RESTful services with Java EE on NetBeans and GlassFish or WebLogic. If you want to support the JSON format but need to access some implementation classes like @JsonIgnore, you need to add the JAX-RS RI, Jersey, to your project's Libraries definition. How to add the RI? You will probably do this:

  1. Open project's Properties (right click on the project)
  2. Go to Libraries
  3. Click on 'Add Library'
  4. Select 'Jersey 1.8 (JAX-RS RI)

But you won't have your service running fine. You may find these exceptions: (added here so Google can help future users)

1 - If you try to access your RESTful service to get a JSON format of it, you will get this exception:

com.sun.jersey.spi.inject.Errors$ErrorMessagesException
  at com.sun.jersey.spi.inject.Errors.processErrorMessages(Errors.java:170)
  at com.sun.jersey.spi.inject.Errors.postProcess(Errors.java:136)
at com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:199)

2 - If you try to access your RESTful service to get an XML format, you will get this exception:

java.lang.RuntimeException: javax.naming.NameNotFoundException: Unable to resolve 'com.sun.jersey.config.CDIExtension'. Resolved 'com.sun.jersey.config'; remaining name 'CDIExtension'
  at com.sun.jersey.server.impl.cdi.CDIExtension.getInitializedExtension(CDIExtension.java:177)
  at com.sun.jersey.server.impl.cdi.CDIComponentProviderFactory.(CDIComponentProviderFactory.java:92)
  at com.sun.jersey.server.impl.cdi.CDIComponentProviderFactoryInitializer.initialize(CDIComponentProviderFactoryInitializer.java:75)
  at com.sun.jersey.spi.container.servlet.WebComponent.configure(WebComponent.java:576)
  at com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.configure(ServletContainer.java:311)

 If you look at your server's log, (in my case, I was using WebLogic 12c) you may find this message somewhere:

WARNING: 
**********
The application is using ServletContainerInitializer class com.sun.jersey.server.impl.container.servlet.JerseyServletContainerInitializer that is loaded from:file:/labs/wls1211/modules/com.sun.jersey.server_1.1.0.0_1-9.jar. This initializer overrides the one available in the system.
**********

When you added Jersey to your library, the "package" checkbox was checked by default. So the JAR ended up going into WEB-INF/lib of your project, conflicting to the already provided by the container. 

So, how to fix this issue? Follow these steps:

  1. Open project's Properties (right click on the project)
  2. Go to Libraries
  3. Uncheck the checkbox 'Package' for Jersey 1.8 (JAX-RS RI)
  4. Click on 'OK'
  5.  Clean & Build (right click on the project) ---> remember to clean and rebuild your project
  6. (re)Deploy application

Done! :_)

 

Thursday Aug 02, 2012

Enable WebLogic 12c FastSwap with NetBeans

Hey everyone, this is my first post, and although I have been working at Oracle since July 2nd, I wanted it to have valuable information, not just a "Hey look, I joined Oracle". So this is it, welcome to my blog!

 How to enable WebLogic 12c FastSwap when developing Java EE applications with NetBeans? Very simple!

  1. Open the file WEB-INF/weblogic.xml
    1. If your application is an EAR, open weblogic-application.xml
  2. Enable FastSwap
    <fast-swap>
        <enabled>true</enabled>
    </fast-swap>
  3. Now open the Properties dialog for your project
  4. Navigate to Run
  5. Disable the checkbox "Deploy on Save"
  6. Close the Properties dialog
  7. Re-deploy your application

Done! Now give it a try. Modify some Java code and refresh the web page that access that code. Remember you don't need to re-deploy your application anymore. NetBeans already deploys it as exploded WAR/EAR. Faster than the re-deploy feature!

Also, FastSwap is a feature that is built-in to WebLogic 12c and there's no need to install anything. For more information about FastSwap, follow this link (for WebLogic 12.1.1).

Was this a valuable information for you? Sure it was for me :-) 

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
« July 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