First for starting up you need the netbeans, jdk and the sun app server installed and configured. Sun app server must be added to the list of servers in Netbeans. This can be done through the "Tools-> Server Manager" in the Netbeans menu.
After Configuring all those stuff, please try out the following procedure for creating the EJB's.
1)First select "new project" from the file menu in netbeans.
2)Within the "Choose project" Dialog Box, Select Enterprise under Categories and "Enterprise Application" under Projects and click on Next button.
3)In the "Name and Location" DialogBox, Enter the name of the Project and select the Location. Make sure that "create EJB module" and "create Web Application Module" checkboxes are selected.
4)Netbeans automatically creates the Project files. Then right click in the "Source Packages" within the "-ejb" part and select "New-> Session Bean".
5)In the "Name and Location" Dialog box that follows, enter the EJB name and the package name. Select Session type as Stateless. Select only Remote within the "Create interface" option.
6)It can be seen that the Bean's Bean and Remote classes are automatically generated.
7)Then edit the Remote Interface class to include the declaration of the function that you want.
8)In the corresponding bean class, implement the corresponding method declared in the Remote Interface.
9)Then right click on "Source Packages" within the "-war" part and select "New-> servlet".
10)In the Name and Location Dialog Box that follows, Enter the name of the servlet and the package for the servlet and click on "Next".
11)Enter the Servlet name and URL Pattern in the "Configure Servlet Deployment" Dialog box and click on finish.
12)Then right click within the code area of the generated servlet class file and select "Enterprise resources->Call Enterprise Bean".
13)Then a Dialog box comes up with the list of all the ejb's open in the current project. In that, select the Bean you created and click on ok.
14)It can be seen that netbeans automatically adds the following line to the servlet code.
private Remote ;
15)Now add the following line to the processRequest function after the PrintWriter creation line.
16)Now save all the codes and right click on the project and select "Build Project". NetBeans builds and links the project.
17)Then right click on the project and select "Run Project". Netbeans runs the project and creates the browser page on completion.
18)Add the "/" to the address tab and press enter. It can be seen that the EJB function is called and the output is displayed in the servlet.
I used Netbeans 5.5 and sun server 9 for doing this project. jdk1.6 is required for installing and running Netbeans 5.5. Please make sure to have the neccessary software installed before trying out.