3
votes

The goal is creating a simple Java EE 6 application with EJBs deployed on a machine and the web part on a different machine. I'm using Glassfish and Netbeans 7.2 but I get confused about the dependencies between the two parts.

I've created an Enterprise Application Project and Netbeans 7.2 started splitting the project in a war part and a jar part. As the two should be deployed into two different machines (two Glassfish servers) I used the Remote option when creating the first EJB but Netbeans asked me for a Remote Project. Should I create a library containing the remote interfaces? And in that case, should the war part use it? (It seems the war jsf managed bean is already able to import the interfaces so I get confused).

All the Netbeans tutorials I've read don't mention Remote Interfaces when the client is a web application but only when the client is an enterprise client application. Which is the correct way to develop Java EE multilayered application with web components and ejb components?

2

2 Answers

2
votes

Yes, you must create one more project for remote interfaces, otherwise you could not call EJB's

0
votes

Yes. You need to create e "EJB Client" jar with all the required (Remote)business interfaces / exceptions and Travel Objects (TO).

If you use maven you can find here a good documentation how to create such one: https://maven.apache.org/plugins/maven-ejb-plugin/examples/generating-ejb-client.html

then on your war/WEB-INF/lib contains only the client-jar and all other required jars for your application, but not the jars containing your EJB Service implementations. these are deployed inside your EAR/lib folder on the other machine. the client-jar must only exist on your web machine class path.

BTW: If you use maven. have a look at an example maven structure on GitHub: https://github.com/StefanHeimberg/stackoverflow-1134894/. It is not a example for a "splitted" architecure, but i think it could be informativ. or simple ignore it :)