Sunday, September 27, 2009

WebSphere ESB and EJBs

My next post will probably be a book review - I was asked to review a new book on WAS 7.0 administration. Cool. Hopefully I'll be able to read it in the next couple of days (did I ever mention I was a quick reader?)
In the meantime, I want to publish my findings on the use of EJBs in WebSphere ESB.
A customer of mine is using WebSphere ESB. For services, it developed EJBs (stateless, of course, but still - version 2.0).
The mediation module has imports for the EJBs.
This turns out to be a very bad architectural decision (I arrived to the project after this decision was taken :-) ) , and right now they are rewriting everything, to drop EJBs and use SCA Java components.
Why?
  1. SCA Java components are actual EJBs, so why have an EJB call an EJB? Not a smart move, performance wise.
  2. Mediation Module (6.1) EJB support is lousy. It fails generating good mapping between the Java bean parameters and Data objects. So my customer resorted into sending Strings to the EJBs, and then parsing them, at the EJB level, to POJOs, using XMLBeans. This is insane - and shouldn't be done.
So what is the current (working!) recommendation?
Use SCA Java components, in the same module, or other modules, depending on your component visibility and deployment needs.
Inside the Java component, use a mapper to map the DataObject object into real Java POJO. and then pass it to your business logic, which is implemented in regular Java Classes.

The mapper is really easy to write:
1. Use JAXB or XMLBeans to generate mapping between the DataObject XSD and a Java class.
2. Write a method that has the following signature:
public static Object mapper(DataObject do, Class clz)
3. Use reflection on the clz - create a new instance of it, and for every field decide:
3.1 If its a primitive - transform it.
3.2 If its a Java Class - call yourself in recurssion
3.3 If its an array - run over all elements

It works fine, great performance, and the development barrier was lowered by more than a few inches.

Hope it serves someone well.


Thursday, September 17, 2009

Problems installing WID 6.2 on Windows 7

I faced many problems while installing WID 6.2 on my Windows 7 machine. I won't get into the full set of problems I encountered, but the process that did work for me was as follows:
1. Don't run the launchpad application, but the installer inside IM_win32
2. Run the installer in compatibility mode, for WindowsXP SP2
3. Since I already tried installing - I had to install everything to a clean directory
3.1 This is a reported bug and was fixed in a fixpack already
4. Remove the file c:\windows\.nifregistry

I found the last tip after digging inside the installation log files, I found the following command executed -C:/Program Files/IBM/WID62/image/WPS62/iip/contrib/6.1.0-WS-WASWS/1/WinX32\WEBSV\install.exe -options C:/Users/liran.ALUNA/responsefile.WEBSV.txt -silent
And the log file specified a NullPointerException on the com.ibm.ws.install.ni.framework.product.VersionUtils.compareVersionsUpToDigit(VersionUtils.java:170)

The weird thing is that I did everything by the book, so it's not clear to me why no one else got this error. But hey - it works now...

Sunday, September 13, 2009

Working with Linkedin

I've found that I'm using LinkedIn more and more. As a matter of fact - I think I spend around 2-4 hours a week on LinkedIn - getting new connections, sending messages, and finding leads. Heck - I even found a recommendation for my kid's kindergarden from LinkedIn. Not exactly what I would expect from a professionals network.

But mostly - I try to hire people through LinkedIn. All our tests found this to be the most effective way to get CVs. From around 700 connections I usually get 40 responses (not all from my connections, and I also post in groups I belong to) - around 80% of them relevant. Much better than the junk I get from web based hiring sites, or from head hunters.

Still - I have a problem. Can't understand why LinkedIn limits me in sending messages to only 50 people at once. Considering all of these guys are my friends - LinkedIn shouldn't care about that. Heck - if they only offer this option for premium sites - I'll go premium (they don't, however).

What to do? Can't say it here (haven't checked the legal stuff yet). But I might have found a solution. It involves coding however. Tons of coding. Luckily I have strong Java roots...

