Verse Of The Day

Monday, March 21, 2016

@Deprecated - Blog no longer in use

While doing some "digital spring cleaning", I realized this old blog is still sitting out here,
  • Any non-worked-related code I can share will be on Github (or much older code on SourceForge or LaunchPad). It's mostly tutorials andjunk I work on in my spare time, as the real stuff I work on belongs to my employer. 
  • I'll post on Twitter when I'm at a conference or other special event.
  • I use LinkedIn for keeping in touch with other professionals.
  • Any pictures, stories, etc. meant to be shared with friends would be on Facebook.
And that about covers the spectrum for digital sharing, leaving this old blog a ghost town in the dusty reaches of the internet.  And with that, this blog is officially retired.

Friday, April 25, 2014

Running Fortify From Gradle Build

I have been using Gradle for some time on personal projects, and recently got my company on board as well. Part of the standards at my comapny are to have all builds automated in Jenkins, along with Sonar and Fortify builds. Hooking up Sonar was not much work, as there are standard Gradle plugins and a lot of documentation.

Fortify, on the other hand, was a bear. That is a proprietary product that requires a license, so documentation and plugins were not so prevalent out on the interwebs. Lots of questions, not many definitive answers.

I finally got my Fortify build to work this past week using the Fortify ANT tasks. Below are the snippets you would add to your build.gradle file to get Fortify scanner running. Again, since this is not F/OSS, the libs won't be out on public repos. You would have to add the libs to your in-house private repo (e.g. Artifactory) to get this to work as-is (or use a local lib, see Gradle docs).

Wednesday, May 23, 2012

OSB Table Poller Issue Setting Status

After building quite a few Oracle Service Bus table pollers, my last project should have been something I could do with my eyes closed. Poll a table looking for certain 'actions', and call a few web services to make that 'action' happen in another enterprise system.

A very simple service flow:
1. JCA table poller adapter, configured for logical delete (change an indicator from one value to another), set up for distributed polling so it will work in a clustered environment. Basically look for records with status of N, switch it to P.
2. Wrap that in a proxy that simply routes to one of several other proxies based on the 'action'. (local transport)
3. Those other proxies call web services based on the values in the original message. On success, the response pipeline will set the status to C. If any of those services fails or returns an error, an error is raised to the proxy's error handler, which sets to the status to E.

That's it, dead simple. If there are no errors, everything works great, record goes to C, we're all good. 

However, if an error is raised on the request pipeline, the status doesn't get changed to E. Using the same service callout that works for C, does not work for E.

I watch my WebLogic logs and my TOAD query at the same time and notice some things:
1. For a success, I see in TOAD the record stays in N status until all the web services have been called. Once the final service returns, it immediately goes to P then C. All good.
2. If an error is raised along the way, or even if I manually try to set the status anywhere on the request pipeline, that call hangs until the transaction timeout occurs, then that update to E fails, as well as the update to P. End result, the record stays in N and gets pulled again, and again, and....

(As an extra red herring to keep me busy, I get a log full of XA transaction type errors, so I spend way too much time working with the DBA trying to set up XA permissions.)

So it seems that all along the request pipeline, the OSB has that row locked for update, but hasn't done the update to P yet. If I try to set it in my flow, the two updates deadlock until the XA timeout occurs. However, when setting it on the response pipeline, the update to P has already happened, so it works there.

I could have rewritten all my proxies to only change the status on the response pipeline, but that would have been a painful rewrite of the flows. An easier solution was to have the poller proxy immediately drop the message on a JMS queue, and then have a queue listener proxy pick those up and route them. Doing this, I see the record go to P immediately, no matter what, and then success or failure, my status changes without any timeouts or XA errors.

Friday, April 01, 2011

Testing SyntaxHighlighter Script

Just testing the Syntax Highlighter script....

Please disregard. There's nothing to see here, move along....

Some links:

#!/usr/bin/env ruby

class SyntaxHighLighterTest

$max_column_chars = 4000

attr_accessor :numRecords

def initialize(numEach=1000)
@numRecords = numEach

def do_nothing
tstamp =
puts "The time is now #{tstamp}"

@numRecords.to_i.times do
puts "going...."

puts "gone"

if __FILE__ == $0
numRecs = ARGV.first
fn = numRecs

Friday, December 03, 2010

WebLogic Annotation For MDB WorkManager

If you are like me, you have been searching the web for 2 hours looking for a way to tie your WebLogic 10g message-driven bean to a WLS WorkManager using the nice EJB3 annotations. But since you aren't me, let me save you some time.

It ain't there. Not gonna do it. Not happening for you today, my friend.

You have to do a bastardized mutt application using a combo of annotations and XML deployment descriptors (remember those?).

Allow me to save you more time by showing a more concise example, so you don't have to take a time machine back to a time when EJB2.1 and XML roamed together in dinosaur-like bliss and figure out what the descriptor should look like.

