Saturday, November 2, 2013

Setup WebLogic 12c environment with Vagrant and Puppet

For one of my presentations at DOAG 2013 I wanted to play around and checkout new features with the latest WebLogic version 12.1.2. To save some time and get experienced in some of the cool DevOps tools I gave a try for Vagrant and Puppet to setup a fresh new WebLogic 12c machine. BTW: All this is possible due to the impressive work Edwin Biemond has done in the last weeks and month (Checkout his powerful puppet modules https://github.com/biemond/puppet/) plus the Vagrant based provisioning script of Matthew Baldwin. (Checkout his recent blog post about that  http://vbatik.wordpress.com/2013/10/11/weblogic-12-1-2-00-with-vagrant/)

To give you a better overview of what I am going to do I created a simple diagram:

I am running the following test drive on Mac OS 10.8.5

Prerequisites
On your host system make sure the following tools are installed

1) Oracle VirtualBox 4.3
2) Vagrant 1.3.5
3) git

Before going on just open 'Terminal' and check if the command line tools are available.

akmac2:~ ak$ vagrant -v
Vagrant 1.3.5
akmac2:~ ak$ git --version
git version 1.7.12.4 (Apple Git-37)


Configuring the desired VM
akmac2: $ cd /Users/ak/Workspace/github
akmac2:github ak$ git clone https://github.com/matthewbaldwin/vagrant-wls12c-centos64.git
Cloning into 'vagrant-wls12c-centos64'...
remote: Counting objects: 280, done.
remote: Compressing objects: 100% (179/179), done.
remote: Total 280 (delta 90), reused 255 (delta 71)
Receiving objects: 100% (280/280), 612.79 KiB | 90 KiB/s, done.
Resolving deltas: 100% (90/90), done.
akmac2:github ak$
-------

Next I made some changes to the Vagrantfile and the provisioning script site.pp in order to get the binaries from my external software repository drive. The path on my local machine to the software binaries is as follows:
- /Volumes/EXT_AK_1TB/Downloads/oracle/oracle.java/jdk-7u25-linux-x64.tar.gz
- /Volumes/EXT_AK_1TB/Downloads/oracle/oracle.weblogic/wls_121200.jar

Changes to Vagrantfile done:
config.vm.synced_folder "/Volumes/EXT_AK_1TB/Downloads", "/software"

Changes to puppet/manifests/site.pp done:
...
jdk7::install7{ 'jdk1.7.0_45':
      version              => "7u45" , 
      ....
      sourcePath           => "/software/oracle/oracle.java",
  }
...
$puppetDownloadMntPoint = "/software/oracle/oracle.weblogic"


Now everything is set up to boot and provision the VM:
akmac2:vagrant-wls12c-centos64 ak$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
[default] Box 'centos64' was not found. Fetching box from specified URL for
the provider 'virtualbox'. Note that if the URL does not have
a box for this provider, you should interrupt Vagrant now and add
the box yourself. Otherwise Vagrant will attempt to download the
full box prior to discovering this error.
Downloading or copying the box...
Progress: 0% (Rate: 93585/s, Estimated time remaining: 3:23:20)

Successfully added box 'centos64' with provider 'virtualbox'!
[default] Importing base box 'centos64'...
[default] Matching MAC address for NAT networking...
[default] Clearing any previously set forwarded ports...
[default] Creating shared folders metadata...
[default] Clearing any previously set network interfaces...
[default] Preparing network interfaces based on configuration...
[default] Forwarding ports...
[default] -- 22 => 2222 (adapter 1)
[default] -- 80 => 8888 (adapter 1)
[default] -- 7001 => 7001 (adapter 1)
[default] Running 'pre-boot' VM customizations...
[default] Booting VM...
[default] Waiting for machine to boot. This may take a few minutes...
[default] Machine booted and ready!
[default] Setting hostname...
[default] Mounting shared folders...
[default] -- /vagrant
[default] -- /software
[default] -- /tmp/vagrant-puppet/manifests
[default] -- /tmp/vagrant-puppet/modules-0
Running Puppet with site.pp...
Info: Loading facts in /tmp/vagrant-puppet/modules-0/wls/lib/facter/oracle_middleware_homes.rb
Warning: Unrecognised escape sequence '\/' in file /tmp/vagrant-puppet/modules-0/jdk7/manifests/install7.pp at line 93
Notice: Compiled catalog for wls1212.enpitlocal.de in environment production in 2.03 seconds
...
Notice: /File[stopNodeManager.sh]/ensure: created
Info: Creating state file /var/lib/puppet/state/state.yaml
Notice: Finished catalog run in 572.02 seconds
akmac2:vagrant-wls12c-centos64 ak$

