Tuesday, January 31, 2012

Create your own keystore trust


keytool -genkey -validity 10000 -alias acme -keyalg RSA -keysize 1024 -dname "CN=acme, OU=Engineering, O=YourCompany, L=YourCity, ST=YourRegion, C=YourCountryCode" -keypass acmepw -keystore identity-acme.jks -storepass $password

# Self Sign the certificate

echo $passWord | keytool -selfcert -validity 10000 -v -alias acme -keypass $passWord -keystore identity-acme.jks -storetype jks

# Export the root certificate

echo $passWord | keytool -export -v -alias acme -file identity-acme.der -keystore identity-acme.jks

# Import the root certificate back with the same name as in step 1 and step 2

keytool -import -v -alias acme -trustcacerts -file identity-acme.der -keystore acme-trust.jks

OSB Datasources

sparse notes here....

oracle.jdbc.driver.OracleDriver vs. oracle.jdbc.OracleDriver


so oracle.jdbc.driver.OracleDriver is deprecated, uh?


Which Oracle DB version am I using?

SELECT version FROM v$instance;

I get

If you do "SELECT * FROM g$instance" in Oracle RAC you get the same view.


wlsbjmsrpDataSource: In the Driver field, select a supported non-XA driver

For Supported Configurations Matrix: http://www.oracle.com/technetwork/middleware/ias/downloads/fusion-certification-100350.html
For OSB http://www.oracle.com/technetwork/middleware/ias/downloads/osb-11gr1certmatrix.xls

Monday, January 30, 2012


if you specify -Dweblogic.jndi.retainenvironment=true in the WLS command line,

in WLInitialContextFactoryDelegate:

String s = System.getProperty("weblogic.jndi.retainenvironment");
if(s != null)
keepEnvironmentUntilContextClose = true;

if (!keepEnvironmentUntilContextClose)

I am trying to understand what this - seemingly undocumented - parameter does.

If you have an idea, pleas leave a comment...

Sunday, January 29, 2012

Counting JMS messages present in a JMS Queue

here we show 2 ways:

(I have a wlsbJMSServer JMSServer, a uoo JMSModule, a uooq JNDI name for the Queue)



cd serverRuntime:/JMSRuntime/AdminServer.jms/JMSServers/wlsbJMSServer/Destinations/uoo!uooq

the cmo is:




package com.acme.gu.jms;

import java.util.Properties;

import javax.jms.Destination;
import javax.jms.JMSException;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import weblogic.management.runtime.JMSDestinationRuntimeMBean;
import weblogic.jms.extensions.JMSRuntimeHelper;

