Three or four times a month, I am asked about a specific JCO connector exception that seems to confuse many people....
If you've experienced the following exception, then read on for more insight:
java.lang.ExceptionInInitializerError: JCO.classInitialize(): Could not load middleware layer 'com.sap.mw.jco.rfc.MiddlewareRFC' JCO.nativeInit(): Could not initialize dynamic link library librfc. Found version "620.0.907" but required at least version "620.0.950".
This exception is misleading because most people start looking for the class com.sap.mw.jco.rfc.MiddlewareRFC which is part of the JCO file "sapjco.jar". After making sure this file is in the CLASSPATH, they attempt to re-run the application, only to get the same error. The answer lies in the fact that they have attempted to run JCo with files from different JCo versions.
SAP has been great about supporting JCo with ever-newer releases. Each release is a successive build upon the last, solving bugs and often adding new features to the connector. The trick is ensuring that you have completely removed ALL files installed from the previous release before attempting to run a new one.
The files in question are:
The exception above occurs when you have left the .dll files from a previous installation in the Windows/system32 directory, while trying to use the latest sapjco.jar file in my Java application. Obviously, my example here is Windows biased, such that if I were running on a UNIX platform, I would be using native libraries (.o, .so, etc.) instead of .dll files.
To perform a successful install of a new JCo version, you simply need to remove the .dll files from the Windows/system32 directory and replace them with the libraries that come zipped in the newer version. Likewise, you must point your CLASSPATH to the latest sapjco.jar file, ensuring that the old version is not available from the CLASSPATH.Author Austin Sincock is a freelance Java/SAP consultant who contributes regularly to Web and print journals. He can be reached at firstname.lastname@example.org. Check out his book Enterprise Java for SAP