Vagrant automatically created the VM in the VirtualMachines folder of your VirtualBox.
and integrated it into the VirtualBox Manager

BTW: The downloaded vagrant boxes are stored in ~/.vagrant.d/boxes. During the download the stream is temporarily stored in ~/.vagrant.d/tmp. So make sure to have enough space in your home directory.


Working with the WLS 12c machine
Well this is pretty easy. Just run
vagrant ssh

to log into the running VM as user vagrant.

Typically you would like to work as oracle user. Just do
wls12c$ su oracle 

By default the root user is locked for security reasons. Any admin tasks can be done as vagrant user by sudo. Nevertheless you can unlock the root user with the following command

# After logging in as vagrant 
$ sudo passwd -u root 

Afterwards you can login with user root and pwd vagrant.

Minor Issues
(1)Vagrant provisioning with puppet
Info: Loading facts in /tmp/vagrant-puppet/modules-0/wls/lib/facter/oracle_middleware_homes.rb
Warning: Unrecognised escape sequence '\/' in file /tmp/vagrant-puppet/modules-0/jdk7/manifests/install7.pp at line 93

=> The Warning looks a bit strange but seems not to break the provisioning run!

(2)Trying to run the "service nodemanager_Wls12c start" I got an exception

oracle@wls1212 ~]$ service nodemanager_Wls12c start
/etc/init.d/nodemanager_Wls12c: line 31: /lib/lsb/init-functions: No such file or directory
[oracle@wls1212 ~]$

Solution: Commenting out line 31 in the init script worked for me ;)


Most important vagrant commands for a managed VM
$ vagrant up (on the first run the VM box is downloaded if needed, booted and provisioned by the configuration of the Vagrantfile. On any further runs the VM box is just booted but not provisioned.)

$ vagrant ssh (Logs into the running VM as user vagrant)

$ vagrant up --provision (Boot the VM and provision by the configuration of the Vagrantfile)

$ vagrant halt (shuts down the running VM)

$ vagrant reload (equivalent of running 'vagrant halt' and 'vagrant up')

$ vagrant reload --provision (equivalent of running 'vagrant halt' and 'vagrant up'  and 'vagrant provision')

$ vagrant suspend (Suspend the running VM)

$ vagrant resume (Resume the suspended VM)

$ vagrant provision (Run the provision scripts against the running VM. Great to test script changes)

$ vagrant destroy (The VM will be completely destroyed. Space is freed.)

Conclusion
The combination of Vagrant / Puppet / Puppet Oracle Modules is extremely powerful. It is possible to create predictable,  preconfigured "VMs from code". With this powerful set of scripts and tools it is quite easy to create new environments based on different Oracle FMW Versions. I guess that we (enpit) will automate the creation and configuration of our environments in the future.

Further information

Saturday, October 26, 2013

Content Integration through WebCenter Pagelets in WebCenter 11.1.1.8

Introduction
In this blogpost I am going to show how to integrate web content into WebCenter Pages by using a so called Pagelets - created by the WebCenter Pagelet Producer.

The Pagelet technology is pretty powerful. It acts like a proxy and works as a clipper for remote web content. It has its roots in WebCenter Ensemble and before that in Plumtree.

Prerequisites
The Pagelet Producer is part of a separate application (pagelet-producer) that by default runs on the WC_Portlets Managed server. So make sure that server is running.

