0

Does one JAR depend upon another for the ACC? The documentation isn't crystal clear on this, at least so far as I've read.

My understanding is that I need to build an EAR from existing code which I can deploy remotely. This EAR should contain the existing client. All of the code: 1.) the client, 2.) the EJB module and 3.) the remote interface runs on localhost. I've deployed the EJB to a remote Glassfish server.

How do I create an "ant-java-ee project" from Creating and Running an Application Client on the GlassFish Server? The sample I created packages very oddly. Netbeans doesn't seem to have a "ant jar" option which builds it in a familiar way for me. There's no ant jar target as is typical with Netbeans applications; ant dist results in:

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$ 

On the other hand, ant run gives good results:

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

These jar's are not packaged how I would expect:

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$ 

I'm unclear as to the relationship between these JAR's. Typically Netbeans will build a "lib" folder for API's. In this case, there's some magic with the ACC. The goal is to package this application as an EAR in order to deploy it to the remote Glassfish server.

Community
  • 1
  • 1
Thufir
  • 8,216
  • 28
  • 125
  • 273

1 Answers1

0

Choose File > New Project and select Enterprise Application Client in the Java EE category

you need Remote interface, not ejb code in client

client uses rmi (socket) to talk to server and runs ejb in the server side

client containers are treated like step children for vendors, most soa architectures have full java ee server on both sides i.e. a java ee web app is the client of java ee ejb/webservice app

I hate all those netbeans files, I would rather use maven, it may be harder at times but you ll get better support on the web

for remote calls i would use jax-rs or jax-ws

Kalpesh Soni
  • 6,879
  • 2
  • 56
  • 59
  • to clarify, there's no ejb code in the client -- it's just like the netbeans sample. – Thufir Sep 19 '14 at 19:59
  • if you really want client project it has to be client project, not java ee ejb type project – Kalpesh Soni Sep 19 '14 at 20:00
  • that would mean that there's no point to the ACC, nor to the netbeans tutorial... what is the purpose of the ACC then? – Thufir Sep 19 '14 at 20:36
  • to have a stand alone java se client execute remote ejb – Kalpesh Soni Sep 19 '14 at 20:40
  • ok, I don't understand your point, sincerely. I'm trying to make a stand along java se client execute a remote EJB -- that is the context of the problem. Perhaps the question was flawed. **How** is the client configured for the remote connection? – Thufir Sep 19 '14 at 21:36
  • you keep saying ear and remote glassfish server, it sounds like you are NOT using simple java se client – Kalpesh Soni Sep 19 '14 at 21:46
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/61586/discussion-between-thufir-and-kalpesh-soni). – Thufir Sep 19 '14 at 21:59