Tips & Tricks that’ll save you a lot of time regarding ODI, Flex, Soa Suite

Latelly I’ve been spending a lot of time regarding deployment and configuration of Adobe Flex applications integrated with Bpel on an OC4J-container.

On the other hand I’ve been experimenting a lot with ODI and how the tool will handle changing data models, changing datasources, …

Lastly I’ve been playing around with invocation of Bpel Processes using Web Service Proxy Clients instead of the Bpel Invocation API.

The question that’s still unanswered because no documentation or benchmarks or best practices are available yet is: ‘What’s the best practice in invoking bpel processes, the Bpel Invocation API or Web Service Proxy Clients?’

Tips & Tricks ODI:

  • Interesting Notes: 423740.1, 423817.1
  • Grant dba-privileges to your source-db-user, otherwise you’ll get ‘insufficient privileges’ exceptions when trying to execute your interfaces

Handling changing data models (new tables, deletion of existing attributes in tables, addition of new attributes, additional relationships, … ) :

  • Go to your datamodel and reverse engineer the changed tables again. New attributes are added, deleted attributes aren’t removed yet because they’re referenced in interfaces in your ODI Designer.
  • Go to your interfaces defined in the Designer-tab in ODI: remove all active mappings to the attributes that were deleted
  • Go back to the model-tab in designer and right-click the attribute in your tabel and choose delete. When all references are updated correctly (no active mapping), the attribute will be deleted from your datamodel

Tips & Tricks Flex:

  • When you’re getting weard errors regarding ‘conversion exception between java.util.Date and java.util.Calendar’ or exceptions regarding producer or consumer-errors => make sure you’ve defined ‘autocommit’-property to false on your data services (Using LCDS)
  • How to handle static data without usage of Value Object or Data Transfer Objects => use SQLAssembler without usage of java-classes or actionscript-classes in your data-management-config.
  • rtmp-host connection failure on OC4J => try to reset the connection-port to another value than the default one which is ’2038′. I’ve defined the value to ’2035′ and now no errors are thrown anymore
  • Use [managed] attribute to make sure all changes on objects are synced between 2 clients
  • Deploying data-management-config to different JEE Servers, e.g. Tomcat and OC4J. When you deploy to tomcat you have to define the full JNDI-location which would be for example: java:/comp/env/jdbc/flexDS. When you deploy to an OC4J, you need to define the short JNDI-descriptor: jdbc/flexDS.

The other exceptions, weard behaviour was already addressed in earlier posts:

  • You need to add an xsl-choose-when-otherwise xsl-node structure to you transform-activity in your bpel-process and in the otherwise-tag define the xsi:nil=true on your attribute to make sure the web service proxy won’t set this attribute to required.
  • You need to update the toplink-mapping file being generated in bpel when using the database adapter. Relationships aren’t defined properly, because the method accessor is checked for all one-to-many relationships whilst these aren’t defined in the java wrapper classes. Uncheck these ‘map to method accessors’ and these exceptions will disappear. You can uncheck these when drilling down in your toplink.mwp file into to your object on your mappedCollections.

A beautiful one were all newbees in SOA Suite spend ages and ages to figure out what the problem is … Oracle please fix this ???

You’ve installed SOA Suite (you can choose which version) and entered a custom password during installation for your oc4jadmin-password, not the ‘welcome1′ password. You can choose your own password wright ?

But when the newbee starts creating his first bpel and esb projects, there are weard errors poping up: ‘connection timed out’, ‘jndi-location for db-adapter isn’t properly defined’, …

Well, weard but true, the ‘welcome1′ password is defined hardcoded in different ‘oc4j-ra.xml’ files used in the jmsadapter-folder, dbadapter-folder, … Make sure to change the passwords correctly when you’re drilling through the different Oracle By Example-exercices or tutorials.

Integrating Flex and Data Management Services with a Bpel process – What about Typed Collections?

As you can remember we’re working out a flex application using Data Management Services and Flex for the client-side and Bpel at server side.

During development I ran into a blocking issue regarding using typed collections in my ActionScript objects.

Why would I use Typed Arguments, Typed Collections or Typed Arrays ?
My bpel process is using a Global Business Object (GBO), an XML Schema Definition, that defines the entire structure of the business objects I will need in the dossier management lifecycle. The bpel process will be cut pu into different sub processes which will define the needed process lifecycle for the dossier management system we’re building.

Of course this kind of business functionality will be handling master-detail data, e.g. a dossier has dossier_members and dossier_members have address_information.

If we create a web service proxy client for our bpel process, the different objects used in this process will be defined as Java Objects. The hierarchical structure of the dossier-element or – object will be defined in the following manner:

public class Dossier implements java.io.Serializable {
protected int id;
protected be.ws.proxy.types.DossierMembersCollection dosMembersCollection;

public class DossierMembersCollection implements java.io.Serializable
{
protected be.kg.ws.proxy.types.DossierMembers[] dossierMember;

The ActionScript Objects I defined for these server side objects :

[Managed]
[RemoteClass(alias="be.kg.ws.proxy.types.Dossier")]
public
class Dossier
{
public var id:int;
public var dosMembersCollection:DossierMembersCollection;

[Managed]
[RemoteClass(alias="be.kg.ws.proxy.types.DossierMembersCollection")]
public class DossierMembersCollection
{
public var dossierMembers:ArrayCollection;
}

The exception I run into :

ArgumentError: Error #2004: One of the parameters is invalid. at
flash.net::NetConnection/flash.net:NetConnection::invokeWithArgsArray()

What does this mean?
In order for this to work, you need to serialize, you’d need to override both the readExternal and writeExternal methods on both the client and server to take of the serialization of the typed collections yourself.

Practical Approach:

  • Implement the Externalizable Interface at Client- and Server-side
  • Overwrite the readExternal()- and writeExternal()-method in both your client and server classes which match (i.e. the read methods exactly match the write methods on both client and server). You need to serialize your fields as well as the source field of the ArrayCollection (it is an Array).

Take care of serialization and deserialization at server-side, use Externalizable Interface:

public class DossierMembersCollection implements java.io.Serializable ,
Externalizable { protected be.kg.ws.proxy.types.DossierMembers[] dossierMembers;

public DossierMembersCollection() { }

/*** Deserializes the client state of an instance of dossierMembers. */ public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException {
System.out.println(“Receiving array ———————–”);
Object[] obj2 = (Object[]) in.readObject();
System.out.println(“Read input array obj2 ———————–”);

if (obj2 != null) {
DossierMembers[] dossierMembers = new DossierMembers[obj2.length];
System.out.println(“Initialized dossierMembers———————–”);
loop over the object array and cast the Object-classes to your custom class.
System.out.println(“Looping over array ———————–”); dossierMembers[i] = (DossierMembers) obj2[i];

System.out.println(“DossierMembers: ” + dossierMembers[i].toString());
}}

System.out.println(“Receiving array DONE ————————”); }

/*** Serializes the server state of an instance of dossierMembers. */

public void writeExternal(ObjectOutput out) throws IOException { out.writeObject(dossierMembers); }

Take care of serialization and deserialization at client-side:

[Managed]

[RemoteClass alias="be.kg.ws.proxy.types.DossierMembersCollection")]

public class DossierMembersCollection implements IExternalizable {

public var dossierMembers:ArrayCollection;

public function readExternal(input:IDataInput):void {
trace(“***********Reading dossierMembers”);
var array:Array = input.readObject() as Array;
if (array!=null) {
trace(“****Array received”);
dossierMembers = new ArrayCollection();
Loop over the array and add the arrayElements as typed objects to your collection in the following way:

dossierMembers.addItem(array.pop() as DossierMembers);

trace(“**Number of dossierMembers : ” + dossierMembers.length); }

public function writeExternal(output:IDataOutput):void {

trace(“Write ArrayCollection dossierMembers to array”);

var array:Array = new Array();

loop over object-array and add array-items to the collection: {

array.push(dossierMembers.getItemAt(i));

trace(dossierMembers.getItemAt(i).toString()); }

output.writeObject(array); trace(“Done”); } }

If you get random errors there will propbably be a mismatch between server- and client-side objects. The two approaches you can use are: print statements or stopping in your read/write external methods in the debugger. Step through actionscript classes and Java classes using Flex Debugging mode, so you can ensure that you are reading exactly what you are writing.

Hopefully this will help a lot of people facing the same issues regarding typed objects in an Adobe Flex Environment.

FLEX SQLAssembler

Recently I have been working with Adobe Flex and Adobe LiveCycle Data Services for building a dossier-management system.

I came around some strange behavior which I couldn’t understand regarding displaying referential/static data in a flex user interface.

The requirement I need to implement in my flex application is to display static, referential data in the different forms being filled in by the user.

This data needs to be looked-up and displayed in for example dropdown-lists and can be adjusted by administrator, so no CRUD-operations are needed in the entry-module of the application.

What I wanted to do is fill some ArrayCollections with data stored in an Oracle 10G database. I don’t want to convert my data to actionscript or java objects, no transfer objects or value objects because I just want to display them so I won’t use any adapters. I made a new destination in my data-management-config and added a fill:

<fill>
<name>dossier_types</name>
<sql>SELECT cd as “cd”,
omschrijving as “omschrijving”
FROM dossier_types</sql>
</fill>

You might notice that I used an alias in my query, initially I didn’t know this but without the alias I can’t display any data. For me this seemed the right solution to retrieve my data but when I tried it I didn’t retrieve anything. I couldn’t see the data in the console of my tomcat server either; my ArrayCollection always had length 0.

Not sure for what reason but I put in a JavaAdapter :

<adapter ref=”java-dao” />

Referencing to:

<adapter-definition id=”java-dao”
class=”flex.data.adapters.JavaAdapter” />

Out of the blue the ArrayCollection was populated with the wright data. Note that I did not specify any java class in my destination. I also tried to use the actionscript adapter but then I couldn’t receive any data.

I’m not sure this is the behavior I must expect but for now it works and I don’t need to define any transfer-objects in the form of actionscript or java objects, which is what I wanted to accomplish.

Buzzing About Adobe Flex – Part 2

Some useful background information you need to know about Adobe Flex … (which you can find in the Adobe Flex Developer Guide):


About Flash Player 9
While Flex applications run in a browser, they take advantage of the Flash Player 9 runtime environment for executing client-side logic, rendering graphics, and playing animation, audio, or video.
Flash Player 9 supports a new higher-performance version of ActionScript
(ActionScript 3.0) that works in conjunction with the expressiveness innovations
in Flash Player 8.

At the core of the Flex product line is the Flex Software Development Kit (SDK). Flex 2 SDK consists of the Flex framework (class library), the Flex compilers, the debugger, the MXML and ActionScript programming languages, and other utilities. Flex SDK also includes the source code for the core Flex framework class library, enabling you to study the code of the classes as well as customize or extend them for your own use.

About Flex Builder 2
Flex Builder is an integrated development environment (IDE) for developing applications with Flex SDK, Flex Data Services, and the Flash Player. The Flex Builder IDE provides tools that help you develop, design, and debug Flex applications, including an integrated incremental compiler and a step-through debugger.

About Flex Data Services 2
You build on the functionality of Flex 2 SDK by adding Flex Data Services. Flex Data Services adds enterprise messaging support and a greatly enhanced data services architecture to the Flex 2 SDK. You deploy Flex Data Services as a standard web application on your J2EE application server or servlet container.

- Adobe Flex Developer Guide - is the document to have a look at.

Today I want to have a closer look at the data-binding layer of Adobe and how I can create CRUD-screens.


Working with data services
Flex is designed to interact with several types of services that provide access to local and remote server-side logic. For example, a Flex application can use AMF to connect to a web service that uses the Simple Object Access Protocol (SOAP), an HTTP URL that returns XML, or for Flex Data Services, a Java object that resides on the same application server as Flex. The MXML components that provide data access are called data service components. MXML includes the following types of data service components:
WebService Provides access to SOAP-based web services.
HTTPService Provides access to HTTP URLs that return data.
RemoteObject Provides access to Java objects (Java Beans, EJBs, POJOs) by using the AMF protocol. This option is only available with Flex Data Services or Macromedia ColdFusion MX 7.0.2.

I need to use the Flex Data Services to be able to add data-bound components into my Adobe Flex Application.

How to build a Data-Driven application (using the Adobe Flex Developer Guide, Chapter 9):

Using the HTTPService – data service component I’m able to integrate an existing rss-feed from a blog to populate a DataGrid-component in my Flex Application. Looks very fancy and it’s not hard to try this out.

Using the WebService – data service component I can call a webservice and get back the results in a datagrid-component. You can learn how to pass parameters into the webservice and how to react when the webservice is calles, e.g. when the user invokes a certain action or when the application has been displayed (e.g. onPageLoad or to say in Flex-language on
creationComplete). You will actually work in the same way as when using the HTTPService only you’re invoking a webservice endpoint instead of a HTTP request.

Data Management Services, chapter 19, discusses the different adapters that are need to use persistent or transient data in an Adobe Flex Application.
The ActionScript object Data Management Service adapter persists data in server memory and is useful for applications that require transient distributed data that is not persisted.
The Data Management Service Java adapter will be used for data that is persisted to a data store.

I need to download a trial version of LiveCycle Data Services ES , to be able to integrate Data into my Adobe Flex application.

I’ve already tried to create a Database Accessor to my Oracle schema but this doesn’t seem to work regarding a bug reported by Adobe. When you try to create a connection to an oracle db with more than 1 schema, which would be the case for 99% of th time, the data connector can’t establish the connection.

So when you want to create a CRUD-application using Oracle as your db, you need to wait for a patch/new beta release.

What are the pro’s and con’s I’ve seen today:

  • Pro: integrating a HTTPService, a blog for example, is very straightforward and doesn’t ask any specific modifications or knowledge from the developer (except reading the dev guide ;o) )
  • Con: renaming the mxml file still holds the old swf- and html-files in the bin-folder, these can be removed manually without any impact on the application
  • Con: Not able to delete a Database Accessor you’ve defined earlier, not clear how to edit the existing Database Accessor either
  • Con: Exceptions thrown when having a look at existing , e.g. try to access www.papervision.org twice in a new browser session => the following error is shown:

ArgumentError: Error #2082: Connect failed because the object is already
connected. at flash.net::LocalConnection/connect() at
com.noventaynueve.underwater::Launch() at main() at
[execute-queued] at [io]

That’s it for today … I hope I can build a small application using an Oracle database.