Create a pagelet
To create a pagelet open the WebCenter Pagelet Producer Console at http://localhost:8889/pagelets/admin and login with the weblogic admin user.

Step 1: Create new Resource
Next: Select Producer Type: Web
Next: Give it a name, Define the Source URL etc.

Next: Define a pagelet: bundesliga-tabelle. The URL-Suffix is used to identify a specific resource from the source URL.

Now move on and create a new clipper. (With a clipper we actually are going to clip a portion of the source web page)

Next comes the most interesting + impressive part. Choose 'Content' and launch clipper. There you will be able to open the source web page in the clipper and choose the desired region:
As a result the 'clipping path' is updated. Save all changes.

Now we can test the pagelet under the 'Documentation" item.
As you can see the Pagelet is embeddable in any simple web page, not only WebCenter based.

Calling the the Pagelet URL in a new Browser-Tab we see that our pagelet is working. 
BTW: All Links are rewritten by default so it is working through the pagelet producer proxy. The clipped content can further be customized through so called 'Injectors' but I am not going to show that in this blog post. Please refer to the documentation (see links below).

Use Pagelets in the Portal Builder
To use the created pagelets in WebCenter Portal, the pagelet producer needs to be registered first.
Go to WebCenter Portal Administration > Tools and Services > Portlet-Producer. Choose 'Register'. Provide the given Producer URL as shown below.
Clicking on OK brings you to the overview page. The created pagelets should show up for the registered provider.
Next. Check if the Pagelets are listed under  "Shared Assets > Pagelets".

Now we can add the pagelets by using Portal Builder for a custom page. In the Portal Builder from the catalog choose ' UI Components > Pagelet-Producer > enpit Pagelets > 'pagelet-libraryname' > 'pagelet' ' and add it by drag and drop to your page. In my sample it looks like that

Save the page and open in view mode

That's it. WebCenter Pagelets - a great, powerful technology!

Gotchas
A) The pagelets is embedded inside an iframe by default. If I disable that option
there is an exception in the Portal Builder

I guess Portal Builder tries to embed  all the css, javascript, etc into the main web page which leads to an error. Just my assumption. If anyone knows more please comment!

B) The UI of the WebCenter Pagelet Producer Admin Console is really poor in terms of usabiliy, UX, etc. I hope it will be improved or/and will be embedded into WebCenter Portal Administration.

Related documentation

Thursday, September 5, 2013

ADF 11gR1: How to improve the UX of tables with filter


In a typical Oracle ADF application there might be a lot of tables with the query-by-example filter functionality. It is a great ADF standard feature that users love. However there is at least one thing that can be improved.

Use Case
Step 1: The user enters a filter criteria and performs the filtering.

=> The table data is filtered according to the criterion

Step 2: The user clicks on "QBE-Filter" button
=> The filter header row is not visible.
=> The table data is still filtered 
=> There is no hint for the user whether the data is filtered and if so how the data is filtered. From UX point of view the UI Feedback is not perfect.

How to improve
To  improve the user feedback it would be great to at least have a UI hint if the visible data is filtered or if the "Hide QBE-Filter" button would reset the filter. In this blogpost I am going to show a hack how you can achieve the latter one with ADF 11R1. 

Step 1: Create a Javascript file with the following content

The hack is to actually override the default showQBE function with a custom function that queues an AdfQueryEvent to clear all filter criteria before calling the default ADF showQBE function.

To register this override in JavaScript you must register a clientListener for the onLoad event in the JSF page.


Environment

Tested with
ADF 11.1.1.6 normal mode
ADF 11.1.1.7 normal and screenReader mode.

To my surprise this improvement is implemented in ADF 12.1.2! No need to hack if you are on the bleeding edge :)

Disclaimer
The described feature uses an unsupported ADF JavaScript Hack! So use on your own risk if your users want it and your stuck on 11gR1.

Wednesday, August 21, 2013

WebCenter: Checking the installed version information

Use Case

While installing WebCenter Portal 11.1.1.8 you will see a screen like the following during the domain creation

First I thought there is something wrong but beeing some time with Oracle technology now I know that these version information might just not be the one you really installing.

