Skip to main content

Invoke Application Client

3 replies [Last post]
Anonymous

Hi.
I created a simple EAR project in eclipse, which contains 3 modules: EJB3, Web, and application client (Java SE, with plain main method). After deploying the EAR, I would like to invoke the java client, but I don't know how to invoke it. ${glassfish}/bin/appclient expects a jar file, but where is the jar and how to use this command?
Thanks.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
ljnelson
Offline
Joined: 2003-08-04
Points: 0

> Hi.
> I created a simple EAR project in eclipse, which
> contains 3 modules: EJB3, Web, and application client
> (Java SE, with plain main method). After deploying
> the EAR, I would like to invoke the java client, but
> I don't know how to invoke it.
> ${glassfish}/bin/appclient expects a jar file, but
> where is the jar and how to use this command?
> Thanks.

Glassfish should automatically make the appclient available via Webstart. You should be able to get there from the admin GUI (then just bookmark the URL).

Best,
Laird

tjquinn
Offline
Joined: 2005-03-30
Points: 0

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

szczyp

I cannot use JavaWebStart as I am running 64bit Linux and there is no Java Plugin available (sic!).
The CLI version does all I need to do my little tests, thank you very much!