November 5, 2009

Book Review: Getting Started with Oracle SOA Suite 11g R1

Oracle Fusion Middleware 11g (OFM 11g) is a big product stack. Books on this product stack are rare and could focus on many specific parts of it. To get started with this stack you have to decide which parts you chose. This books gets you started with the SOA Suite part of OFM 11g

The Authors

This book is written by a team of Oracle SOA Suite product managers, namely Heidi Buelow, Demed L'Her, Manas Deb, Prasen Palvankar, and Jayaram Kasi.

The Book

To get started with the Oracle SOA Suite 11g R1 one can chose many ways. An easy one is by developing a sample application that covers nearly all possible areas of the whole product. This is exactly the approach of this book. Conceptually it is divided in three parts.

Part 1

This first part introduces you to the product in general. It starts with the SOA evolution in chapter 1 and finishes with a product architecture overview. in chapter 2.

Part 2

The second part starts with an introductory chapter to the sample application and the remaining chapters of the book and how to read/use them. This is not quite new, as nearly every book does this, but the diagrams used herein are very helpful. After you have finished the SOA Suite installation as described in chapter 4, you are ready to go for the remaining 6 chapters. These cover WS Binding, DB Adapter and Mediator, File Adapter, BPEL PM, Human Workflow, Rules, and finally JMS Adapter. When you finish this part, chapter by chapter in sequence, you have a complete application to demo to your peers.

Part 3

The last part contains 9 tutorials on Service Bus, Lifecycle, Testing, Exception Handling, Security, BAM, Events, Service Data Objects (SDO) and B2B. You can use them with the sample application in any order you like.

Recommendation

This book is mainly written for the newbies. You learn how to use the Oracle SOA Suite 11g and its parts. That's it. Introductions to concepts or standards are included, but are very minimal, not to distract you from the real stuff. If you need a proper understanding of the more advanced details you should refer to the product documentation.

On the other hand, this book has some outstanding but hidden gems to offer. These gems are, for example, one of the best and most concise picture to explain the difference between JMS Queues and Topics, or how to remove the software you have just installed.

It is always a tough decision which book and approach to chose for learning and referencing. Personally I prefer books that could be used for reference later. This is often very hard for a tutorial book. Some of these tutorial books could also serve as a reference. I consider this book as one that could serve as one that points me in the right direction when I lost track of some parts during my busy work.

Since Oracle SOA Suite 11g will be sooner or later updated, this book will as well. Packt Publishing offers free PDF eBook upgrades. This is a really nice concept.

The Details

Title Getting Started with Oracle SOA Suite 11g R1
Authors Heidi Buelow, Demed L'Her, Manas Deb, Prasen Palvankar, and Jayaram Kasi
Paperback 468 pages
ISBN 13 978-1-847199-78-2

October 21, 2009

Revisited: Including a Class-Path In Your MANIFEST.MF

In January 2008 I wrote about putting additional information into your Manifest.mf (see original entry). Recently a colleague told me that this does not work as expected in JDeveloper 11.1.1.1.0.

A short investigation showed that JDeveloper 11.1.1.1.0 does two things while going through the deployment process.

  1. It checks the correctness of the tag and its usage.
  2. It expects a value in the same line as the tag.

The first is nice and necessary to avoid any surprises. The second is a bit surprising if you follow my advise in having a separate line per Class-Path element. To get it work as in the original post, you need to be sure that every multi-line tag entry must have the form <tag>: <first_value> in the first line. For example:

Class-Path: ./lib
  commons-lang.jar
  etc.

September 24, 2009

OFM 11g: Starting WebLogic Server with opmnctl

There are many ways to start the Oracle WebLogic Server 10.3. or higher. The most common is to use the provided script and off you go. To automate this, I usually use scripts and include them in the normal System V boot process as implemented in Linux or Solaris.

A Common Way for Unix-based Systems

Here is a script, I'm using very often:

#!/bin/sh
ORACLE_HOME=/opt/oracle/product/wls/10.3.1
DOMAINS_HOME=$ORACLE_HOME/user_projects/domains
DOMAINS="test login"

start() {
   for i in $DOMAINS
   do
     export WLS_REDIRECT_LOG=$DOMAINS_HOME/$i/wls_${i}_$$.log
     eval $DOMAINS_HOME/$i/bin/startWebLogic.sh &
   done
}

stop() {
   for i in $DOMAINS
   do
     $DOMAINS_HOME/$i/bin/stopWebLogic.sh
   done
}

