【发布时间】:2014-11-14 11:09:40
【问题描述】:
对于 ACC,一个 JAR 是否依赖于另一个 JAR?文档对此并不十分清楚,至少so far as I've read。
我的理解是我需要从existing code 构建一个可以远程部署的 EAR。此 EAR 应包含现有客户端。所有代码:1.) 客户端,2.) EJB 模块和 3.) 远程接口在 localhost 上运行。我已将 EJB 部署到远程 Glassfish 服务器。
如何从Creating and Running an Application Client on the GlassFish Server 创建一个“ant-java-ee project”?我创建包的示例非常奇怪。 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$
这些 jar 没有按我的预期打包:
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 将为 API 构建一个“lib”文件夹。在这种情况下,ACC 有一些魔力。目标是将此应用程序打包为 EAR,以便将其部署到远程 Glassfish 服务器。
【问题讨论】:
标签: java netbeans jar glassfish ear