HelloEARACC
, a "hello world" using the Glassfish Application Client Container (ACC), deploys from the CLI fine and runs with F6 on Netbeans. After the initial run, it's then possible to run the client from the CLI.
How is the client, HelloEARACC
, executed from outside of Netbeans?
When HelloEARACC
was created, the project was added to HelloEAR
as a module so that the EAR deploys from within an ear
as an appclient
:
thufir@dur:~$
thufir@dur:~$ glassfish-4.1/glassfish/bin/asadmin list-applications
Nothing to list.
No applications are deployed to this target server.
Command list-applications executed successfully.
thufir@dur:~$
thufir@dur:~$ glassfish-4.1/glassfish/bin/asadmin deploy NetBeansProjects/HelloEAR/dist/HelloEAR.ear
Application deployed with name HelloEAR.
Command deploy executed successfully.
thufir@dur:~$
thufir@dur:~$ glassfish-4.1/glassfish/bin/asadmin list-applications
HelloEAR <ear, appclient, ejb>
Command list-applications executed successfully.
thufir@dur:~$
thufir@dur:~$ jar -tf NetBeansProjects/HelloEAR/dist/HelloEAR.ear
META-INF/
META-INF/MANIFEST.MF
lib/
HelloEAR-ejb.jar
HelloEARACC.jar
lib/HelloLibrary.jar
thufir@dur:~$
It's this HelloEARACC.jar
which interests me -- how do I execute it?
I can run HelloEARACC
from the CLI with ant clean;ant run
with:
run-deploy:
-as-retrieve-option-workaround:
[copy] Copying 1 file to /home/thufir/NetBeansProjects/HelloEARACC/dist
[copy] Copying 2 files to /home/thufir/NetBeansProjects/HelloEARACC/dist/HelloEARACCClient
[copy] Warning: /home/thufir/NetBeansProjects/HelloEARACC/dist/gfdeploy/HelloEARACC does not exist.
-init-run-macros:
-run-pregfv3:
-run:
[java] hello world
run:
BUILD SUCCESSFUL
Total time: 25 seconds
thufir@dur:~/NetBeansProjects/HelloEARACC$
provided that I'm in the project directory and use ant clean;ant run
after running with F6 from the IDE -- other attempts to execute the client fail similarly to:
thufir@dur:~$
thufir@dur:~$ glassfish-4.1/glassfish/bin/appclient -jar NetBeansProjects/HelloEARACC/dist/HelloEARACC
HelloEARACCClient/ HelloEARACCClient.jar HelloEARACC.jar
thufir@dur:~$ glassfish-4.1/glassfish/bin/appclient -jar NetBeansProjects/HelloEARACC/dist/HelloEARACCClient.jar
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:382)
at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:397)
Caused by: java.lang.NoClassDefFoundError: Lgreetings/GreetingsBeanRemote;
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Class.java:2397)
at java.lang.Class.getDeclaredField(Class.java:1946)
at com.sun.enterprise.deployment.util.ComponentValidator.acceptWithCL(ComponentValidator.java:857)
at com.sun.enterprise.deployment.util.ComponentValidator.accept(ComponentValidator.java:781)
at com.sun.enterprise.deployment.util.AppClientValidator.accept(AppClientValidator.java:64)
at com.sun.enterprise.deployment.BundleDescriptor.visit(BundleDescriptor.java:625)
at com.sun.enterprise.deployment.archivist.AppClientArchivist.validate(AppClientArchivist.java:184)
at org.glassfish.appclient.client.acc.FacadeLaunchable.validateDescriptor(FacadeLaunchable.java:183)
at org.glassfish.appclient.client.acc.AppClientContainer.completePreparation(AppClientContainer.java:366)
at org.glassfish.appclient.client.acc.AppClientContainer.prepare(AppClientContainer.java:320)
at org.glassfish.appclient.client.AppClientFacade.prepareACC(AppClientFacade.java:279)
at org.glassfish.appclient.client.acc.agent.AppClientContainerAgent.premain(AppClientContainerAgent.java:83)
... 6 more
Caused by: java.lang.ClassNotFoundException: greetings.GreetingsBeanRemote
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at org.glassfish.appclient.client.acc.ACCClassLoader.findClass(ACCClassLoader.java:237)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 19 more
FATAL ERROR in native method: processing of -javaagent failed
^C
Aborted (core dumped)
thufir@dur:~$
thufir@dur:~$
thufir@dur:~$ glassfish-4.1/glassfish/bin/appclient -jar NetBeansProjects/HelloEARACC/dist/HelloEARACC.jar
Sep 22, 2014 7:36:09 PM org.glassfish.apf.impl.DefaultErrorHandler error
SEVERE: Class [ Lgreetings/GreetingsBeanRemote; ] not found. Error while loading [ class helloearacc.Main ]
Exception in thread "main" java.lang.NoClassDefFoundError: greetings/GreetingsBeanRemote
at helloearacc.Main.main(Main.java:11)
Caused by: java.lang.ClassNotFoundException: greetings.GreetingsBeanRemote
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at org.glassfish.appclient.client.acc.ACCClassLoader.findClass(ACCClassLoader.java:237)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 1 more
thufir@dur:~$
While it's possible to run this EJB from the EAR on Glassfish, with JNDI lookup, I would prefer to use appclient
-- what is the correct way to package and deploy for appclient
usage?