Insert Witty Irony Here

vince kraemer's Weblog


20060131 Tuesday January 31, 2006

Another way to waste a few minutes I have been helping a user duplicate the results of my Appclient calling and Stateles EJB 3.0 example. The user was seeing the Java Console open and then close right back up...

I read the user's code a couple times, to no avail...

It just did not work.

We kept getting this message in the log:

    Applying default to ejb reference: Unresolved Ejb-Ref client.Main/bean@jndi: beans.DistantGreeting@null@beans.DistantGreeting@Session@null
    

The Root Cause

The user had implemented the method defined in the DistantGreeting interface but did not "implement DistantGreeting". So, I am joining Cay Horstmann to call for better error messages and diagnotic tools. I have filed a couple issues against GlassFish (issue 208 and 209). Now, I am headed over to NetBeans.org to file a couple issues there... (2006-01-31 14:17:21.0) Permalink

I guess that's what you call ironic... I just read Roumen's entry about a funny video/song about OS' of yester and today [On Window's XP, in Firefox 1.0.7].

So, I started to watch it. I was having a little chuckle. Then the screen saver kicked in... I bumped the mouse to get the screen back, but Firefox and the video were GONE.

I laughed so hard I started to cry...

Because, "I guess that's what you call ironic." (2006-01-31 12:26:54.0) Permalink Comments [1]

20060130 Monday January 30, 2006

A history lesson of deployment strategies A recent entry by Jean-Francoise Arcand, reminded me of an article that I saw a couple years ago. The article covered information about deploying application to SJSAS 8.

Folk who have been paying attention may note that the GlassFish Project is based on code that was originally part of SJSAS 8, so the article has information that is relevant today...

For example, folks who want to use a "supported" fast deployment method for their J2EE components and application may want to consider combining "Directory Deployment" with "Dynamic Reloading".

I have done some tests with dynamic reloading in the past. The reloading mechanism was smart enough to detect whether I had changed a DD file or a class and http://imdb.com/title/tt0097216/.