So the purpose of this post is to double check the WebCenter version once installed.

Check installed versions with OPatch

Create a checkversion.sh script like the following

export MW_HOME=/oracle/fmwhome11118
export ORACLE_HOME=$MW_HOME/Oracle_WC1
export JAVA_HOME=/oracle/javahome/jdk1.6.0_29
export PATH=$JAVA_HOME/bin:$PATH

java -version

$ORACLE_HOME/OPatch/opatch lsinventory -details -jdk $JAVA_HOME

The setting of Oracle is needed in order to run OPatch successfully.
Next run the script from the command line:

[oracle@soabpm-vm fmwhome11118]$ sh checkversion.sh
java version "1.6.0_29"
Java(TM) SE Runtime Environment (build 1.6.0_29-b11)
Java HotSpot(TM) 64-Bit Server VM (build 20.4-b02, mixed mode)
Oracle Interim Patch Installer version 11.1.0.9.9
Copyright (c) 2012, Oracle Corporation.  All rights reserved.


Oracle Home       : /oracle/fmwhome11118/Oracle_WC1
Central Inventory : /oracle/oraInventory
   from           : /oracle/fmwhome11118/Oracle_WC1/oraInst.loc
OPatch version    : 11.1.0.9.9
OUI version       : 11.1.0.9.0
Log file location : /oracle/fmwhome11118/Oracle_WC1/cfgtoollogs/opatch/opatch2013-08-17_06-35-49AM_1.log


OPatch detects the Middleware Home as "/oracle/fmwhome11118"

Lsinventory Output file location : /oracle/fmwhome11118/Oracle_WC1/cfgtoollogs/opatch/lsinv/lsinventory2013-08-17_06-35-49AM.txt

--------------------------------------------------------------------------------
Installed Top-level Products (1):

Oracle WebCenter Portal Suite 11g                                    11.1.1.8.0
There are 1 products installed in this Oracle Home.


Installed Products (42):

Application Server 11g Cloning Component                             11.1.1.8.0
Installer SDK Component                                              11.1.0.9.0
Jython                                                               11.1.1.7.0
Oracle Bali Share                                                    11.1.1.7.0
Oracle Business Process Management Process Spaces                    11.1.1.7.0
Oracle Display Fonts                                                 11.1.1.7.0
Oracle Extended Windowing Toolkit                                    11.1.1.7.0
Oracle Fusion Middleware Admin Config                                11.1.1.6.0
Oracle Help for Java                                                 11.1.1.7.0
Oracle Help for the Web - UIX                                        11.1.1.7.0
Oracle Help for the Web Shared Library                               11.1.1.7.0
Oracle Help Share Library                                            11.1.1.7.0
Oracle Ice Browser                                                   11.1.1.7.0
Oracle Jakarta                                                       11.1.1.7.0
Oracle JFC Extended Windowing Toolkit                                11.1.1.7.0
Oracle JGroups                                                       11.1.1.7.0
Oracle JSCH                                                          11.1.1.7.0
Oracle One-Off Patch Installer                                       11.1.0.9.9
Oracle Remote Diagnostic Agent                                       11.1.1.7.0
Oracle Remote Intradoc Client                                        11.1.1.8.0
Oracle SOA workflow                                                  11.1.1.7.0
Oracle UIX                                                           11.1.1.7.0
Oracle Universal Installer                                           11.1.0.9.0
Oracle Upgrade Assistant                                             11.1.1.8.0
Oracle Upgrade Assistant                                             11.1.1.8.0
Oracle Upgrade Assistant for Webcenter                               11.1.1.8.0
Oracle WebCenter Portal Suite                                        11.1.1.8.0
Oracle WebCenter Portal Suite 11g                                    11.1.1.8.0
Oracle WebCenter Portal: Activity Graph                              11.1.1.8.0
Oracle WebCenter Portal: Analytics Collector                         11.1.1.8.0
Oracle WebCenter Portal: Discussions Server                          11.1.1.8.0
Oracle Webcenter Portal: Framework                                   11.1.1.8.0
Oracle Webcenter Portal: Framework Core                              11.1.1.8.0
Oracle WebCenter Portal: Pagelet Producers                           11.1.1.8.0
Oracle WebCenter Portal: Personalization                             11.1.1.8.0
Oracle Webcenter Portal: Portlet Server                              11.1.1.8.0
Oracle WebCenter Portal: RCU                                         11.1.1.8.0
Oracle Webcenter Portal: Spaces                                      11.1.1.8.0
Oracle WebCenter Portal: Suite Components                            11.1.1.8.0
Oracle WebCenter Portal: Wiki                                        11.1.1.8.0
Oracle WebLogic Communications Service Client Library                11.1.1.7.0
OracleAS Documentation                                               11.1.1.8.0
There are 42 products installed in this Oracle Home.


