users@glassfish.java.net

Re: deploying and running an app client using glassfish v 2.1

From: Tim Quinn <Timothy.Quinn_at_Sun.COM>
Date: Thu, 14 Jan 2010 13:12:57 -0600

Hi, June.

The JARs indicated by the --libraries option are not used in computing
what JARs are needed by clients, whether it's a stand-alone client or
one packaged inside an EAR.

The basic problem is that the user has no way to tell GlassFish whether
a library is used only on the server side, used only on the client side,
or used in both places. To avoid expanding the download size for
clients with possibly unneeded JARs, the client download does not
include these libraries.

The developer can include a library that is needed on the client in the
EAR. In some ways it's not quite as convenient if that library is used
by multiple applications (which is something the --libraries option
makes easier) but without a clear way to know whether each library is
needed on the client or not, this is what we chose to do.

- Tim

June.Parks_at_Sun.COM wrote:
> Hi Tim,
>
> Does using the Libraries option in the Admin Console deployment page
> or the --libraries option of the asadmin deploy command work for a
> stand-alone app client? Or does an app client have to be in an EAR to
> make use of libraries?
>
> June
>
> On 12/15/09 06:35 AM, Tim Quinn wrote:
>> Hi, Jerry.
>>
>> A few notes on this:
>>
>> GlassFish makes the JARs in the glassfish/lib/... directories
>> automatically available only to server-side components, not to app
>> clients. That's why placing foo.jar there did not make it visible to
>> your app client.
>>
>> To get your app client working I'd suggest this: Instead of
>> deploying your app client as a stand-alone app client (in its own
>> module), package it into an EAR and include foo.jar in the EAR's /lib
>> directory. The app client will still be launchable using Java Web
>> Start but GlassFish will automatically make any JAR in the EAR's
>> library directory (/lib by default) accessible to all modules in the
>> EAR, including the app client. It's an additional packaging step,
>> true, but that one extra step should get things working for you.
>>
>> (If you wanted to you could package the app client and foo.jar into
>> an EAR and place foo.jar anywhere you wanted in the EAR. Then make
>> sure the app client JAR's manifest Class-Path refers to the correct
>> location within the EAR where foo.jar resides. It's a little simpler
>> to just place foo.jar in /lib and not have to worry about adjusting
>> the app client's manifest Class-Path.)
>>
>> I hope that helps.
>>
>> - Tim
>>
>> glassfish_at_javadesktop.org wrote:
>>> I'm trying to deploy and run an app client using glassfish. I
>>> deploy the jar using the following application-client.xml:
>>> [code]
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <application-client version="5"
>>> 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/application-client_5.xsd">
>>> <display-name>ApplicationClient1</display-name>
>>> </application-client>
>>> [/code]
>>>
>>> But when I try to run the application (through the glassfish admin
>>> console) I get the following runtime error:
>>> [code]
>>> Dec 14, 2009 7:36:46 PM
>>> com.sun.enterprise.appclient.MainWithModuleSupport <init>
>>> WARNING: ACC003: Application threw an exception.
>>> java.lang.NoClassDefFoundError: com/foo/bar
>>> at applicationclient1.Main.main(Main.java:22)
>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>> at
>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>>
>>> at
>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>>
>>> at java.lang.reflect.Method.invoke(Method.java:597)
>>> at
>>> com.sun.enterprise.util.Utility.invokeApplicationMain(Utility.java:266)
>>> at
>>> com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:449)
>>>
>>> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
>>> Method)
>>> at
>>> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
>>>
>>> at
>>> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
>>>
>>> at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
>>> at
>>> com.sun.enterprise.appclient.jws.boot.JWSACCMain.run(JWSACCMain.java:221)
>>>
>>> at
>>> com.sun.enterprise.appclient.jws.boot.JWSACCMain.main(JWSACCMain.java:182)
>>>
>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>> at
>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>>
>>> at
>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>>
>>> at java.lang.reflect.Method.invoke(Method.java:597)
>>> at com.sun.javaws.Launcher.executeApplication(Launcher.java:1528)
>>> at com.sun.javaws.Launcher.executeMainClass(Launcher.java:1466)
>>> at com.sun.javaws.Launcher.doLaunchApp(Launcher.java:1277)
>>> at com.sun.javaws.Launcher.run(Launcher.java:117)
>>> at java.lang.Thread.run(Thread.java:637)
>>> Caused by: java.lang.ClassNotFoundException: com.foo.bar
>>> at
>>> com.sun.enterprise.loader.EJBClassLoader.findClassData(EJBClassLoader.java:738)
>>>
>>> at
>>> com.sun.enterprise.loader.EJBClassLoader.findClass(EJBClassLoader.java:628)
>>>
>>> at java.lang.ClassLoader.loadClass(ClassLoader.java:315)
>>> at java.lang.ClassLoader.loadClass(ClassLoader.java:250)
>>> at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:398)
>>> ... 22 more
>>> Error launching or running the application
>>> java.lang.reflect.InvocationTargetException
>>> java.lang.reflect.InvocationTargetException
>>> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
>>> Method)
>>> at
>>> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
>>>
>>> at
>>> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
>>>
>>> at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
>>> at
>>> com.sun.enterprise.appclient.jws.boot.JWSACCMain.run(JWSACCMain.java:221)
>>>
>>> at
>>> com.sun.enterprise.appclient.jws.boot.JWSACCMain.main(JWSACCMain.java:182)
>>>
>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>> at
>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>>
>>> at
>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>>
>>> at java.lang.reflect.Method.invoke(Method.java:597)
>>> at com.sun.javaws.Launcher.executeApplication(Launcher.java:1528)
>>> at com.sun.javaws.Launcher.executeMainClass(Launcher.java:1466)
>>> at com.sun.javaws.Launcher.doLaunchApp(Launcher.java:1277)
>>> at com.sun.javaws.Launcher.run(Launcher.java:117)
>>> at java.lang.Thread.run(Thread.java:637)
>>> Caused by: java.lang.RuntimeException:
>>> java.lang.reflect.InvocationTargetException
>>> at
>>> com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:461)
>>>
>>> ... 15 more
>>> Caused by: java.lang.reflect.InvocationTargetException
>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>> at
>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>>
>>> at
>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>>
>>> at java.lang.reflect.Method.invoke(Method.java:597)
>>> at
>>> com.sun.enterprise.util.Utility.invokeApplicationMain(Utility.java:266)
>>> at
>>> com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:449)
>>>
>>> ... 15 more
>>> Caused by: java.lang.NoClassDefFoundError: com/foo/bar
>>> at applicationclient1.Main.main(Main.java:22)
>>> ... 21 more
>>> Caused by: java.lang.ClassNotFoundException: com.foo.bar
>>> at
>>> com.sun.enterprise.loader.EJBClassLoader.findClassData(EJBClassLoader.java:738)
>>>
>>> at
>>> com.sun.enterprise.loader.EJBClassLoader.findClass(EJBClassLoader.java:628)
>>>
>>> at java.lang.ClassLoader.loadClass(ClassLoader.java:315)
>>> at java.lang.ClassLoader.loadClass(ClassLoader.java:250)
>>> at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:398)
>>> ... 22 more
>>> [/code]
>>>
>>> the com.foo.bar class being reference is in a jar file called
>>> foo.jar. I copied the jar file to the glassfish/lib/ and
>>> glassfish/lib/domain/domain/lib/ext/. But I still get the same
>>> runtime error. However I'm able to run the application from the
>>> command line using the appclient script included with glassfish: ( I
>>> had to export the APPCPATH variable so it references the jar file I
>>> needed) [code]
>>> export APPCPATH=foo.jar
>>> ./glassfish/bin/appclient -xml sun-acc.xml myApp.jar [/code]
>>>
>>> Thanks,
>>>
>>> Jerry
>>> [Message sent by forum member 'djgerbavore' ]
>>>
>>> http://forums.java.net/jive/thread.jspa?messageID=376552
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
>>> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>>>
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
>> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>>
>