Archive for category Mac
… has stopped working in the latest webkit versions (for quite some time actually).
(ok, you guessed it, I’m posting this just to draw uncle G’s attention. Sorry!)
Today I was presented with the following error
java.lang.UnsupportedClassVersionError: Bad version number in .class file
My first instinct was of course that I must be using an older vm on the machine in question (an OS X 10.5.6 server), but no, java 1.6 was installed on this machine:
~$ ls -alF /System/Library/Frameworks/JavaVM.framework/Versions/ total 56 drwxr-xr-x 14 root wheel 476 25 Sep 10:43 ./ drwxr-xr-x 12 root wheel 408 1 Nov 18:28 ../ lrwxr-xr-x 1 root wheel 5 25 Sep 10:43 1.3@ -> 1.3.1 drwxr-xr-x 3 root wheel 102 2 Nov 2007 1.3.1/ lrwxr-xr-x 1 root wheel 5 25 Sep 10:43 1.4@ -> 1.4.2 lrwxr-xr-x 1 root wheel 3 16 Jun 2008 1.4.1@ -> 1.4 drwxr-xr-x 8 root wheel 272 25 May 2007 1.4.2/ lrwxr-xr-x 1 root wheel 5 25 Sep 10:43 1.5@ -> 1.5.0 drwxr-xr-x 8 root wheel 272 25 May 2007 1.5.0/ lrwxr-xr-x 1 root wheel 5 25 Sep 10:43 1.6@ -> 1.6.0 drwxr-xr-x 8 root wheel 272 16 Jun 2008 1.6.0/ drwxr-xr-x 8 root wheel 272 25 Sep 10:43 A/ lrwxr-xr-x 1 root wheel 1 25 Sep 10:43 Current@ -> A lrwxr-xr-x 1 root wheel 3 25 Sep 10:43 CurrentJDK@ -> 1.5
A little further investigation revealed that, even though 1.6 is installed, 1.5 is still firmly the default:
~$ java -version java version "1.5.0_16" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_16-b06-284) Java HotSpot(TM) Server VM (build 1.5.0_16-133, mixed mode)
Thankfully, this can be changed by aliasing java to the 1.6 version:
~$ alias java=/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Commands/java ~$ java -version java version "1.6.0_07" Java(TM) SE Runtime Environment (build 1.6.0_07-b06-153) Java HotSpot(TM) 64-Bit Server VM (build 1.6.0_07-b06-57, mixed mode)
Do this in your .profile to make it stick.
In fact the solution was simpler than the above for me, I just had to put
in my tomcat startup script (since I only needed the 1.6 jvm in tomcat).
You’d think it’d be easy eh?
- My first google turned up SAPRFC, an extension module for php which allows direct ABAP calls from php. ‘Perfect’, I thought, until I discovered that it is now essentially unmaintained, and it seems that no one ever tried it on OS X in the first place.
- Very very happy was I then when I discovered its (very new) successor: sapnwrfc. But no one has bothered to compile this yet on OS X either (and, like its predecessor, it requires the SAP RFC SDK, which I don’t have). And besides, it really is very new, just a month or so old – not suitable for production then.
- So I resigned myself to using another language to bridge the gap. My first thought (my first hope really), was perl. This turned up SAP::Rfc, written by the same guy who’s creating sapnwrfc. But this also requires the SAP RFC SDK, and I couldn’t find anyone who’d ever compiled this on OS X.
- So why not Java? The SAP client my employer would have me use is pure Java, so surely I could use the same technologies?
And this is where I stand at the moment: Use PHP/Java Bridge to call from php to Java, and SAP JCo to call from Java direct to SAP.
Yes, it’s cludgy, horrible, and sounds stupid. And it probably is stupid. But it’s how I plan to proceed for the present. Tomcat will host the Java VM, and – if all the PHP/Java Bridge documentation is to be believed – there will be no need for Java ‘glue’ code, I should be able to use the JCo code directly in php.
If I live through the experience I’ll post more info about this soon.
Some pre-emptive defence: I know there are other technologies which would be preferable to my current solution – but I can make no changes whatsoever to SAP, this severely restricts my options.
This doesn’t appear to be documented anywhere else on the web, and it’s something I’ve done a few times, so here’s how I went about it.
Thankfully, OSX Server comes with Tomcat pre-installed and ready to run. We need to make a few minor tweaks for BIRT, but otherwise this is an easy install (much simpler than installing BIRT on a regular Mac OSX for example).
First, we enable Tomcat (which is disabled by default). Open the Server Admin application, expand your server (add it if you need to), click on ‘Web’ in the tree, and click on ‘Settings’ in the toolbar (I’m assuming that you’ve enabled the web service here, if you haven’t you’ll need to do so).
In the ‘General’ settings tab, you’ll notice a checkbox labelled ‘Enable Tomcat’. Check it and click save. To verify that it’s working, visit http://localhost:8080 on the server, you should see the standard tomcat screen as in the image.
Next we need to download the latest BIRT runtime. Visit the BIRT downloads page, and grab the latest copy of the BIRT runtime (I’m using 2.3.1 here). Extract it somewhere, and copy the WebViewerExample folder into /Library/Tomcat/webapps, renaming the folder to something more meaningful, like birt-viewer.
Now, as per the deployment instructions for Tomcat 6, we need to grab a copy of the commons logging library. Download it from here (I’m using the 1.1.1 binary release), extract it, and copy the jars (I’m not sure which ones it needs, so just copy them all) into /Library/Tomcat/lib/.
Next, we have some minor tweaks to make. Because java on *nix generally needs an X-server running to generate images (and OSX won’t normally be running one), we need to instruct java to run headless. To do this (this is how I do it, there may be a better way) add the following line to somewhere near the top of the /Library/Tomcat/bin/startup.sh (just after the licensing jargon is a good place)
Also, since a server probably won’t have any printers set up, we need to tell BIRT not to try to use any. We do this by editing the file /Library/Tomcat/webapps/birt-viewer/WEB-INF/web.xml and changing BIRT_VIEWER_PRINT_SERVERSIDE to OFF as follows:
<context-param> <param-name>BIRT_VIEWER_PRINT_SERVERSIDE</param-name> <param-value>OFF</param-value> </context-param>
That’s it then, save your changes and restart Tomcat (by restarting the Web service in Server Admin). Test that it’s all working correctly by viewing the test report.
Following on from my earlier post about PC vs Mac vs Linux, these are a selection of the (many many) Mac vs PC ads from Apple.
Full credit to apple, their advertising department is exceptional (and this has nothing to do with the fact that I work for them!).