Tuesday, January 31, 2012

Create your own keystore trust

password="welcome1"

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

http://stackoverflow.com/questions/6202653/difference-between-oracle-jdbc-driver-classes

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

http://docs.oracle.com/cd/E12840_01/wls/docs103/jdbc_drivers/oracle.html



Which Oracle DB version am I using?

SELECT version FROM v$instance;

I get 11.2.0.3.0

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

oracle.jdbc.xa.client.OracleXADataSource

wlsbjmsrpDataSource: In the Driver field, select a supported non-XA driver
http://docs.oracle.com/cd/E12840_01/common/docs103/confgwiz/howdoi.html


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

weblogic.jndi.retainenvironment

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


in WLInitialContextFactoryDelegate:

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


if (!keepEnvironmentUntilContextClose)
JNDIEnvironment.getJNDIEnvironment().popThreadEnvironment();


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)

WLST

connect(....)

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


the cmo is:

[MBeanServerInvocationHandler]com.bea:ServerRuntime=AdminServer,Name=uoo!uooq,Type=JMSDestinationRuntime,JMSServerRuntime=wlsbJMSServer

cmo.getMessagesCurrentCount()



Java

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();
  jmsjmx.countMessages();
 }
 
 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:


http://docs.oracle.com/cd/E11035_01/wls100/javadocs_mhome/weblogic/management/runtime/JMSDestinationRuntimeMBean.html


http://docs.oracle.com/cd/E12840_01/wls/docs103/javadocs/weblogic/jms/extensions/JMSRuntimeHelper.html



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);
   result.append(Long.toString(destMBean.getMessagesCurrentCount()));
   if (count < jndis.length - 1) {
    result.append(",");
   }
  }


  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 :

http://jvzoggel.wordpress.com/2012/01/23/osb_tracing_runtime/

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


Here more doc on this:

http://docs.oracle.com/cd/E17904_01/doc.1111/e15867/app_debugging.htm

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 := 
    <properties>
     <stageErrorDirectory>bla</stageErrorDirectory>
     <targetErrorDirectory>bla</targetErrorDirectory>
    </properties>
    
    let $match := $properties//*[name()=$propertyName]
    return
    if ($match) then
     $match/text()
    else 
     fn:error(xs:QName('IllegalArgument'), $propertyName)
};

declare variable $propertyName as xs:string external;

xf:getProperty($propertyName)


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

<ciao/>

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"/>
        </plt:role>
    </plt:partnerLinkType>
    <wsdl:types>
        <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"/>
        </schema>
    </wsdl:types>
    <wsdl:message name="GmAcmeTrackerCollection_msg">
        <wsdl:part name="GmAcmeTrackerCollection" element="top:GmAcmeTrackerCollection"/>
    </wsdl:message>
    <wsdl:portType name="AcmeDBInsert_db_ptt">
        <wsdl:operation name="insert">
            <wsdl:input message="tns:GmAcmeTrackerCollection_msg"/>
        </wsdl:operation>
    </wsdl:portType>
</wsdl:definitions>



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:

Vaadin...

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):

http://officeimg.vo.msecnd.net/en-us/files/325/058/ZA010351135.jpg


Prepare/Properties

( 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:

CTRL-F9
right click
edit field
field name=DocProperty and select your property


( this is explained very well here)


TRICK: you can achieve the same by:
CTRL-F9 then type DOCPROPERTY YOURPROPERTNAME
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:

http://www.dummies.com/how-to/content/how-to-manage-your-styles-in-word-2007.html

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...
http://wordprocessing.about.com/od/usingtemplatesandaddins/l/blwordtemp.htm

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

http://www.roseindia.net/jsp/file_upload/Sinle_upload.xhtml.shtml


on multipart/form-data:

http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.2

if you add in the index.jsp

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


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:

http://www.jguru.com/faq/view.jsp?EID=1045507

http://commons.apache.org/fileupload/

interesting code snippets here

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

looks too complicated...


I would rather use

http://www.servlets.com/cos/javadoc/com/oreilly/servlet/MultipartRequest.html

getParameter(java.lang.String name)

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

but, wait a minute, I find this
http://stackoverflow.com/questions/3238103/extracting-parameters-of-a-httprequest-when-form-type-is-multipart


http://commons.apache.org/fileupload/apidocs/org/apache/commons/fileupload/servlet/ServletFileUpload.html

http://commons.apache.org/fileupload/apidocs/org/apache/commons/fileupload/disk/DiskFileItemFactory.html


Some other posts on the topic:

http://stackoverflow.com/questions/1545717/issue-with-multipart-form-data


http://stackoverflow.com/questions/1748259/get-form-parameters-from-multipart-request-without-getting-the-files

http://stackoverflow.com/questions/3238103/extracting-parameters-of-a-httprequest-when-form-type-is-multipart

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:

http://javatoolsforweblogic.googlecode.com/svn/trunk/fileUpload/index.jsp
http://javatoolsforweblogic.googlecode.com/svn/trunk/fileUpload/single_upload_page.jsp


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

http://www.amazon.com/Do-more-SOA-Integration-Packt/dp/184968572X/ref=sr_1_1?ie=UTF8&qid=1326096025&sr=8-1




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

DevOps

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:

http://blog.carlossanchez.eu/2012/01/02/about-devops/

http://en.wikipedia.org/wiki/DevOps
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"