Insert Witty Irony Here

vince kraemer's Weblog


20080116 Wednesday January 16, 2008

Is Javascript the C of the Web

Last night, while the wheelers and dealers of MySQL, Sun, Oracle and BEA were signing on dotted lines the tech crowd was at Google's building 43 for the Silicon Valley Web and Java Users group meeting to hear a presentation about GWT.

Bob Vawter's presentation was excellent. He covered the basics quickly and took questions. His presentation provided answer to some of the things that make folks go, "Hmmm", when they look at the output of the GWT compiler.... Like, "What are all those obtuse numerically named files all about?"
Short answer (heavily paraphrased): They are the Javascript of the UI that you created in GWT, pretailored for each of the four major browsers out there today. The names are created from a hash of their content and are safe and easy to cache. When you change the UI, the name of the files will change, so folks don't keep seeing an old UI and have your server side processing freak out because of missing data.

There was a raffle for a number of books. I won a book.

Why does this entry have its title?

While Bob was talking about GWT, it reminded me of working at Interactive Software Engineering, now known as Eiffel Software. The Eiffel compiler used a similar "trick" of transforming a strongly typed language (Eiffel) into a weakly typed language (C). From the outside, it looks like GWT is doing something similar with Javascript playing the part of C.

Another parallel between GWT and the Eiffel compiler was the amount of optimization it could do. After expressing his sample in a rich language, Java, the compiler optimized almost ALL that richness out of the resulting Javascript code... making it much leaner.

(2008-01-16 21:18:17.0) Permalink

20070727 Friday July 27, 2007

Java API design antipattern and tip

The Antipattern: Don't Create an Event Object for Your Listener Interface's Methods

I discovered this while trying to implement against a Listener interface that just sent in the "interesting" parts of the event... A String or two.

I needed to find out the source of the event (which is a pretty standard member of an Event interface), so that I could react to the event. This is easy to resolve by creating the listener with an additional member for the "expected" source. Or it is easy to resolve until you try to garbage collect these listeners that know their source...

An Event/Listener pair helps your API mature gracefully. Additional members/accessors can get added to the Event side of the interface without requiring changes in code that implements the Listener, unless the listener wants to USE that new member/accessor.

In the interest of transparency and honesty; I have to admit that I helped review and approve the Listener interface that lead to this entry. It just goes to show the value of having to write REAL code against an interface before you say, "Oh. That looks fine."
(2007-07-27 13:48:26.0) Permalink

20060128 Saturday January 28, 2006

Equinox Hibernate Spring GlassFish Jerome has an interesting entry about using Spring and Hibernate on GlassFish.

I looked at the entry that Matt Raible posted, and decided to see if I could help him....

I assume that Matt was trying to get Equinox to run on GlassFish. So, I tried to deploy and run it, myself.

