使用Glassfish上的应用程序客户端容器(ACC)构建用于远程部署的耳机

时间:2014-09-19 19:20:43

标签: java netbeans jar glassfish ear

一个JAR是否依赖另一个JAR?文档对此至关清楚,至少so far as I've read

我的理解是我需要从existing code构建一个可以远程部署的EAR。此EAR应包含现有客户端。所有代码:1。)客户端,2。)EJB模块和3.)远程接口在localhost上运行。我已将EJB部署到远程Glassfish服务器。

如何创建" ant-java-ee project"来自Creating and Running an Application Client on the GlassFish Server?我创建的示例包非常奇怪。 Netbeans似乎没有一个" ant jar"选项,以熟悉的方式为我构建它。 Netbeans应用程序通常没有ant jar目标; ant dist导致:

dist:

BUILD SUCCESSFUL
Total time: 6 seconds
thufir@dur:~/NetBeansProjects/HelloClient$ ll
total 32
drwxrwxr-x  7 thufir thufir 4096 Sep 19 11:51 ./
drwxrwxr-x 16 thufir thufir 4096 Sep 16 09:22 ../
drwxrwxr-x  5 thufir thufir 4096 Sep 19 11:51 build/
-rw-rw-r--  1 thufir thufir 3654 Sep 13 20:40 build.xml
drwxrwxr-x  2 thufir thufir 4096 Sep 19 11:51 dist/
drwxrwxr-x  3 thufir thufir 4096 Sep 13 20:38 nbproject/
drwxrwxr-x  4 thufir thufir 4096 Sep 13 20:38 src/
drwxrwxr-x  2 thufir thufir 4096 Sep 13 20:38 test/
thufir@dur:~/NetBeansProjects/HelloClient$ ll dist/
total 12
drwxrwxr-x 2 thufir thufir 4096 Sep 19 11:51 ./
drwxrwxr-x 7 thufir thufir 4096 Sep 19 11:51 ../
-rw-rw-r-- 1 thufir thufir 1848 Sep 19 11:51 HelloClient.jar
thufir@dur:~/NetBeansProjects/HelloClient$ 
thufir@dur:~/NetBeansProjects/HelloClient$ 
thufir@dur:~/NetBeansProjects/HelloClient$ java -jar dist/HelloClient.jar 
Exception in thread "main" java.lang.NoClassDefFoundError: hello/HelloBeanRemote
    at helloclient.Main.main(Main.java:11)
Caused by: java.lang.ClassNotFoundException: hello.HelloBeanRemote
    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 java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    ... 1 more
thufir@dur:~/NetBeansProjects/HelloClient$ 

另一方面,ant run给出了很好的结果:

-run:
     [java] hello world

run:

BUILD SUCCESSFUL
Total time: 28 seconds
thufir@dur:~/NetBeansProjects/HelloClient$ ll dist/
total 32
drwxrwxr-x 3 thufir thufir  4096 Sep 19 11:56 ./
drwxrwxr-x 7 thufir thufir  4096 Sep 19 11:56 ../
drwxrwxr-x 2 thufir thufir  4096 Sep 19 11:56 HelloClientClient/
-rw-rw-r-- 1 thufir thufir 13106 Sep 19 11:56 HelloClientClient.jar
-rw-rw-r-- 1 thufir thufir  1848 Sep 19 11:56 HelloClient.jar
thufir@dur:~/NetBeansProjects/HelloClient$ 

这些罐子没有包装我的预期:

thufir@dur:~/NetBeansProjects/HelloClient$ 
thufir@dur:~/NetBeansProjects/HelloClient$ jar -tf dist/HelloClient.jar 
META-INF/
META-INF/MANIFEST.MF
helloclient/
META-INF/application-client.xml
helloclient/Main.class
thufir@dur:~/NetBeansProjects/HelloClient$ 
thufir@dur:~/NetBeansProjects/HelloClient$ jar -tf dist/HelloClientClient.jar 
META-INF/MANIFEST.MF
META-INF/application-client.xml
META-INF/glassfish-application-client.xml
META-INF/sun-application-client.xml
org/glassfish/appclient/client/AppClientFacade.class
META-INF/javaee.client.policy
META-INF/restrict.client.policy
thufir@dur:~/NetBeansProjects/HelloClient$ 
thufir@dur:~/NetBeansProjects/HelloClient$ jar -tf dist/HelloClientClient/HelloClient
HelloClientClient.jar  HelloClient.jar        
thufir@dur:~/NetBeansProjects/HelloClient$ jar -tf dist/HelloClientClient/HelloClient.jar 
META-INF/MANIFEST.MF
META-INF/application-client.xml
helloclient/Main.class
thufir@dur:~/NetBeansProjects/HelloClient$ 
thufir@dur:~/NetBeansProjects/HelloClient$ jar -tf dist/HelloClientClient/HelloClientClient.jar 
META-INF/MANIFEST.MF
META-INF/application-client.xml
META-INF/glassfish-application-client.xml
META-INF/sun-application-client.xml
org/glassfish/appclient/client/AppClientFacade.class
META-INF/javaee.client.policy
META-INF/restrict.client.policy
thufir@dur:~/NetBeansProjects/HelloClient$ 

我不清楚这些JAR之间的关系。通常Netbeans会构建一个" lib" API的文件夹。在这种情况下,ACC会有一些魔力。目标是将此应用程序打包为EAR,以便将其部署到远程Glassfish服务器。

1 个答案:

答案 0 :(得分:0)

选择文件>新项目并在Java EE类别中选择Enterprise Application Client

您需要远程接口,而不是客户端中的ejb代码

客户端使用rmi(套接字)与服务器通信并在服务器端运行ejb

客户端容器被视为供应商的步骤子项,大多数soa架构都有完整的Java ee服务器,即java ee web应用程序是java ee ejb / webservice app的客户端

我讨厌所有那些netbeans文件,我宁愿使用maven,有时可能会更难,但你会在网上获得更好的支持

对于远程调用,我会使用jax-rs或jax-ws