admin@glassfish.java.net

Re: Thoughts about access to license from Java API

From: Ken Paulsen <Ken.Paulsen_at_Sun.COM>
Date: Tue, 12 Aug 2008 12:26:42 -0700

Hi Tom,

In order for the bundle to be visible to the web app, you'll need a META-INF/MANIFEST.MF file in your web app that contains something like:

    HK2-Import-Bundles: com.sun.pkg.client

Then it should work.  Alternatively, Anissa or I can give you the admingui.war file.  You can deploy that and attempt to start the server.  It will resolve the bundle when you do that.

FYI, our META-INF/MANIFEST.MF file looks something like:
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: anilam
Build-Jdk: 1.5.0_13
Glassfish-require-services: org.glassfish.api.admingui.ConsoleProvider
HK2-Import-Bundles: org.glassfish.admingui.console-common,com.sun.enterprise.hk2,org.glassfish.admingui.console-plugin-service, org.glassfish.common.amx-api, org.glassfish.deployment.deployment-client,org.glassfish.registration.registration-api,org.glassfish.registration.registration-impl, org.glassfish.javax.servlet, javax.servlet.jsp, org.glassfish.jsftemplating, org.glassfish.admingui.dataprovider, com.sun.pkg.client
Thanks,

Ken

Tom Mueller wrote:
Sorry about that.  This time I commented out that whole code block (please see the attached file).

I'm trying to get GFv3 running with a little web app so that I can debug this. Will it work to do the following:

1. copy pkg-client.jar to glassfish/modules
2. deploy a simple web app that has a JSP
3. modify the JSP to import com.sun.pkg.client.Image and then call the constructor

?

Thanks.
Tom



Anissa Lam wrote:
Hi Tom,
I tried with this jar that you attached.
I am still getting NPE,  but at a different line:

INFO: !!! Cannot create update center Image for /Users/anilam/Sun/v3/v3-pb18
Aug 12, 2008 11:49:47 AM 
SEVERE: java.lang.NullPointerException
Aug 12, 2008 11:49:47 AM 
SEVERE:         at com.sun.pkg.client.Image.getVersion(Image.java:1205)
Aug 12, 2008 11:49:47 AM 
SEVERE:         at com.sun.pkg.client.Image.<init>(Image.java:576)
Aug 12, 2008 11:49:47 AM 
SEVERE:         at org.glassfish.uc.admingui.UpdateCenterHandlers.getUpdateCenterImage(UpdateCenterHandlers.java:219)


thanks
Anissa

Tom Mueller wrote:
Anissa,

Please find attached a pkg-client.jar that has a temporary fix for this problem.  It just checks for null at that point and returns a version of "0" in that case. It also fixes the version problems (Rajkumar will be checking in an official change for that).

Hopefully this will help with making progress. The only impact of this temporary fix is that the User-agent header will have the wrong version information in it.
Tom

Tom Mueller wrote:
Thanks for the info.  I've created issue 547 to track this. It definitely has something to do with running as an OSGi bundle. The line before the NPE is the following:

            String classContainer = Image.class.getProtectionDomain().getCodeSource().getLocation().toString();

Apparently this returns null when running as an OSGi bundle. I'll need to determine something to replace this.

Thanks.
Tom

Anissa Lam wrote:
Hi Tom,


Tom Mueller wrote:
Anissa,
I see a bug in that section of the code, having to do with the recent changes to the version values in the manifest file.  However, I don't see how it would be causing that NPE.

Do you know what version of the JAR file you are using?  I especially interested in the subversion revision number (1048 or something like that).
I am using  pkg-client-1.0.7-13.1048.jar


Also, what environment are you running this in? Is this a command-line test program, or are you running within the context of glassfish?
I have just tested that.

image = new Image (new File ("/Users/anilam/Sun/v3/v3-pb18"));

The same line works fine in a simple standalone program,  but give NPE when running as part of GlassFish.  Maybe issue with the OSGi bundle ?

thanks
Anissa.

Thanks.
Tom

Anissa Lam wrote:
Hi Tom,

I wasn't able to get that jar working until today.  Thanks to Ken who finally figured that the problem was relating to versioning of the jar and an email sent out earlier.   Because of this,  I was not able to look at the API about getting the license content.

Now that i finally able to use the jar,  I ran into a NPE when creating the image.  Please let me know if this is a regression or i did something wrong.  My code was working before with the previous jar.

Here is my code, and the stack trace:

image = new Image (new File (ucDir));     //I am sure the ucDir is correct.

Here is the stack trace:

Aug 11, 2008 5:26:03 PM 
INFO: !!! Cannot create update center Image for /Users/anilam/Sun/v3/v3-pb18
Aug 11, 2008 5:26:06 PM 
SEVERE: java.lang.NullPointerException
Aug 11, 2008 5:26:06 PM 
SEVERE:         at com.sun.pkg.client.Image.getVersion(Image.java:1180)
Aug 11, 2008 5:26:06 PM 
SEVERE:         at com.sun.pkg.client.Image.<init>(Image.java:575)
Aug 11, 2008 5:26:06 PM 
SEVERE:         at org.glassfish.uc.admingui.UpdateCenterHandlers.getUpdateCenterImage(UpdateCenterHandlers.java:219)
Aug 11, 2008 5:26:06 PM 
SEVERE:         at org.glassfish.uc.admingui.UpdateCenterHandlers.getInstalledPath(UpdateCenterHandlers.java:45)
Aug 11, 2008 5:26:06 PM 

thanks
Anissa.

Tom Mueller wrote:
Anissa,

Last Friday, I updated the issue for adding a feature to the pkg Java API for getting access to the contents of the licenses for a package.  Did you have a chance to look at this?

The issue is here: https://updatecenter2.dev.java.net/issues/show_bug.cgi?id=452

I was wondering if you had a preference regarding these various options for implementing this feature.

Thanks.
Tom