There are no Interim patches installed in this Oracle Home.


--------------------------------------------------------------------------------

OPatch succeeded.
[oracle@soabpm-vm fmwhome11118]$

Further information
If you want to try out WebCenter follow the links for more information

Download WebCenter Portal 11.1.1.8

Neue Features und Änderungen in WebCenter Portal  11.1.1.8.0
http://docs.oracle.com/cd/E29542_01/doc.1111/e27603/whatsnew.htm#sthref8

See more Screenshots of the WebCenter Portal  11.1.1.8.0 on our german blog
http://www.enpit.de/webcenter-portal-11-1-1-8-mit-zahlreichen-neuerungen/

Saturday, August 17, 2013

ADF: Creating a custom train button bar, reflecting the disabled state

Requirement

In some cases there is a need to obtain more control over the ADF train button bar. The generated default does not allow to add an additional actionListener.



Environment

JDeveloper/ADF 11.1.1.7

Solution

There is a simple solution I found on http://www.adftips.com/2010/10/adf-ui-how-to-specify-actionlistener.html to create custom buttons for the previous / next functionality.


But there is still one thing missing. The buttons are always enabled. Unfortunataly there is no easy way to set the disabled property right from the given trainModel that is accessible by EL.

To solve this we create a managed bean as follows:



Now it is possible to bind the properties for disabled status




Similiar posts


Friday, August 2, 2013

JDeveloper 12c: Create RESTful Service from Java Class

With JDeveloper 12c finally it is possible to create RESTful Services from a Java Class. The implementation is based on Jersey following the Java EE 6 specification JAX-RS. For testing JDeveloper includes a comprehensive Tooling. In general RESTful services are really popular for mobile applications, e.g. ADF Mobile.

Get started
Create a simple Java Class for your business domain object plus a Service Facade that you want to expose as a RESTful Service.
Make sure to annotate the class with the @XmlRootElement otherwise the REST Service will not work for this domain object.

Next create a simple service facade with some test data, e.g.
package enpit.sample.adf12c.pojorest.model;
import java.util.ArrayList;
import java.util.Date;import java.util.List;

public class PersonService {

    
private List<Person> persons;
    
private Person person;

    
public PersonService() {
        
super();
        
this.persons = new ArrayList<Person>();
        
for (long i = 0; i < 10; i++) {
            Person p = 
new Person();
            p.setId(i);
            p.setFirstname(
"Firstname " + i);
            p.setLastname(
"Last " + i);
            p.setHiredate(
new Date());
            
this.persons.add(p);
        }
        
this.person = this.persons.get(0);
    }

    public List<Person> getPersons(){
        return this.persons;
    }

    public void addPerson(Person person) {
        System.out.println(
"add person " + person);

        
if(person != null){
            getPersons().add(person);
        }
    }
    public Person getPerson(){
        
return person;
    }
}

So far there is nothing special. 

Create RESTful Service with the help of JDeveloper 12c
Now comes the interesting part. Select the PersonService.java in the application navigator and
choose "Create RESTful Service…"

