Glassfish appclient从EAR部署 - 它是如何执行的?

时间:2014-09-23 02:48:41

标签: java java-ee netbeans glassfish ejb

HelloEARACC,一个使用Glassfish应用程序客户端容器(ACC)的“hello world”,从CLI部署并在Netbeans上使用F6运行。在初始运行之后,可以从CLI运行客户端。

客户端HelloEARACC如何从Netbeans外部执行?

创建HelloEARACC后,项目已作为模块添加到HelloEAR,以便EAR在ear内部署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:~$ 

这是我感兴趣的HelloEARACC.jar - 我该如何执行它?

我可以使用HelloEARACC从CLI运行ant clean;ant run

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$ 

如果我在项目目录中并且在从IDE运行F6后使用ant clean;ant run - 其他尝试执行客户端的操作类似于:

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:~$ 

虽然可以run this EJB from the EAR on Glassfish, with JNDI lookup,但我更愿意使用appclient - 为appclient用法打包和部署的正确方法是什么?

0 个答案:

没有答案