Tomcat 6.0.18, Apache 2.2.9, proxy_ajp on Ubuntu 8.10: Almost Trivial...
... after four hours of documentation re-reading.
[Update Tue Dec 23 15:30:20 CST 2008] The above line was written two days ago when I moved this blog away from a dying PC. Regular readers might have noticed outages of this blog for stretches of several hours at a time and during the evening hours. The whole machine would lock up while the disk light is a solid on, presumably trying to read something off the disk.
This is the second time a PC has died at home. If you remember, gao-2002 went out of commission only 23 days ago. And now gao-2006 is gone. You've seen gao-2006 mentioned here, here, here, and here.
Luckily, I was able to save all the data from the dying PC before it finally would get a kernel panic during the boot up process. I felt that I was this close to writing a different blog entry that begins: "I'm an idiot and I lost all data in this blog..."
Are your data backed up? Now would be a good time to implement your backup strategy.
With the backed up data, I was able to setup this blog on gao-2009 within four hours, most of it spent on one task. Here's entire process on this Ubuntu 8.10 machine:
- Install sun-java6-jdk from Synaptic Package Manager
- Install apache2 from Synaptic Package Manager
- Install tomcat6 from Synaptic Package Manager
- Deploy my blog at /var/lib/tomcat6/webapp/blog
- Connecting apache2 to tomcat6
The first four steps are trivial. I did the first three prior to the move. Step 4 took minutes. Step 5 is also trivial, but I didn't know it when I started. What tripped me up is Google. Most of the search results leads to outdated information. And I spent a number of hours following the wrong leads, most of them about mod_jk, which I custom compiled in the early days of this blog.
It finally downed on me that perhaps I should read the documentations. And what a good idea what was. All I need to know is in the documentations:
The gist of the documentation can be distilled to three sentences: Apache 2.2.9 includes mod_proxy_ajp support. Tomcat 6.0.18 is configured with an AJP connector by default. All I need to do is to enable mod_proxy_ajp and then tell it where my webapp is.
To enable mod_proxy_ajp I used the command:
[root@gao-2009] # a2enmod mod_proxy_ajp
To tell Apache 2.2.9 where my webapp is I added /etc/apache2/conf.d/proxy_ajp with the following content:
ProxyPass /blog ajp://localhost:8009/blog ProxyPassReverse /blog ajp://localhost:8009/blog <Proxy /blog> Order deny,allow Allow from all </Proxy>
It turns out I also need to edit /etc/apache2/mods-enabled/proxy.conf to change a line that says Deny from all into Allow from all. Without this change, noone can access the blog and I get error message that reads:
... client denied by server configuration: proxy:ajp://localhost:8009/...
That's all there is to it.
Wednesday Java Quiz
(Mark Volkmann suggested this quiz.)
Q: Will the following Java source compile, run without exceptions?
import java.util.SortedMap; import java.util.TreeMap; public class Main { public static void main(String[] args) { SortedMap sm = new TreeMap(); sm.put("one", 1); sm.put(2, "two"); System.out.println("value for one is " + sm.get("one")); System.out.println("value for 2 is " + sm.get(2)); } }
Strict rules: No actually running the Java compiler.
JavaFX 1.0 On Linux: Video
[Update (Wed Jun 3 07:45:43 PDT 2009)]: As of June 2, 2009, you can download the Linux and Solaris version of JavaFX 1.2 SDK directly from http://javafx.com. The Linux and Solaris support is preview only.[/]
In the two previous posts, I showed how to install JavaFX SDK 1.0 and the JavaFX 1.0 NetBeans Plugin on Linux machines. In both cases, I used the Mac version of the JavaFX SDK.
This approach won't give us any native libraries for Linux. However, thanks to
(via Pushing Pixels), we know a place where we can get those:
If you look carefully, you may find jar files whose names contain "natives". Although not complete, the various Linux and Solaris platforms are represented. Download, unjar, and throw the resulting *.so files into the appropriate place, you've gotten at least some of the native capabilities. The most interesting of them all is
jmc-natives-linux-i586__V1.0.0.jar
which contains
libGStreamer.so
libon2_decoder.so
That could only mean one thing—JavaFX videos on Linux. Here it is (Linuxy format, you need extra software to view it on Windows and Mac):
This is an Ogg Theora video recorded with gtk-recordMydesktop in Fedora 10/i586 with OpenJDK 6 (in VirtualBox 2.0.6 in Vista SP1, on the other side of the dual-boot). It is also the video played by JavaFX inside the video. I wasn't able to play FLV videos when I tried. Well, they did say it's not ready.
Google Chrome: The Three Month Report
I almost forgot about my promise to write about my experience with Google Chrome.
That was 98 days ago. It's a long time to be evaluating a product. I'd like to say that I did not forget to write the evaluation, but that's exactly what happened. After the first batch of complaints, I simply kept on using Google Chrome.
Chrome "worked" for most of the web sites that I visit on a daily basis. And it did a good job of fading into the background. Most of the time, I don't think thoughts like "This is Chrome." By the time I realize I still haven't written a review, three months have passed.
So, what kept me from falling back to Firefox 3.0.4? Start up time. Maybe it's because I have too many plugins installed in Firefox, the few times when I tried to use Firefox its start up time is three times that of Chrome. Whereas Chrome starts in one second, Firefox starts in three.
I know what you are thinking: "It's only three seconds." You can't believe how long that three seconds feel, especially when there is a one second alternative that does the same thing. "I can't believe how I tolerated this before," was my thought every time I start Firefox.
Now, my complaints. I have only two. First, if I click on a link and Chrome starts a download, that download "belongs" to that tab. And the download will be canceled if that tab or the whole browser is closed. And this is a real-life issue. I have been bitten by it several times.
Second, there are still some financial institutions that tell me only IE or FF are supported. This is not Google Chrome's fault, but it is a problem for the Chrome user nevertheless. My work around is to fall back to IE.
So, I'm quite a happy Google Chrome user.
JavaFX 1.0 On Linux: NetBeans Plugin
[Update (Wed Jun 3 07:45:43 PDT 2009)]: As of June 2, 2009, you can download the Linux and Solaris version of JavaFX 1.2 SDK directly from http://javafx.com. The Linux and Solaris support is preview only.[/]
This is a follow up on my Using JavaFX 1.0 On Linux seven days ago.
That blog entry was picked up by:
A commenter on my blog (and several commenters on the above cited blogs) asked about if the JavaFX NetBeans plugin can be made to work on Linux. Sure it can. It's Java.
However, since the plugin is not officially released for Linux, things are a little bit confusing: If you browse for Available Plugins and search for javafx, you will see three plugins:
- JavaFX Source Debug
- JavaFX 1.0
- JavaFX Weather Sample
but they cannot be installed. The error message reads:
No plugin providing the capability javafx.sdk could be found.
These three are leftovers from the JavaFX Preview SDK release. We do not want them. We need to browse to the NetBeans update center to find the ones we want:
http://updates.netbeans.org/netbeans/updates/6.5/uc/final/stable/modules/javafx/
It contains 23 *.nbm (Netbeans module) files. Download them all into a directory.
In NetBeans plugin manager, go to the Downloaded tab and click on the Add Plugins... button, and add all the downloaded files. You will see 21 plugins showing up in the window. Now *uncheck* the three JavaFX Preview SDK plugins listed above and install the rest 18. The installation should go normally, prompting you to restart Netbeans.
The two *.nbm files that the NetBeans plugin manager did not show contains the Windows and Mac versions of the JavaFX SDK 1.0. We ignore the Windows file and concentrate on the Mac version. We do a manual installation:
- Unzip the file (It's a Zip formatted file)
- This generated a few subdirectories, one of them is netbeans
- The netbeans directory further contains subdirectories config, javafx-sdk1.0 and modules
- In your NetBeans 6.5 installation directory, create a subdirectory javafx2 (in parallel to the java2, groovy1 and ruby2 subdirectories) and copy the config, javafs-sdk1.0 and modules directories into javafx2.
- You may need to go into the javafx-sdk1.0/bin subdirectory and make the scripts there executable.
That's it. You now can create JavaFX projects in NetBeans 6.5, edit, compile, debug and preview the project.
Enjoy!
Or wait for the official Linux release, which is only (I heard it somewhere) weeks away.
(Disclaimer: I know very little about NetBeans modules. Although the above procedure appears to work for me, I'm not sure if there is a shorter way to do all this, or if it will have any negative effects on your NetBeans installation. YMMV.)
St. Louis λ-Lounge
The inaugural meeting of the St. Louis λ-Lounge was held at Appistry this evening.
More than thirty people came. Alex Miller from Terracotta lead the opening discussion. Matthew Taylor from Spring Source showed two meta-programming techniques in Groovy. Ryan Senior did an introduction to OCaml.
Mark Volkmann will talk about Clojure in the January meeting. Mario Aquino volunteered a talk about writing iPhone applications or Widgets.
The vision of the group is to pull together the people who are interested in alternative languages that won't viably form individual dedicated user groups. Functional programming and dynamic languages are the focal points. Essentially, its a place where we can talk about things like tail-call optimization, closures, continuations, duck typing, meta-programming protocols, type inferences, monads, and Gödel's incompleteness theorem without being ridiculed.
It was a bit long, from 6:00pm to about 9:00pm. But its fun.
Overheard at the meeting:
- Ten years ago, we gathered to get into Java. Now we are getting away from Java.
- XSLT should count as a functional language.
- Is there a web framework for OCaml.
- Can I use your meta-programming techniques to subvert DRM.
- The Office-based joke that I didn't get (something about pennies from accounts.)
- I follow you on twitter. I follow you too.
- I still haven't gotten over the fact that both Symbolics and the LMI went out of business.
Using JavaFX 1.0 On Linux
[Update (Wed Jun 3 07:45:43 PDT 2009)]: As of June 2, 2009, you can download the Linux and Solaris version of JavaFX 1.2 SDK directly from http://javafx.com. The Linux and Solaris support is preview only.[/]
This is a quick update to my Watch JavaFX SDK Run---On Linux post from 121 days ago.
With the preview release, we got an easy pass because zip file versions of the SDK was available from the download site. For the now online JavaFX 1.0, only the Windows installer and the Mac OS X disk image (*.dmg) versions are available.
Fortunately, Linux can deal with Mac dmg files quite easily. Here's what I tried on my Ubuntu 8.10 amd64 box:
- Download The Mac OS X version of JavaFX SDK 1.0 from JavaFX Downloads for Mac and Windows page
- Run bunzip2 to decompress the downloaded javafx_sdk-1_0-macosx-universal.dmg
- Mount the result at a directory. The directory will contain many levels of subdirectries and files
- Unarchive on of the files with cpio to get a javafx-sdk1.0 directory
Here's a transcript of my terminal session:
[weiqi@gao:~] $ file javafx_sdk-1_0-macosx-universal.dmg javafx_sdk-1_0-macosx-universal.dmg: bzip2 compressed data, block size = 100k [weiqi@gao:~] $ bunzip2 javafx_sdk-1_0-macosx-universal.dmg bunzip2: Can't guess original name for javafx_sdk-1_0-macosx-universal.dmg -- using javafx_sdk-1_0-macosx-universal.dmg.out bunzip2: javafx_sdk-1_0-macosx-universal.dmg: trailing garbage after EOF ignored [weiqi@gao:~] $ mkdir mount-point [weiqi@gao:~] $ sudo mount -o loop -t hfsplus javafx_sdk-1_0-macosx-universal.dmg.out mount-point [sudo] password for weiqi: [weiqi@gao:~] $ mkdir javafx-sdk1.0 [weiqi@gao:~] $ cd javafx-sdk1.0/ [weiqi@gao:~/javafx-sdk1.0] $ gunzip -c ../mount-point/javafx_sdk-1_0.mpkg/Contents/Packages/javafxsdk.pkg/Contents/Archive.pax.gz | cpio -i 65687 blocks [weiqi@gao:~/javafx-sdk1.0] $ ls bin docs LICENSE.txt README.html servicetag THIRDPARTYLICENSEREADME.txt COPYRIGHT.html lib profiles samples src.zip timestamp
A little involved, but we got our javafx-sdk1.0 directory. Copy it to the appropriate place like /opt or wherever you install software packages, add the javafx-sdk1.0/bin directory to your $PATH, and you are in business.
As usual, all the pure Java stuff should work.
I'll let you know what I can do when I play a little bit more with it.
JSR 277: On Hold
Mark Reinhold: Sun has therefore decided to halt development of the JAM module system, and to put JSR 277 on hold until after Java SE 7.
JDK 7, Which They Hope To Deliver Early In 2010...
...and in modules.
Mark Reinhold: JDK 7 As a first step toward this brighter, modularized world, Sun’s primary goal in the upcoming JDK 7 release will be to modularize the JDK.
There will be other goals, to be sure—more on those later—but the modularization work will drive the release, which we hope to deliver early in 2010.
Java News Brief (JNB): Experiments With JavaFX Script
This month's OCI Java News Brief (JNB) is online now. Since I last reported on JNB in September about Mark's WAX article, let me briefly mention the JNBs that were published since:
- October: Complex Event Processing with Esper by Paul Jenssen
- November: Exploring Scalable Data Processing with Apache Hadoop by Tom Wheeler
- December: Experiments With JavaFX Script by Weiqi Gao
The December article is written by yours truly. It grew out of an OCI Java lunch about JavaFX in July of this year, a couple of days before the JavaFX Preview SDK release. (Talking about OCI's Java lunchs, please check out the video of this month's Java lunch—Eric Burke's Android presentation on YouTube.) I also signed up to write a JNB article about JavaFX for December, not knowing that JavaFX Desktop SDK 1.0 will be released on Devember 4, a few days after the article goes online.
The article is a bit long. That's because I started early, and I wanted to cover the language to the extent that after reading the article, you can go on reading JavaFX source files without too many language related issues.
I wrote the article in the last three weekends before Thanksgiving, plus the evenings in between. The three most enjoyable aspects of the writing process are:
- The openjfx-compiler Open Source project, where when you ask a question, the JavaFX compiler team members, including Brian Goetz, Per Bothner, Robert Field, will answer your question.
- The AntlrWorks IDE for ANTLR grammars with its syntax diagram display. The developers of the JavaFX ANTLR grammar may have spent days agonizing over the language design details. With AntlrWorks I can browse the whole thing in minutes.
- The MarkMail.org mailing list archive and search tool. It uses the MarkLogic Server XQuery technology. And its web UI is really easy to use. The openjfx-compiler's mailing lists are all available at http://openjfx.markmail.org.
So if you are at all curious about this new JavaFX Script language, give the article a try. It's a charming little language that can do lots of cute things.
And of course, go get the 1.0 release on December 4 from javafx.com.