1

I am starting a new enterprise project and use Glassfish 3 as an application server and NetBeans 6.9 as an IDE. I have some EJBs which I want to access remotely from a desktop Swing application. AFAIK there are two options - either use plain JNDI lookup or run the Swing application in an application-client container and use @EJB annotations. I tried successfully the first option but I had to copy all glassfish libraries to satisfy the dependencies(about 50MB, which I don't find normal). Now I try the second option. In NetBeans, I create a new Enterprise Application Client project, add the EJB project as a dependency and press run. I get the following exception: Sniffers with type [ejb] and type [appclient] should not claim the archive at the same time. Now if I remove the package checkbox, next to the EJB project in the Project properties of application client, I get a different ClassNotFound exception of my remote interface.

I feel kind of stuck:( Could some more experienced guys, tell me how do they access their EJBs remotely, using Glassfish 3? As I have written above, I succeed with the first option, but 50MB are too much in my opinion for a simple client.

Edit: What approach would you choose for deployment and remote access from the client, if you have the business logic in ejbs on a remote server?

Thanks for any suggestions you have!

Wish you all the best, Petar

Petar Minchev
  • 46,889
  • 11
  • 103
  • 119
  • Did you download the full version or just web profile? The 'sniffer' is part of glassfish container that figures out which container to start when you deploy a jar file. It introspects the jar file to look for tell tale files like web.xml, etc. Since sniffer is complaining about not being able to find the ejb container, my guess is that you may have download the web profile. Try getting 'full platform' – Chuk Lee Oct 04 '10 at 04:58
  • I downloaded the full version and I think the client container is complaining because it finds two things - ejb and application client and it doesn't know which to run. But how can I reference my ejb project then?!!! – Petar Minchev Oct 04 '10 at 10:24
  • I'm not sure where you problem is but if you give me your email I'll send you a sample for you to look at – Chuk Lee Oct 05 '10 at 01:21
  • @Chuk Many thanks! Here it is - petar.minchev(at)gmail.com Just make sure your example guarantees that there is no Glassfish server installed on the client side. I will be glad if you send me an example including app-client container and also without it(completely standalone). – Petar Minchev Oct 05 '10 at 04:10
  • @Chuk - I feel like a dumbass now:( The problem was I clicked run on the application client and then Netbeans gave the sniffer exception. But if I click run on the ear, then everything is fine:) – Petar Minchev Oct 05 '10 at 16:59

1 Answers1

1

I think the best approach in your case is to create a Servlet (or some other light simple component) in your server and make this guy talk to your EJB. If you choose this case, you will isolate your client/server comunication and your business logic implementation.

Plínio Pantaleão
  • 1,229
  • 8
  • 13
  • Thanks for the answer. But I have chosen EJB, so the remote communication is easier through a well defined @Remote interface. Also I won't have a web GUI, why create a servlet then and use HTTP communication? Isn't it too low level and artifical? – Petar Minchev Oct 04 '10 at 12:18
  • Yes, it is. But if you want to avoid all the application server dependencies, i think this may be an approach. Of course, the best way is have a true EJB communication with all dependencies in your client application. In some cases it may be a problem (I have an client WebStart application with 87MB, but our customer use it in a private network, so its not a problem here). – Plínio Pantaleão Oct 04 '10 at 13:27