case "$1" in
   start)
     start
     ;;
   stop)
     stop
     ;;
   status)
     status
     ;;
   restart)
     stop
     start
     ;;
   *)
     echo $"Usage: $0 {start|stop|restart|status}"
     exit 1
esac

Platform Neutral: Leverage opmn

In OFM 11g the opmn Process Management Systems is still in use. If your architecture includes an opmn installation it would be a waste of resources to use shell scripts to start all your bits and pieces.

One specific architecture is the typical "JEE Application Server behind Apache" one. Apache uses a mod plugin to redirect the requests to the configured JEE application server. mod_oc4j is a typical example for older Oracle AS versions. With OFM 11g Oracle HTTP Server (OHS) comes a mod_wls_ohs that does the same for the OHS-WebLogic combination.

The only requirement is to start both parts in a good order to service all requests from the very beginning. You can achieve this with a good combination of the above mentioned shell scripts. Or you could add new entries to your opmn.conf.

Here is a sample entry for a single WebLogic domain:

<ias-component id="wls-login" status="enabled" id-matching="false">
<environment>
<variable id="WLS_REDIRECT_LOG"
value="/opt/oracle/product/fmw/11.1.1.1/user_projects/domains/login/wls.log"
append="false"/>
</environment>
<process-type id="WLS" module-id="CUSTOM">
<start timeout="3000" />
<stop timeout="3000" />

<process-set id="WLS" restart-on-death="true" numprocs="1">
<module-data>
<category id="start-parameters">
<data id="start-executable"
value="/opt/oracle/product/fmw2/11.1.1.1/user_projects/domains/login/bin/startWebLogic.sh"/>
</category>
<category id="stop-parameters">
<data id="stop-executable"
value="/opt/oracle/product/fmw2/11.1.1.1/user_projects/domains/login/bin/stopWebLogic.sh"/>
</category>
</module-data>
</process-set>
</process-type>
</ias-component>

Quiz

When you have implemented OFM 11g in some way, you have noticed some changes in the file structure. Where do we find the opmn.xml in OFM 11g (eg in the Web Tier installation)? Please post your suggestions as comment.

August 31, 2009

Book Review: Oracle SOA Suite Developer's Guide

Things can get strange over time. While waiting for the release of the Oracle Fusion Middleware 11g, the OTN Forums never stopped asking for ways to learn Oracle SOA Suite. Although the product documentation is huge and could occupy many MBs of your hard disk drive, it still is a difficult read and it never tells you how to start with the SOA Suite.

The Authors

The Oracle SOA Suite Developer's Guide was written by Matt Wright and Antony Reynolds, two SOA Suite practitioners from the first release of the Oracle SOA Suite.

How to start a book on SOA Suite?

Although SOA promises to make things much easier, any implementation of SOA will be a complex beast of technologies. The Oracle SOA Suite is no exception from the rule. For the uninitiated this complexity makes it very difficult to find the right entry point to SOA and the SOA Suite product.

The first brilliant step was the decision of the authors, not to publish the installation of SOA Suite but keep it online. This way it could be adjusted to the latest release if needed. Brilliant, because it saves us from reading a useless chapter while the product and the installation get better.

Part 1: Getting Started

The first part helps you to get started with the SOA Suite. It sets the scene and explains which components have been chosen and which have been omitted and why. This part consists of eight chapters and shows how to write the first service, how to service-enable existing applications, loosely coupling of services, using BPEL to build composite services, implementing business rules apart from the parts of the complete service, incorporating human services, and, finally, building a dashboard using BAM.

Throughout this part, you will be introduced to the best parts of the SOA Suite and how to combine them. You get an understanding how they work together and why you should use them for the task. Another good decision was to use Oracle Service Bus instead of Oracle Enterprise Service Bus, as both will sooner or later diverge into a single implementation. On the other hand this decision makes the design time more complex, as OSB and BPEL use different tooling to accomplish the task.

Part 2: Developing a Sample Application

The major part of the book is written around an on-line auction application. Equipped with the knowledge of the components introduced in Part 1, the authors guide you through the concepts that make the distinction between a good and a bad implementation. These concepts include Service Contracts, Business Services, Validation, Error handling, Message Interaction and Workflow Patterns, and the Importance of Bindings.