Well, I can see why Matt had so much trouble. The installation instructions were very sketchy, but I was able to get things to work. Here is what I did:

  1. Get PostgreSQL installed and configured on my Mac... [That was a whole 'nother story].
  2. Downloaded Equinox
  3. Extracted it into /Volumes/300gb/equinox.
  4. Edited build.properties, to add the following
      server.home=/Volumes/300gb/glassfish
      
  5. Ran 'ant new -Dapp.name=test3'.
    This created a directory /Volumes/300gb/test3
  6. `cd /Volumes/300gb/test3`
  7. Ran 'ant test-all'
    The tomcat tests failed, but I pressed onward...
  8. Ran 'ant deploy'
    This created an new directory and content under /Volumes/300gb/glassfish/webapps/test3. I check it out and it looked like a web-app, so it was all good.
  9. I started up GlassFish.
  10. I ran 'asadmin deploydir /Volumes/300gb/glassfish/webapps/test3'.
    At this point, I saw exceptions just like Matt's. I took a deep breath and said to myself, "Don't panic, you can beat this. It is just a web-app!"
  11. I added the following lines to the server.policy file for the domain.
      grant codeBase "file:/Volumes/300gb/glassfish/webapps/test3/WEB-INF/lib/hibernate-3.1.jar" {
              permission java.util.PropertyPermission "*", "read,write";
              permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
      };
      
      grant codeBase "file:/Volumes/300gb/glassfish/webapps/test3/WEB-INF/lib/spring-1.2.6.jar" {
              permission java.util.PropertyPermission "*", "read,write";
              permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
      };
      
      grant codeBase "file:/Volumes/300gb/glassfish/webapps/test3/WEB-INF/lib/cglib-2.1_3.jar" {
              permission java.security.AllPermission;
      };
      
      grant codeBase "file:/Volumes/300gb/glassfish/webapps/test3/WEB-INF/lib/commons-validator-1.1.3.jar" {
              permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
      };
      
      grant codeBase "file:/Volumes/300gb/glassfish/webapps/test3/WEB-INF/lib/springmodules-validator-0.1.jar" {
              permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
      };
      
    Note: I did have to iterate (start the server, read the log, stop the server, change the server.policy file) a couple times to come up with this list.
  12. Once the server started up "clean", I went to "http://localhost:8080/test3" and things looked good.

    Until I pressed the "View Demonstration" button. That is when I got the error discussed in this thread.
  13. I used the Admin Console to change the server's classpath a bit...
  14. At this point, I was able to go through the demo without any problems (AFAICT).
One thing to remember, THIS IS ALL A HACK... I don't recommend that you change your server.policy file without good reason. If running Equinox is a "good reason", then I hope this entry helps you.

I would have used NetBeans 5.0 RC2 to do this, if I had needed to actually look at real code. (2006-01-28 07:35:53.0) Permalink

20060123 Monday January 23, 2006

Custom Certificate Dialogs for JWS App Clients Java Web Start is an awesome technology... but like all awesome technologies, it can have a darkside. I went to a site yesterday that had a JWS enabled demo that had a self-signed certificate. When JWS asked me to trust the site, I had to say 'No'.

That reminded me that I had to do something similar for the application client that I created in one of my earlier entries. So I started to ask folks about how to get a real certificate associated with my clients.

To implement 'Webstartability' (Note to the AP, don't ask Steven Colbert or Michael Adams to define this soon to be 'Word of 2006'. You'll need to ask Tim Quinn) the GlassFish Project's implementation uses a generic client that is reused by all user implemented clients.

The shared, generic client is in the lib directory of the GlassFish installation. It is called 'appserv-jwsacc-signed.jar'. It is the file that triggers the security certificate dialog that appears when you start an webstartable app client. [For an example, see this entry If you take a second look in the lib directory, you will also see the file 'appserv-jwsacc.jar'. This is the unsigned version of the generic client.

Why is this file there? This file is there, so that you can sign it with YOUR own certificate. By replacing the 'appserv-jwsacc-signed.jar' with a copy of the appserv-jwsacc.jar file that is signed with your certificate and NAMED 'appserv-jwsacc-signed.jar', your users will see a new dialog, when they are asked to trust the certificate... One with your organization's name in it! (2006-01-23 17:42:39.0) Permalink

20060113 Friday January 13, 2006

Sun Java System Application Server... Not, Just for NetBeans any more!!! I love to troll... I mean read... the threads on the eclipse zone. This one caught my eye, though.

A hidden feature in the GlassFish plugin for Eclipse is the ability to register instances of Sun Java System Application Server 8.x (where x == 1 or 2). And hey, if you want SJSAS 8.2, you can get it from here (Windows), here (Linux)... and more. (2006-01-13 19:53:24.0) Permalink

NetBeans users are still ahead of the pack! This is hard to believe...

http://java.sun.com/j2ee/1.4/download.html

still hasn't been updated with Sun Java System Application Server 8.2, yet..

If you want the Latest and Greatest App Server from Sun

You gotta get it...HERE (2006-01-13 19:35:17.0) Permalink

20060112 Thursday January 12, 2006

NetBeans gives you the hottest J2EE bits first! That is right kids...

I took these screen shots at Jan 12, 2005 at 7:10 pm PST...

http://java.sun.com/j2ee/1.4/download.html has

http://www.netbeans.info/downloads/download.php has

That's right. NetBeans users are the very first in the world to get Sun Java System Application Server 8.2 bits.

Who loves you.... (2006-01-12 19:22:50.0) Permalink

20051227 Tuesday December 27, 2005

Start writing apps for Tivo in NetBeans; updates for HME 1.4 I gave my wife a Tivo box Christmas. And I got a new toy to play with....

One of the first things I did was look for how to hac... create applications for... it. And there was a ton of resources about it.

Some of the folks associated with NetBeans have an article about developing Tivo application using NetBeans. Unfortunately, it seems like the Tivo HME team is a bit more liberal about API evolution than the NetBeans team.

I had to use the following code to create the app that Tim Boudreau blogged back in February, 2005.

    package tivotest;
    import com.tivo.hme.sdk.Application;
    import com.tivo.hme.interfaces.IContext;
    import com.tivo.hme.sim.Simulator;
    import java.awt.Color;
    
    public class Main extends Application {
    
        public static void main(String[] args) {
            try {
                Simulator.main(new String[] {Main.class.getName()});
            } catch (Exception ex) {
                System.out.println("I don't know what to do!!!");
            }
        }
    
         public void init(IContext context) {
             getRoot().setResource(createText("default-36-bold.font",
                Color.white, "Hello from an application!"));
        }
    
    }
    

The bigggest changes between Tim's code and this:

  1. import of IContext.
  2. catch the Exception in main().
  3. use of getRoot() instead of a direct reference to root (which became a private member of Application).
(2005-12-27 20:20:59.0) Permalink

Java Web Start fast and easy... I wrote my entry about creating a Java Web Start-able application client, without really knowing much about Java Web Start. So, I read through the white paper that Eduardo cited on The Aquarium to learn more about it.

After I read through the paper, I realized how much work NetBeans 5 and the GlassFish Project's is doing for the developer...

  • Package the app in a jar...Covered
  • Deploying a JWS App... Covered
  • Setting up the Web Server... Covered
  • Creating the JNLP File... Covered
  • Placing the Application on the Web Server... Covered
  • Creating the Web Page... Almost
None of these things are hard. But they add up and distract developers.

Then I got to thinking, does an application client need to access resources from the server? The answer is no. It might, but doesn't have to. That means that a developer could create a "plain old java application", wrap it up in an Enterprise Application and let the GlassFish Project's deployment mechanism do the tedious housekeepinng. Their app would be JWS enabled with hardly any effort.

Sweet! (2005-12-27 12:07:23.0) Permalink Comments [2]

20051222 Thursday December 22, 2005

See the Java Console on Mac OS X While trying out GlassFish Project's Java EE 5 implementation on Mac OS X 10.4, I ran into hiccup with application clients.

I soon discovered that other folks had hit the same issue, and some hints at a solution. Note: the response from the developer, tjquinn, is one of the most complete responses I have ever read in a bug report. All I needed to do was translate his response into Apple.

After some poking around, I found the 'Java Preferences' utility in /Applications/Utilities/Java/J2SE 5.0. This utility let you set the proper flags to open the Java Console.

Image of Java Preferences showing the Java Console controls
The Java Preferences interface: Java Console radio button visible

Once I set it up, I was able to see the output of batch oriented application clients that get launched by Java Web Start. (2005-12-22 11:31:52.0) Permalink

20051111 Friday November 11, 2005

App Server 8.1 and Ubuntu 5.10 David Coldrick had an interesting entry about Ubuntu, so I thought I would give the "Breezy Badger" release a try.

Very sweet, but with a tangy little bite that I had to resolve when it came time to install Sun Java System Application Server PE 8.1 2005Q2 UR2... I think I like the name Breezy Badger better...

I got a message that told me that I needed to get libstdc++-libc6.2-2.so.3...

Horror! I barely got Ubuntu installed and now I have to find some shared library on the great wide 'net....

I checked the release notes for SJSAS. The notes had a fix, that was for rpm's.... Then I did a little more googling and came up with an entry that looked promising.

The fix listed there did the trick. (2005-11-11 18:03:23.0) Permalink Comments [0]

20050702 Saturday July 02, 2005

Running GlassFish in Mac OS X Disclaimer first. This information is about software that is currently under ACTIVE DEVELOPMENT. By the time you read it, it may not be accurate.

When you download a GlassFish jar-ball and try to install it on Mac OS X, you may see output that looks like this when you follow the installation instructions (ant -f setup.xml):

Failed to create database 'XXXYYYZZZ/domains/domain1/lib/databases/ejbtimer', see the next exception for details.

Basically, setup.xml exec's asasdmin to create an initial domain. One of the steps in creating the initial domain requires that asadmin start Derby, to create an ejbtimer database (as best I can tell).

Derby needs a special system property defined to execute under Mac OS X. Setup.xml and asadmin don't set the value of the property correctly. The property is derby.storage.fileSyncTransactionLog. It must have the value true.

The easiest thing to do, is edit bin/asadmin and add -Dderby.storage.fileSyncTransactionLog=true to the command that is executed.

Restarting the installation process `ant -f setup.xml` seems to execute sucessfully after that.

Tags: (2005-07-02 19:58:25.0) Permalink Comments [1]

Calendar

« May 2008
SunMonTueWedThuFriSat
    
1
2
3
4
5
6
7
8
9
10
11
12
13
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
       
Today

RSS Feeds

XML
All
/5 in 5
/Compile Time
/Ease of Evolution
/General
/GlassFish
/Gotchas
/Java
/Music
/NetBeans

About Me

Photo of Vince Kraemer
Short Bio

Search

Links


Navigation



Subscribe with Bloglines Add to Technorati Favorites

Referers

Today's Page Hits: 410