Here's an example:

My MDB class signature looks something like this....

@MessageDriven(activationConfig = {
propertyName = "destinationType",
propertyValue = "javax.jms.Queue") },
mappedName = "jms.ens.yes943processing.queue")
public class YearEndProcessingMdb implements MessageListener {

And so on, with your onMessage() and all the other crap you would put in an MDB.
Then my weblogic-ejb-jar.xml file looks a bit like this....



You can tell if the thread limiter is working by deploying, chucking a bunch of messages on thequeue, and checking the WLS console.

  • Go to deployments
  • Click to expand your EAR
  • Click on the MDB name.
  • Then go to the Monitoring tab.
  • Under that click on the Workload tab.
  • Here you should see your work manager and thread constraints with the number of messages they are processing.

Monday, November 01, 2010

Oracle Service Bus - Getting XML Out of Table Column

This took me a while to figure out, and ended up being pretty simple once I knew which XQuery functions were available.

Let's say you have a table you need to query from the OSB. The result set you get back from the JCA DB adapters gets turned into XML for you. If one of the columns is a LOB containing XML, then it gets escaped using CDATA. Anything in CDATA is basically ignored by XML, XSL, XPath, etc.

It is a 2 step process to extract that value and make it usable XML:

  1. Use the fn:string() function to turn the value into a string. In this case, it strips off the CDATA wrapper and gives you a string that looks like XML.
  2. Use the fn-bea:inlinedXML() function to parse that string into XML.

You can use an ASSIGNMENT task to jam that XML into a variable, and then run any XSL, XPath, etc on it. You can also use INSERT or REPLACE tasks to embed it back into your original XML.

Enabling Oracle Trace For WLS Connection Pools

We recently had the need to run an Oracle trace to catch some database diagnostics for an OSB call flow. To enable the trace only for the sessions coming from WebLogic, I added the following to the "initSql" field in the connection pool setup screens (in the WLS console). Just remove it and save the pool settings when you're done collecting your *.trc files. Works like a charm.

SQL BEGIN DBMS_MONITOR.session_trace_enable(waits=>TRUE, binds=>TRUE); END;

Wednesday, October 13, 2010

Oracle Service Bus and JCA Adapters

If you've spent any time using Oracle's SOA suite, the first thing you will notice is their toolset kind of blows donkey. It's a half-baked patchwork of crap - some of it written by them, some of it bought from other companies and bastardized. And chock full of interesting bugs and random crashes.

So the first thing I noticed when working with the OSB for the first time (Oracle Service Bus, a.k.a. BEA Aqualogic service bus, or ALSB) is that the "Workshop" tooling lumps everything as either a "business service" or a "proxy service". That's all fine and good, but when I first started reading about integration patterns, SOA, and service buses years ago, a lot of what I learned about was JCA adapters. Where are the JCA adapters!?

If "Workshop for Weblogic 10g" is your only Oracle SOA IDE, then you might think JCA doesn't exist anymore. Oh, but it does. And chances are you need it. So here comes that patchwork - that menagerie of mismatched pieces. You need to use Oracle JDeveloper as well as Workshop for Weblogic - 2 IDE's to accomplish your 1 task.

Ugh, seriously?

This tutorial and sample, while well written, confirms it in all it's ridiculous glory. You need to launch JDeveloper to create the JCA adapter. Then you launch Workshop for Weblogic and create a business service or proxy service in your OSB project. Within that service, you have to import the WSDL that you generated from JDeveloper (as well as any XSD's and TopLink mappings).

Maybe next time Oracle will put all that into one tool? Though since they bought Sun, they have aquired even more application servers and tools, so next time you'll probably have to launch JDeveloper, Workshop, and NetBeans to get a simple service working.

A Few More SEAM Nuggets

I just came across some stuff that was supposed to be a blog post with some more SEAM tips and tricks. Since then, I've moved on to a new job, and haven't been using SEAM in my new position.

Showing Number of Matched Records in List View

When you generate a SEAM application from a database, you end up with a set of components for each table - for example a list view, record view, and record edit. When you are displaying a list of records, it is common to want to show how many records match the current query (or the total records if you went to list view without a search criteria).

You can easily get this function by accessing the "resultCount" attribute on your view, like this:

<h:outputtext value="#{yourTableList.resultCount} rows found." rendered="#{not empty yourTableList.searchResults}">

Change Default Sort Order, But Still Allow Click-To-Sort

One requirement we ran into on one of my SEAM projects was to change the default sort order for some of the list views. However, the views that the SEAM gen tool creates allows the user to click on the column headers to change sorting as well. To achieve a default sort order on initial load, and still allow clickable headers, override the getOrder() method in your source like this:

public String getOrder() {
String order = super.getOrder();
if ("".equals(order) || order == null)
order = "col1 asc,col2 desc";//your default sort columns here
return order;