In this part I really like the Designing the Service Contract chapter. It not only propagates the "Contract First" Principle but also goes very deep into XML Schema Definition creation and usage details. And it serves as a good example how the authors provide a plethora of tips and tricks throughout the book. This one is full of tips and tricks for a good design and how to avoid most of the traps and pitfalls in designing a good service contract. (I really missed the maxOccurs="999" bug, though)

Part 3: Deployment

The last part consists of three chapters for Packaging and Deployment, Testing Composite Applications, and Security and Management Policies. Although the Packaging and Deployment chapter seems to be of most interest for the SOA Suite community, I would have put the Testing chapter before it. Testing as early as possible saves time and money. The Security and Management Policies chapter concentrates on Oracle Web Service Manager (OWSM), a good piece of software that feels a bit strange in the whole SOA Suite as it is neither SOA nor Security. Anyway, it makes good sense as this technology is much more integrated into the OFM 11g stack and combines the ease of implementation of the 10.1.3 web service security interceptors as well as the centralized management of policies.

Part 4: The Missing Chapter

The Oracle SOA Suite Developer's Guide is full of useful and good hints and practices. But I miss the consistent concept of making the reader aware of them. Sometimes these are highlight by the electric bulb icon and sometimes these are just within the normal sections of the normal text. You read, understand and memorize them but you might not find them again easily. You have to rely on your own dog ears, notes or other kinds of markings. This is cumbersome, and an overview or an index for finding them quickly would be great.

What you don't get

Although this book is a treasure of tips and tricks and common wisdom, it does not tell you all the nifty details of all the standards used within the SOA Suite. If you are interested to learn more about them, you need other sources.

Recommendation

If you need to learn how to develop applications for the Oracle SOA Suite, I highly recommend this book. If you are a seasoned SOA Suite practitioner you should take a look at it and find out which of the best practices you still don't know.

Book Details

Title Oracle SOA Suite Developer's Guide
Authors Antony Reynolds, Matt Wright
Paperback
652 pages
ISBN 1847193552
ISBN 13 978-1-847193-55-1

August 27, 2009

OFM 11g: Install OAM 10.1.4.3 (32-bit) on 64-bit RedHat AS 5

When you want to install Oracle Access Manager 10.1.4.3 on a 64-bit platform, you will instantly notice that there is no 64-bit version available. Here is how to go ahead with the 32-bit version of Oracle Access Manager.

Use the 32-bit Environment

The installer of Oracle Access Manager do not work on a 64-bit environment. On RedHat AS 5 you can "switch" to the 32-bit architecture by starting a new bash with linux32 bash. Until you close this new shell you will be in 32-bit world.

Use the OFM 11g Web Tier 32-bit

Because the web server plugins for PolicyManager and WebPass are available as 32-bit versions only, you need to install the OHS 11g from the OFM 11g Web Tier distribution. Unfortunately, this will not go through smoothly and will sooner or later stop in one of the makefiles (*.mk) which link the executables.

When you encounter one of these (possible candidates are $OHS_HOME/rdbms/lib/ins_rdbms.mk, $OHS_HOME/network/lib/env_network.mk, or $OHS_HOME/webcache/lib/env_calypso.mk) do not stop the installer! I mean it.

You can now scan the makefile in question for a command line containing gcc. To link a 32-bit executable, the command line must have the -m32 flag set. If this is missing, simply replace gcc with gcc -m32.

When you finished these small obstacles, the rest of the installation of Oracle Access Manager should continue smoothly.

A Word on WebGate

When you configure your web server with the PolicyManager and WebPass it is a good practice to install WebGate as well. But, don't get confused by the 64-bit WebGate.This should not be installed for the web server containing PolicyManager and WebPass. Use the 32-bit version of WebGate and everything is fine.

June 5, 2009

June, 5th: Environmental Day

Sitting at home, reading about the recession in the papers, seeing it in the news, all this makes you angry and restless. But what if this is just a fraction of the real life?

Today is Environmental Day all over the world! What does this mean to me and to you? Well, I don't have the answer but this web site might give you an idea:

"We are living in exceptional times. Scientists tell us that we have 10 years to change the way we live, avert the depletion of natural resources and the catastrophic evolution of the Earth's climate.

The stakes are high for us and our children. Everyone should take part in the effort, and HOME has been conceived to take a message of mobilization out to every human being."

Go and visit HOME

May 17, 2009

Book Review: Business Process Driven SOA using BPMN and BPEL

