The following tutorial should explain how to build your own JEE Web/EJB Project in Eclipse. I use Glassfish Tools Bundle for Eclipase 1.1, which contain glassfish applicatin server and eclipase 3.4 IDE.
Finally our project consits of three modules.
- EJB module with the workflow components and also webservices
- Web module which contains the business logic of our business process. Things like forms and search pages
- EAR module which fits all together an represents the deployment unit which we will provide to our system integrator.
Start your Eclipse Workbench:
Build the EJB Module :
start using the first Eclipse JEE Wizard -> create EJB module
then enter your project name and check on the "EAR member", click next
from next wizard page, choose if to create a EJB client JAR module and click finish.
Now your Workspace structure should look like this:
ejb-jar.xml
The ejb-jar.xml deployment descriptor is used to provide unique names of the workflow ejb components. As the ejbs in JEE 5 use annotations to declare there behaviour there is no need for an ejb deployment descriptor. But when you plan to develop more then one application the names of the EJB need to be unique.
sun-ejb-jar.xml
The sun-ejb-jar.xml descriptor is the glassfish specific descriptor.
Build the Web Module
Now we can create our web project were we put in all our application logic. Start again the Eclipse New-Project-Wizard and select "Web->dynamic web module
click finish, you will get:
Notice that the web project is already added to as a EAR module.
now, you can develop your EJB module and WEB module. After you finish your coding, you can deploy them. It is very simple to do this, just right click the MyFistAppEar project and choose "run on server":
then you can directly choose "finish" on following wizard page:
the myFirstAppEAR will be automatically deployed to glassfish application server.
Hope from console window, you can see following message that prove your deployment is done correctly.
deploy:
[exec] Command deploy executed successfully.
deploy-url-message:
[echo] Application Deployed at: http://localhost:8082/myFirstAppEAR
Let us go to glassfish admin console to see what happen on the application server:
and you will see glassfish admin web page:
-->input username admin and password "adminadmin"
-->choose the "Enterprise Application" in the left menu bar
you will see that myFirstAppEAR is in the list on the right window like following:
click the "myFirstAppEAR", you can see more detail, like EJB module and WEB module in it.