You will get a wizard to specify the RESTful Service interface. Set the desired root path. Choose the desired media types and the Methods you want to expose as REST Service
After finishing the wizard the following happens
- JAX-RS Annotations are generated  on the Java Class
package enpit.sample.adf12c.pojorest.model;
import java.util.ArrayList;
import java.util.Date;import java.util.List;import javax.ws.rs.Consumes;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;import javax.ws.rs.POST;import javax.ws.rs.Path;import
 javax.ws.rs.Produces;


@Path(
"rest")
@Produces(value = { "application/json""application/xml" })
@Consumes(value = { "application/json""application/xml" })
public class PersonService {

    
private List<Person> persons;
    
private Person person;

    
public PersonService() {
        
super();
        
this.persons = new ArrayList<Person>(){
        
for (long i = 0; i < 10; i++) {
            Person p = 
new Person();
            p.setId(i);
            p.setFirstname(
"Firstname " + i);
            p.setLastname(
"Last " + i);
            p.setHiredate(
new Date());
            
this.persons.add(p);
        }
        
this.person = this.persons.get(0);
    }

    @GET
    @Path(
"/persons")
    
public List<Person> getPersons(){
        
return this.persons;
    }

    @POST
    @Path(
"/person")    
    
public void addPerson(@FormParam("person"Person person) {
        System.out.println("add person " + person);

        
if(person != null){
            getPersons().add(person);
        }
    }

    @GET
    @Path(
"/person")
    
public Person getPerson(){
        
return person;
    }
}

- web.xml is created. The Jersey Servlet is configured properly.

Testing the RESTful Service in JDeveloper 12c
Jdeveloper is quite powerful. It lets you test the RESTful service right in the IDE.
Right-Click on the PersonService.java class and choose Run.

In background WebLogic Server 12c starts and the RESTFul Service gets deployed.

The WADL is kind of WSDL for RESTful Services. Clicking on the "Target Application WADL" URL brings you to the overview of the provided service operations

You can test each Service Operation right from the IDE. Pressing the "Test" Button brings you to the HTTP Analyzer Screen.
Here you can choose the Method, change HTTP Headers (e.g. what kind of media type you want to accept).
Press "Send Request" to actually test the Service Operation. Make sure to change the view to "HTTP Content" not "WADL Structure" otherwise you want see the pretty formatted output on the right hand side.

Change the Accept-Header to application/json and send the request again. The output automatically will be in JSON format.
The HTTP Analyzer is even so good to parse the POST Parameter to create a good looking form for data entry

Conclusion
Creating and Testing RESTful Services is really simple with JDeveloper 12c.

Friday, July 19, 2013

ADF 12c: Model-Driven LOV with Bean Data Control


Introduction

Prior to ADF 12c Model-driven input List-Of-Values (LOV) was a feature exclusively reserved to the ADF BC DataControl. With ADF 12c the Bean DataControl has been enhanced a lot. Now it is possible to create input LOVs the declarative way.

Prerequisites
You have a plain Java Object Model, for which you want to build the UI, including an LOV. In this sample we use Person, Address and a PersonService, which we want to expose as a DataControl
The adressId of Person should be filled through a LOV from available Address-Entities.

How to do it

First, create the DataControl from the PersonService: Right Click the PersonService.java class and Choose: Create DataControl


For this purpose, just keep the defaults in the wizard and complete with "Finish"

Open the generated DataControls.dcx, Select the Collection Type person and choose 'Edit'

The metadata file for the Person entity will be created. Next open the generated metadata file and configure the LOV on addressId as follows

Now the LOV is already configured and could be used for the UI Creation. If needed the LOV can be refined with UI Hints (as known from the ADF BC LOVs)

Now you can go on an build the UI. Drop the persons collection from the Data Control Palette onto the Page and
choose "ADF Form":

As indicated an ADF LOV Input will be crated for the addressId attribute. It can be further adjusted if needed in the next wizard screen

The LOV has been created

and can be tested at runtime.

The LOV Popup contains a query panel to limit the given values. As a wildcard only % is working. no Asterisk (*) what I personally would prefer. Anyway the LOV works as expected. In the sample the adressId is filled correctly.

Validation also works by default. If you try to enter an invalid value an error message pops up.

Download


Further Reading