One of my last projects was for the Public Services and it felt that these people tend to live for business processes by definition. But while we went on with the project requirements, a team mate showed the whole team what he did for a former project with similar requirements. It was a single diagram done with the BPMN notation and it covered a pretty thorough picture of the requirements and process dependencies.

BPMN is not just another modelling language for Business Process Modelling but the one orgininally build for this purpose. It is less technical then UML, includes support for timed execution of process steps and can help to run a simulation of the whole process in a tool.

The book by Matjaz B. Juric and Kapil Pant is a good starting point to learn BPMN for your project and get the right focus to it. While chapters 1 and 2 introduce you to the need of a proper modelling technique for SOAs, chapters 3 and 4 explain the BPMN language in more detail, present all available constructs as well as patterns and advanced techniques for better use of BPMN. Chapters 5 and 6 complete the book by showing how BPMN could and should be used in SOA / BPEL projects.

Compared to the UML books on my book-shelf, this one is a refreshingly small, easy to read and quickly to understand and apply. If you are a highly technical person, you might be quickly bored, but with a less technical more process oriented background you can get quickly up to speed with those tech guys. Likewise both types of readers can reach the same level of understanding with a fairly easy modelling language and can better work in a powerful team.

Book Details

Business Process Driven SOA using BPMN and BPEL, Matjaz B. Juric and Kapil Pant, 311 Pages, ISBN 978-1-84719-146-5, Packt Publishing, www.packtpub.com

Book Review: Processing XML documents with Oracle JDeveloper 11g

Although is very often not considered as the IDE of choice, JDeveloper is a wonderful and productive tool chest for everyone. When I found Deepak Vohra's book about XML processing with JDeveloper, I was instantly convinced as I know Deepak Vohra as an author on the Oracle Technology Network.

In its book he covers a broad range of XML document processing techniques within JDeveloper. In 14 chapters you will find almost everything that you might need for your XML processing. Very naturally it starts with XML document reading and writing. Once you finished that piece of work, requirements get more sophisticated and XML Schema definition and validation are needed for the documents of the same type. Voila, chapters 2 and 3 are there to read about it. And so it goes on, topics like XPath and XSLT transformations are followed by the JSTL XML Tag Library. DOM Level 3 Load and Save and Validation follow. A chapter on JAXB 2.0 concludes the first part of the book which introduces all basic techniques to work with XML.

The last five chapters show typical usage scenarios of these techniques. Chapter Comparing XML Documents is just the warm up phase for the next two chapters about XML Conversion to different output formats (chapter 11: PDF and chapter 12 for Excel). The last two chapters cover Storing XML in Oracle Berkeley DB XML while the last chapter gives you an appetizer for Oracle XML Publisher.

This book presents you a quick and easy learning path through the functionality offered by JDeveloper and the included Oracle XML Development Kit. You can start at every chapter you want. They are self-contained and do not require a cover to cover reading. Likewise the author does not bother to teach you XML, XSD, and XSLT from the ground up and in every detail. You just get enough information to set the scene and wet your appetite for more information.