public class JMSJMX {
 public static void main(String[] args) throws NamingException, JMSException {
  JMSJMX jmsjmx = new JMSJMX();
 public void countMessages() throws NamingException, JMSException {
  Properties env = new Properties();
  env.put(Context.PROVIDER_URL, "t3://localhost:7001");
  env.put(Context.SECURITY_PRINCIPAL, "weblogic");
  env.put(Context.SECURITY_CREDENTIALS, "weblogic1");
  env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
  InitialContext ctx = new InitialContext(env);

  Destination queue = (Destination) ctx.lookup("uooq");

  JMSDestinationRuntimeMBean destMBean = JMSRuntimeHelper.getJMSDestinationRuntimeMBean(ctx, queue);
  System.out.println("count: " + destMBean.getMessagesCurrentCount());

see also:



If you want to invoke the same code in OSB, you can use this variant:

package com.acme.gu.jms;

  * Method to be run inside a Container
  * @param jndis
  * @return
  * @throws NamingException 
  * @throws JMSException 
 public static String countCurrentMessages(String[] jndis) throws NamingException, JMSException {
  StringBuffer result = new StringBuffer();
  InitialContext ctx = new InitialContext();

  for (int count = 0; count < jndis.length; count++) {
   Destination queue = (Destination) ctx.lookup(jndis[count]);
   JMSDestinationRuntimeMBean destMBean = JMSRuntimeHelper.getJMSDestinationRuntimeMBean(ctx, queue);
   if (count < jndis.length - 1) {

  return result.toString();

And you invoke it with a Java Callout, passing in input a Sequence ('jndi1', 'jndi2') which is converted automatically in a String[] I am returning a CSV list (String), because a String[] as a return parameter in converted into a Java object, which is not easy to access in OSB. Make sure you associate a Service Account (static) to the Java Callout, because when you create a new InitialContext without associating credentials, OSB attaches an anonymous user and you get an error: Callout to java method "public static java.lang.String[] com.acme.gu.jms.JMSJMX.countCurrentMessages(java.lang.String[]) throws javax.naming.NamingException,javax.jms.JMSException" resulted in exception: javax.naming.NoPermissionException: User <anonymous> does not have permission on weblogic.management.adminhome to perform lookup operation. weblogic.jms.common.JMSException: javax.naming.NoPermissionException: User <anonymous> does not have permission on weblogic.management.adminhome to perform lookup operation. at weblogic.jms.extensions.JMSRuntimeHelper.getJMSDestinationRuntimeMBean(JMSRuntimeHelper.java:458) at com.acme.gu.jms.JMSJMX.countCurrentMessages(JMSJMX.java:49) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at stages.transform.runtime.JavaCalloutRuntimeStep$1.run(JavaCalloutRuntimeStep.java:173)

The alternative is to enable "Anonymous Admin Lookup Enabled" in "View Domain-wide Security Settings" in WebLogic console.

Friday, January 27, 2012

Tracing and debugging in OSB

There are alternatives to putting LOG statements in the message flow.

One is activating payload tracing :


also, be aware that there are 2 files alsbdebug.xml and configfwkdebug.xml in $DOMAIN_HOME:

Here more doc on this:


Wednesday, January 25, 2012

Global warming is just a myth

fueled by conspiracy theorists.

I have taken this picture biking on the Alps. Normally in this season we would have half a meter snow in the valley - 600 meters above sea level. Now to find half a meter snow you must go at 2000 meters - these mountains are 3000 meters high. What is shown is the North face - the South face is even more free from snow.

All sort of tree are blossoming. In January. They too must be part of this delusional wave called "climate crisis theory".

Of course all this is just a statistical fluctuation, things will go back to normal and we can happily keep burning oil, cutting trees and behaving like there is no tomorrow.

Sunday, January 22, 2012

XQuery to return a property value

Too often in OSB developers hardcode property values everywhere in the Message Flow.
This makes life difficult, especially if these are environment-dependent values.

Waiting for Oracle to provide a decent way to externalize variables in a property file and read it from OSB (you can do that with a Custom XPath.... but the problem is that the property file would not be visible/editable from the OSB console, which is a pity...)...
you can use this approach:

xquery version "1.0" encoding "Cp1252";

declare namespace xf = "http://tempuri.org/OSBProject1/getProperty/";

declare function xf:getProperty($propertyName as xs:string)
    as xs:string {
    let $properties := 
    let $match := $properties//*[name()=$propertyName]
    if ($match) then
     fn:error(xs:QName('IllegalArgument'), $propertyName)

declare variable $propertyName as xs:string external;


This code shows also 2 interesting things:
- how to find a node with a given element name (using *[name()='something'] )
- how to raise a well readable error message with fn:error()

Saturday, January 21, 2012

OSB rejected messages handling with WSIF

Here http://ws.apache.org/wsif/ the official Apache page on WSIF

I have tried assigning a dummy WebService (based on a sample WSDL generated by Eclipse)

In the "JCA Transport Configuration" of my Proxy Service I specify:

EndPoint Properties rejectedMessageHandlers = "wsif://http://localhost:7001/errorpoller/errorhandlerws?WSDL|newOperation|in"

Of course it doesn't work, I get this error:

JCA_FRAMEWORK_AND_ADAPTER BEA-000000 Rejection handler failed Rejection handler failed Error while trying to hand off bad message to Rejection handler wsif://http://localhost:7001/errorpoller/errorhandlerws?WSDL|newOperation|in due to: Unable to find an available port Please address the underlying issue or correct/redeploy the process

Here http://docs.oracle.com/cd/E12839_01/integration.1111/e10231/life_cycle.htm#BABGIGGI at "Web Service Handler" they report a sample payload schema, but it's all broken. It was impossible to find a complete WSDL for a proper Web Service Handler. How sad.

In fact it was my mistake, I should specify: Absolute wsdl path|service name|port name
and the port name is "NewWSDLFileSOAP" and the service name is "NewWSDLFile"
so I try with rejectedMessageHandlers = "wsif://http://localhost:7001/errorpoller/errorhandlerws?WSDL|NewWSDLFile|NewWSDLFileSOAP"

All of a sudden I find this example of rejectionmessage.wsdl : http://bentaljaard.wordpress.com/2010/10/22/creating-a-bpel-rejected-message-handler-for-ftp-file-polling/

referring to this http://oraintpc.blogspot.com/2007/10/in-action-adapter-rejection-handlers-in.html

sounds cool! I try to implement it stealing this WSDL
it turns out that in the oracle.tip.adapter.fw.agent.jca.JCAActivationAgent there is a property "portType" which needs to be set! Of course in the Oracle documentation there is no mention of this, they only say to set the property "rejectedMessageHandlers"

Here http://docs.oracle.com/cd/B14099_19/integrate.1012/b14058.pdf is says

WSIF Based Rejection Handler: In WSIF based Message Rejection handler, you can configure any type of WSIF WSDL, such as JCA, EJB, JMS, HTTP, and Java. You can configure any kind of service that can be reached through WSIF as the bad message handler.
The syntax for specifying a WSIF based Message Rejection handler is as follows:

<property name="rejectedMessageHandlers"> wsif://<wsif-wsdl-location>|<operation-name>|<input-message-part-name> </property>

You can specify a WSIF based Message Rejectionhandler as shown in the following example:

<property name="rejectedMessageHandlers"> wsif://file:/C:/orabpel/samples/test/ErrorTest/FileAdapterWrite.wsdl|write|mess age </property>

The WSIF based Message Rejection handler has the same constraint on message type as that of BPEL Process Rejection Handler. Refer to the BPEL Process Rejection Handler section.

still working on this... not a single COMPLETE working example available on the entire internet...

Friday, January 20, 2012

XQuery, extract file name from directory

fn:tokenize(fn:replace($theDirectory, '\\', '/'), '/')[fn:last()]

input: C:\tmp\bla\po\in\if2

output: if2

Thursday, January 19, 2012

rename namespace

a small note to myself on how to change namespace of a xml element in OSB

input is


output is

<lap:ciao xmlns:lap="http://www.laperrasucia.com"/>

A callout cannot invoke a one-way operation

I have created a DBAdapter JCA Client invoking an INSERT operation
JDeveloper generates this WLSD:

<?binding.jca AcmeDBInsert_db_db.jca?>
<wsdl:definitions name="AcmeDBInsert_db" targetNamespace="http://xmlns.oracle.com/pcbpel/adapter/db/AcmePOC_Sharath/Acme_POC_Acme_WMS/AcmeDBInsert_db" xmlns:tns="http://xmlns.oracle.com/pcbpel/adapter/db/AcmePOC/Acme_POC_Acme_WMS/AcmeDBInsert_db" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:plt="http://schemas.xmlsoap.org/ws/2003/05/partner-link/" xmlns:top="http://xmlns.oracle.com/pcbpel/adapter/db/top/AcmeDBInsert_db">
    <plt:partnerLinkType name="AcmeDBInsert_db_plt">
        <plt:role name="AcmeDBInsert_db_role">
            <plt:portType name="tns:AcmeDBInsert_db_ptt"/>
        <schema xmlns="http://www.w3.org/2001/XMLSchema">
            <import namespace="http://xmlns.oracle.com/pcbpel/adapter/db/top/AcmeDBInsert_db" schemaLocation="xsd/AcmeDBInsert_db_table.xsd"/>
    <wsdl:message name="GmAcmeTrackerCollection_msg">
        <wsdl:part name="GmAcmeTrackerCollection" element="top:GmAcmeTrackerCollection"/>
    <wsdl:portType name="AcmeDBInsert_db_ptt">
        <wsdl:operation name="insert">
            <wsdl:input message="tns:GmAcmeTrackerCollection_msg"/>

the "insert" operation is a one-way operation (no wlsd:output clause)

The problem is that the Service Callout expects a request-reply pattern.

So in this case you must necessarily use a Publish, with Quality of Service "Exactly Once" to execute in the same transaction and with a blocking operation.

Wednesday, January 18, 2012

JMA supports SOPA and PIPA

After all, Middle Ages were cool, with all those witches burnt on a stake, entertainment was bountiful.

We also support Stalinism, and the Freedom to shut in prison whomever we want without evidence. Freedom is a good thing.

Uh, also Nazi Book Burning is cool, it's such a pity that websites burning can't keep you warm in winter:

Monday, January 16, 2012

What a developer thinks about Vaadin

(guest post)
I have interviewed a good friend who has been using Vaadin at his job for 6 months. Here is what he says:


Too be short, it's like any framework trying to do generate everything for you.
Great at the things the demo application does. Not always so great at the things you really want to do.

The plus side is that it is all Java, and thus for the most part extendable.
The down side is that you have to do this a bit too often.

If at our company we were not forced to use a framework built on top of the Vaadin framework, I would say it upped the productivity.
Vaadin gives a lot of freedom. If you're going to build something on top of it, try to retain most of that freedom.
A lesson I'm trying to teach our architects ...

All in all, it's better then the struts world I've been accustomed too. But the holy grail it is not...

Sunday, January 15, 2012

How to create and use Custom Document Properties in Word 2007

Create the property:

Clic on the Microsoft Office Button (top left):



( you can acheve the same with Alt-F Alt-E Alt-P)

a Properties ribbon appear under the main ribbon.
Click on the drop down list "Document Properties - Server" and choose advanced properties

Click on the Custom TAB

Enter a property name AND a property value, and click ADD.
I suggest to prefix YOUR custom properties with a prefix, like PV_, to distinguish them from built-in properties.

To insert a property in your document:

right click
edit field
field name=DocProperty and select your property

( this is explained very well here)

TRICK: you can achieve the same by:
then right-click and "update field"

OR use ALT-F9 to display field codes and edit them, then ALT-F9 again to revert to normal mode.

or simply copy/paste an existing field, then right-click and edit field.

For help on Word Field Codes: http://office.microsoft.com/en-us/word-help/field-codes-in-word-HA010100426.aspx

My conclusion: Microsoft has done a very poor job when it comes to be able to externalize strings and include them dynamically in the document. I have seen better tools 20 years ago.

Saturday, January 14, 2012

Writing proper technical documents with Word 2007 +

I am a geek and I always hated writing good looking doc...
I LOVE to document stuff, but only on a merely technical level (Javadoc, wikis, TDD, comments in code...).

When it comes to writing Word documents, all sort of aesthetic considerations come into account (font size, uniformity of the styles across the suite of documents etc), and a real macho-geek considers aesthetic issues something a bit borderline like homosexuality.

So the statement "I can write very good Word Documents" sounds like "I wear a pink pajama at night and I spend hours massaging my body with perfumes in the shower".
Real geeks don't waste time with Word. Real men don't wear pajamas and they rarely shower unless they have to - sweat it their only perfume.

But real men know how to bite the bullet and do something even if they hate it.

First thing occurring to my weak mind: use styles everywhere:


styles are the only way to ensure uniform presentation, and to quickly change look and feel of a document.

Styles: Ctrl+Shift+Alt+S, Manage Styles, export.... this only exports existing styles to an existing template....

there is a normal.dotm template. you want to create your own template.
You can save your document as "word macro-enabled template (*.dotm)"

But, wait a second, how does a template work? I have never used them...

Something interesting is also CUSTOM PROPERTIES.... Microsoft Office Button Button image, point to Prepare, and then click Properties.
On the Custom tab, you can add the name of a new property, but the Add button for that property remains disabled until you also assign a value (a point many users miss).

Here it explains the pain of enabling the "Insert property" option in the menu...

IT'S AWFUL the castration produced by Microsoft in the new 2007 menus, every single person I talk to HATES the new menus....

Ok, I stop here... on the whole I find the new Word incredibly complicated for those who want to use a professional but straightforward use... all the functionality is there, but they make it very difficult to use it. The "old style" menus where a lot more intuitive.

And, I still believe that every project should hire a (maybe part-time) technical writer, you can't expect very talented technical people to excel in word (hahaha pardon the pun).

Wednesday, January 11, 2012

Web Application to upload a file to any directory


on multipart/form-data:


if you add in the index.jsp

<td><b>Choose the destination directory:</b></td>
<select name="targetDirectory">
<option value="c:/tmp">c:/tmp</option>
<option value="c:/temp">c:/temp</option>

and you do:

Object targetDirectoryAttribute = request.getAttribute("targetDirectory");
String targetDirectoryParameter = request.getParameter("targetDirectory");
System.out.println("targetDirectoryAttribute=" + targetDirectoryAttribute);
System.out.println("targetDirectoryParameter=" + targetDirectoryParameter);

they are both null

on how to read parameters in a multipart/form-data form:



interesting code snippets here

invoke readHeaders() in org.apache.commons.fileupload.MultipartStream

looks too complicated...

I would rather use


getParameter(java.lang.String name)

so I download http://www.servlets.com/cos/cos-26Dec2008.zip

but, wait a minute, I find this



Some other posts on the topic:




Eventually I give up on all those horrible libraries, and I add a second for an a onclick javascript to add in the HTTP query the directory info...

See the working result here:


Anyway this is disgusting, the way this HTTP Java Servlet technology turns simple things in a total nightmare.... no wonder people turn to other technologies...

Monday, January 9, 2012

Planet is screwed? Maybe....

but it's not a reason to stop loving it and defending it ....

SOA Integration Best of Packt - a compendium of books and techniques


Do more with SOA Integration: Best of Packt

It looks promising....

Thursday, January 5, 2012

Glenn Gould - Beethoven's "Emperor" Concerto

simply inspiring...

Channel Purger vs Message Filter

It was not clear to me the difference between the 2:

http://eaipatterns.com/ChannelPurger.html this is meant to remove from a CHANNEL (IN PARALLEL TO THE MAIN FLOW) spurious bogus messages that should be prevented from reaching the main flow (e.g. test messages or old expired messages)

http://eaipatterns.com/Filter.html a filter is used IN SERIES TO THE MAIN FLOW to discard irrelevant (but perfectly legal) messages

So the difference is like between a parallel spike suppressor and a series filter (pardon me for being an electronic engineer).

Wednesday, January 4, 2012


As a developer and architect, I am VERY proud of having spent a few years of my life doing production support. Having been "on the other side of the barricade" gives you great clues on how an application should be conceived to avoid operational nightmares.

So, welcome to DevOps.

Here a link to a great post on the topic:


generalities on DevOps
http://theagileadmin.com/2010/10/15/a-devops-manifesto/ a DevOps Manifesto

« Infrastructure is code, and should be developed and managed as such.”
“Simplicity–the art of maximizing the amount of work not done–is essential.”

“Giving developers more environment control »
« Automating as much as possible”
“Collaboration between dev and ops »

“iterative development ... each release has less change but occurs more often. This creates a smooth rate of progressive application change vs. the large impact effect of rare deployments–each of which contains a large number of changes.”

(carefully avoiding here the word “agile” because a too overloaded word)

Thinking in silos:

Tuesday, January 3, 2012

javax.resource.spi.InvalidPropertyException: Duplicate Property Values Exception. The properties [xADataSourceName] and [dataSourceName (both in connector properties)] can not both be [jdbc/SOADataSource].

ok, I have done it again...

in the JCA file adapter outbound connection pool instance, you should configure only.
either dataSourceName, or xADataSourceName... NOT BOTH! Du blöder Einer! Dummkopf!

* "Du blöder Einer" is a yiddish-german expression. it means "you stupid"