users@glassfish.java.net

Re: Invoke Application Client

From: <glassfish_at_javadesktop.org>
Date: Wed, 12 Nov 2008 06:40:26 PST

Laird has described one way to run the app client.

If you really want to use the appclient command yourself for some reason, you can do that also.

You might be able to do this easily from Eclipse, but I do not use Eclipse so I do not know if it provides a way to run app clients from inside the IDE.

When you deploy an EAR that contains an app client, GlassFish generates a JAR file that contains your app client plus any library JARs that the client depends on. If you deploy using the command line you can retrieve this generated JAR file using the --retrieve option. Another way, perhaps more useful for you, is you can use the asadmin get-client-stubs command which retrieves the same generated JAR file but after the deployment has run. So, if you use

asadmin get-client-stubs --appname your-app-name dir-to-store-JAR-file

then you should see a copy of the generated JAR file for your app in the dir-to-store-JAR-file directory. Then use

appclient -client dir-to-store-JAR-file/the-retrieved-JAR.jar

to launch your client.

Note that this works without any additional steps if you are on the same system where the server software is installed. If you want to launch the client on a different system, you need to make sure the other system has the needed GlassFish components. This is described in the documentation: http://docs.sun.com/app/docs/doc/819-3672/beakt?a=view (look for the section on the package-appclient script.)

If your client expects command line arguments, just add them to the end of the appclient command when you launch the app client.

Using the built-in Java Web Start support, as Laird has described, relieves you of needing to retrieve the generated client JAR, manually install any GlassFish bits on a remote system, etc. To pass arguments when you launch this way, just add a query string of the form

?arg=first-arg&arg=second-arg ...

to the URL. As Laird mentioned, you can find out what URL to use for launching via Java Web Start from the admin console. Also, when you deploy the EAR GlassFish will write a message to the log file showing the context-root part of the URL you can use. If GlassFish is running on myHost then the full URL will be something like http://myHost:8080/${context-root-displayed-in-deployment-message}

This is also described in the doc.

Enjoy!

- Tim
[Message sent by forum member 'tjquinn' (tjquinn)]

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