The downside of the book are the code samples. Almost every code sample is just there to demonstrate how things work, but should not be considered as a blueprint for your product. I saw resource leaks, hardly maintainable code due to ignoring DRY style (Don't Repeat Yourself) or different type usage conventions (import vs fully qualified class names). Proper code formatting with indentation, usage of blanks or curly braces, or common sense of factoring for repeated code parts would have made the book superb.

Having said that, it is quite a good book in nearly every aspect. It leads you quickly to the point of the topic and does not waste your time with chapter-long introductions. You can start quickly and improve your knowledge as you go.

Book Details

Processing XML documents with Oracle JDeveloper 11g, Deepak Vohra, 370 pages, ISBN 978-1-847196-66-8, Packt Publishing, www.packtpub.com

April 29, 2009

Java Performance: The Return of the Usual Suspects (Updated)

After some years of Java development, one should expect that all lessons are learned and good code is the norm. Yes, really, but this isn't the case. As I work in different projects and reading many books, I am still surprised how often you will find the same ways for doing things wrong.

Create Unnecessary Objects

One of the easiest errors you can do, is to create unnecessary objects. Yes, honestly. There is one famous class in the whole Java environment that can only have two real values. These values are provided as constant values and the only reasonable ones everybody should use as objects of this class. I am talking of the Boolean class. True and false are the only instance and are provided as constant values Boolean.TRUE and Boolean.FALSE. Unfortunately, this class also has a public constructor Boolean(boolean value). This constructor leads to really unnecessary code new Boolean(true) or new Boolean(false). If you see this in your code, it is time to speak with the author and introduce some code inspection tools like FindBugs or PMD.

Use of StringBuffer

In JDK 1.0 times, StringBuffer was a reasonable approach to boost performance for String concatenation. It still is an alternative, but StringBuilder is a better one. The worst thing you can do is to concatenate string literals (aka constant strings) with StringBuffer.append(). Because you are working with literals use the + operator. It gives the compiler the chance to optimize the concatenation during compile time and not to leverage the effect to the runtime.

Method Calls in Loop Conditions

It is really tempting to use the "size" methods of the collection classes (anything like size(), length(), rowCount(), etc.). But before you use them in a loop condition like for(int i = 0; i < array.size(); ++i), take a step back and think about it again. Do you just iterate over it to find something? Or do you modify it in the loop? If the content of the collection will not be modified you should use a construct like for(int i = 0, size = array.size(); i < size; ++i). This is much faster, especially when the method is synchronized.

Repeated Access of the Same Object Through a Method

Very often, in a loop you find code to access the same object through the same method more then once. This makes your code hard to read, less maintainable, and slower. Imagine this method call is synchronized, what an avoidable bottleneck. Of course, you check the method before writing the code, but this does not help for ever. The next version of the API might use a synchronized method. Anyway, to improve the readability, maintainability and performance of the loop, you can introduce a temporary variable, call the method and use the variable throughout the loop. Here is some code:

// Bad
for (int i = 0, size = array.size(); i < size; ++i) {
   doSomething(array.get(i));
   doSomethingElse(array.get(i));
}

// Better
for (int i = 0, size = array.size(); i < size; ++i) {
   Object obj = array.get(i);
   doSomething(obj);
   doSomethingElse(obj);
}

Sure, these two line loop isn't really challenging, but image loops with more lines and line lengths with more then 80 characters...

JDBC DriverManager vs DataSource

Another classic. Use of JDBC in a server environment is much different than in a simple demo environment. You should avoid the DriverManager API (for example, not allowed in Java EE) as this does not allow you to provide connection pools as with a DataSource and very often the wrong class loader is used.

Closing JDBC Resources

Although some JDBC drivers support implicit closing of JDBC resources it is still a recommended practice to close the JDBC resources in the right order at the right place in your code and explicitly. The right order is ResultSet, PreparedStatement, Statement, and Connection. The right place for issuing this code is the finally clause of your try-catch-finally block. Do not reinvent the wheel for this, use the Apache Commons DbUtils library.

Use the Correct ClassLoader

The usage of the ClassLoader in Java is very often the only way to get resources loaded. Using the correct ClassLoader is essential for a perfect running application. The best way to use the correct ClassLoader is by using the Context ClassLoader. You can access it through Thread.currentThread.getContextClassLoader()

Don't Repeat Yourself - DRY

You can write the worst code in every programming language. If you write your code, always ask yourself, whether you have seen this code before, if so, try to refactor both pieces to common code and find ways to put custom code in it. Repetition is boring and introduces errors and problems.

Common Wisdom

This is just the tip of the iceberg. You can get much more interesting points to check your code against from very good references:

April 6, 2009

Upgrading your WebLogic to ADF 11.1.1.0.2

One of the first questions that come up with the JDev /ADF 11.1.1.0.2 release is how to upgrade your WebLogic 10.3 to it. Here is my solution:

  1. Open the Uninstaller of your WebLogic installation
  2. Select JDeveloper 11g (11.1.1.0.x) Studio Edition 11.1.1.0
  3. Uncheck everything under WebLogic Server
  4. Click Next to finish the deinstallation. If you're interested you can click on the Details button to see what has be uninstalled.
  5. Now open the JDev 11.1.1.0.2 Installer
  6. Select the WebLogic home where to install the new ADF version
  7. Now deselect everything and select the Application Development Framework Runtime only. Note: This will also select the JDeveloper and ADF folder again.
  8. To avoid class loading issues, rebuild all your EAR files.

Enjoy.

Note: You will find the Uninstaller either as $WLSHOME/wlserver_10.3/uninstall/uninstall.sh or %WLSHOME%\wlserver_10.3\uninstall\uninstall.cmd. On a headless server (like a Linux or Unix-based system) you may need to set the DISPLAY variable to an X Server like VNC or Xming. (Assuming that $WLSHOME or %WLSHOME% is your home directory for the WebLogic Server 10.3. installation.)