If you are an ant user, you can even write code that will detect if you have just changed a java file and do next to nothing when you build and "redeploy" a web app that just has JSP changes. [For JSP changes, you don't need to touch the dot-reload file...]

I haven't done it for a while, so I may need to look it up or reinvent it.

NetBeans Note: Folks that use NetBeans may not know that NetBeans does the right thing for JSP web-apps deployed to the SJSAS 8.1, 8.2, and GlassFish. Web-apps are directory deployed (by default) and JSP files are copied to the "deployment" directory when they are saved in the editor. So, you can edit and reload your JSP pages... no redeploy is required! (2006-01-30 11:27:36.0) Permalink

20060129 Sunday January 29, 2006

Swing-ing to the NetBean Platform I saw this entry from Matt Ryan about an application that he convereted from pure Swing to NetBeans RCP + Swing. I get the impression that the conversion was none too difficult. (2006-01-29 21:34:50.0) Permalink

another test in testa/testb (2006-01-29 21:27:58.0) Permalink

another test in testa/testb (2006-01-29 21:27:32.0) Permalink

20060128 Saturday January 28, 2006

Win a prize with your story behind scott/tiger? It is the universal Oracle account. Known to thousand, maybe even millions... But who is "scott" and why is his password, "tiger".

If you know, "Do tell."

If you don't, make something entertaining up and share it here (or in your own blog, via a link!)

The prize....

A nice tie-dyed bubble-bursting flame out t-shirt.

The details:

  1. It's my shirt. I decide who gets it. Period.
  2. Once the comment link closes, entries are, too. Think and type fast.
  3. I will make a reasonable attempt to contact the winner. If I cannot get a mailing address from you after making that attempt, the shirt will go to somebody else.
  4. If you need to whine about any of this, you probably should not enter.
(2006-01-28 14:42:28.0) Permalink Comments [2]

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

A New Bridges Problem A co-worker and I were discussing ways to blow off steam a couple days ago. His was to put the top down and drive around. Which seems like a good one. His next comment provided more insight into what he meant, "My car gets better milage at 100 mph than it does at 25 mph..."

That lead me to a thought...

What is the fastest time that someone has "solved" the bridges of the Bay Area problem?

This really isn't a variation on the The Bridges of Konigsberg problem. It is a time-trial. The problem is to cross all eight major toll bridges that span the San Fransisco Bay in the shortest time according to your FasTrak statement.

Is there a site that catalogs such a trial? I googled and couldn't find one, so I have got to wonder... Does one exist? (2006-01-23 15:55:06.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

20060110 Tuesday January 10, 2006

Lazy people rejoice! I have been making people work too hard in the notes I have been writing in entries about using NetBeans 5 to create Java EE 5 artifacts. If a Web or Enterprise project is targetted for GlassFish, the javaee.jar file is already a library for that project [Explore the project's library node to see it].

Folks will need to remember that javaee.jar needs to be added to General projects (Java Application and Java Class Library) that need to use Java EE 5 annotations. (2006-01-10 08:38:58.0) Permalink

20060108 Sunday January 08, 2006

Fastest Web Service Development in the West Well, I read through this extensive article about creating Web Services and am ready to give you an alternative approach. After I show you how I approach doing Web Service development, I will compare the two approaches.

Get Ready

You need to install GlassFish and NetBeans 5. I am using GlassFish build 32 and a nightly build of NetBeans 5 (which will be an RC any day now). Once you install these, register the GlassFish instance with NetBeans.

Implement A Service

I will create a web-app based service, just like the other author did.

So, I create a web-app.

I create a class that will implement my service.

I add the service annotations.

    package services;
    
    import javax.jws.WebMethod;
    import javax.jws.WebService;
    
    @WebService
    public class Greeting {
        @WebMethod public String sayHello(String name) {
            return "May I be of service, "+name+"?";
        }
    }
    
I change the web.xml file, so that the web app will be deployed as a Java EE 5 component, instead of a J2EE 1.4 component. To do this you just need to change the web-app element from
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
	 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	 xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
	 version="2.4">
to
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
	 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
	 version="2.5">
I deploy the project.

Testing the Service

The GlassFish implementation of Java EE 5 includes the ability to test web services from within the Admin Console. Testing is just one of the features of the web service management capabilities in the Admin Console.

You can open the Admin console from within NetBeans, using the context menu of the target instance.

There are two sets of pages associated with web services. The first set provides general information about the services deployed on your instance. The other tab in the set allows you to create a catalog of registries.

The second set of pages/tabs allows you to manipulate individual services. The General tab provides all sorts of detailed information and has the Test button.

A new browser window opens when you press the Test button.

After you enter the arguments for the service, pressing the operation button provides the result and detailed informatiion about the SOAP messages exchanged between the service and the client.

Comparison of the two implementation methods

Both processes use JAX-WS 2.0 to implement a web service. Both methods deploy that service onto GlassFish. Both methods use NetBeans 5.0 as the development environment.

The method outlined in the other article stays within the boundries of what NetBeans 5.0 supports. My method goes outside that supported environment slightly, since changing the web-app element disables the web.xml multiview editor. If you need to do a lot of web.xml editing, change the web-app element LAST, so you can take advantage of the GUI editing capabilities.

The other method requires that you change the build.xml file for your web application. This is supported. The method that I outline in this entry pushes most of the "work" to the GlassFish deployment processing. This is also supported. It may be a bit less error-prone, since you won't need to remember to edit the build.xml for each SEI that is in the implementation WAR file.

Conclusion

At this point, you have a couple different strategies to implement JAX-WS 2.0 web services in NetBeans for deployment to GlassFish. Both are pretty easy to do.

You also have a couple different strategies for testing your web services.

You have seen some of the Web Service Management features exposed by the Admin Console.

Updates

Ludo pointed out a mistake in this note... If you register a project for deployment to a GlassFish domain, javaee.jar is ALREADY a library! To see it, explore the Libraries node of your web project. I have updated this note to account for that. I love it when things get easier! (2006-01-08 09:51:47.0) Permalink Comments [3]

Calendar

« January 2006 »
SunMonTueWedThuFriSat
1
2
4
5
6
7
9
11
14
15
16
17
18
19
20
21
22
24
25
26
27
    
       
Today

RSS Feeds

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

About Me

Photo of Vince Kraemer
Short Bio

Search

Links


Navigation



Subscribe with Bloglines Add to Technorati Favorites

Referers

Today's Page Hits: 54