Sunday, August 9, 2009

Stale Connection in WebSphere Application Server 6.1

Well, a customer of mine has a very weird bug. Sometimes he gets a StaleConnection exception when executing a statement against his Oracle Connection. The client runs WebSphere App Server 6.1, Oracle Database 10g, and uses EJBs and an XA datasource.
Finally, we discovered that there is a scenario that always raises the Stale Connection Exception, and we started investigating the root of the problem.

First of all, WebSphere throws the Stale Connection exception as a wrapper to specific SQL Exceptions received from the JDBC connection.
But why is the connection suddenly closed? A step-by-step following with the debugger found that we get the connection open from the datasource, and then, suddenly, the connection is closed.
We tried to convert the datasource to a non-XA datasource, and received allot of exceptions. This showed us that the process in question needed the XA capabilities of WAS.
We then wrote wrappers over Oracle's XA connection manager (oracle.jdbc.xa.client.OracleXADataSource) and Oracle's Connection (oracle.jdbc.pool.OraclePooledConnection), and seen the debug messages.
We still have no solution, but there can be 2 options:
1. There is a bug with the WAS XA handler.
2. When using statement.getConnection().close(), we close the physical connection, and not the logical connection coming from the datasource. The customer now changes his code, to see if he can get away without the statement.getConnection() bit, and close the logical connection received from the datasource.

I'll post more details later.

Sunday, August 2, 2009

WebSphere ESB Invalid Content Length

Well, turns out I was mistaken in my previous post. Invalid Content Length can occur when using MTOM in .net C# clients with WebSphere ESB, but that was not the case in our customer.
Invalid Content Length appeared when the client closes the socket before sending the entire request. This can happen when the process is halted during send time. WESB will sysout Invalid Content Length, but you can usually ignore it.

However, we still faced a problem with very large service calls (over 1MB in size - only XML, no attachments). Turns out that our synchronization code was messed up, and for some reason - our cache was not correctly initialized, and so we received allot of NPE (NullPointerExceptions).
So - we synched our cache, and voilla - all works.

That teaches me to blog before I see everything working in my own eyes.

One last important issue. Sending large service calls can take time. Allot of time. And so, each C# client has a Timeout property, that sets that Timeout for the service call, in milliseconds. Use it well, since you are very likely to get a Timeout exception before you get the web service response.

Thursday, July 23, 2009

WebSphere Integration Developer issues

Well, it was a while since I've posted - mainly since my partner (Doron) is in Japan, and I have to do the work of two.
But there is a 10 minutes break now, and I really wanted to blog these issues:
1. If you need WAS 6.1 to work with WS-Security and C# clients - drop it. The built in web services support in WAS - JAX-RPC or JAX-WS, just doesn't work.
2. If you send WAS web services, with large content from C# and get SRVE0080E: Invalid content length - you need to set the sendChunk=false property on the .net request client. This will fix it.

Thursday, July 2, 2009

WebServices Versions

Well, just read this. It's an article by IBMers on versioning of web services and schemas. I got this URL from @kfrion after a phone call we had together concerning the versioning of APIs.

The article highlights the same problem I'm presenting in my SOA classes and to my customers. Generating WSDL is great. Whether you're using VS.Net or AXIS/CXF/Metro - WSDL is automatically generated and it works just fine.
However, if you want to use company standard XSDs (from your repository of business objects), to enforce policies, or anything like that - you're stuck. The reason - WSDL editing tools are just not good enough.
And if you need to upgrade your WSDL version - changing the target URL, the schema and so on - then you're on the road to hell, since it requires so much low level understanding of the schema and WSDL specs that your chance of getting it right is slim.

So, what we really need are tools that will allow us to set everything in the WSDL from our code annotations (schema locations, policies, etc.), and can understand changes we made to our programming language code, and generate a backward compatible WSDL according to all versioning best practices.
I've developed something like that (very very limited) in C#. If someone is interested - reply or mail me.