users@glassfish.java.net

Re: Dumb Beginner Question

From: <glassfish_at_javadesktop.org>
Date: Tue, 07 Oct 2008 06:26:26 PDT

Thanks for the informative post!

> The "custom JVM" part I find a bit disturbing. It
> would be interesting as to what is "custom" about
> it.
>
> What your command line does is a couple of things.
>
> 1) It executes the "default class" of your
> "company.jar" file. This is defined in the Manifest
> of the jar as to exactly what class is being
> executed. But on that class, the "public static void
> main(String args[])" method is what is being
> executed.
>
> 2) All of those arguments are arguments to the actual
> executing programs (as in they are passed as string
> in the args[] array of the main method).

What is custom is how it interacts with the back-end server, and how the java classes get instantiated when connected through this JVM-- picture a custom backing store.

Here are some things that I know about it-

1. It has a custom class loader
2. It is a new product, so nobody has tried to connect it to glassfish, so I don't even know if it will (yet) work.
3. It uses the parameters that get passed in (host/port/credentials) to connect to the backing store.

> 3) I believe this includes the "-classpath" option as
> well as the "examples.hellowworld.HelloWorldMain"
> option. "-classpath" is normally used for the JVM
> itself, but since it appears AFTER the -jar option, I
> think the JVM is going to ignore that argument and
> pass it to the program as an option. As far as I know
> "-jar" and "-classpath" are exclusive options to the
> JVM, you can have one or the other but not both.

Looking at our docs, the above makes sense. From what our docs sound like, it is inserting itself in to the middle so-to-speak.
It is starting with a custom classpath (pre-defined to include information from the backing store, which apparently might have jar's on it), finally looking at the client-side classpath which got passed in as an arg.

>
> If you wish to use the code in this jar within
> Glassfish, you should simply treat it as a library.
> This means you will call the code within the jar
> directly rather than, typically, relying on the jars
> default class static "main" method.

This above part is what I apparently cannot do-- according to our docs:

"Attempting to execute an application that uses Company classes without specifying the company.jar file as the first -jar option will cause a Java stack dump because the Company classes cannot execute outside of a Fluency JVM

> Now, you could certainly call that yourself, building
> up your own argument string array and simply passing
> it to the "main" method, but most systems aren't used
> that way.

Any tips as to how I might go about this?

Right now, I don't care if it is dirty or ugly, I just want to get it to work.

Once I know that it can work, then I can worry about prettying it up ;)
[Message sent by forum member 'jrsmobile' (jrsmobile)]

http://forums.java.net/jive/thread.jspa?messageID=303732