Through the analysis of the sample program, the sample program in the self-sensation book is really unprincuring, mainly to deploy tools, in this year, how can J2EE bring a deployment tool with J2EE, A large pile of configuration is really irritating! Ha ha.
Said a lot, starting to enter the key topic, you listen to you.
I chose Eclipse, this free thing is not bad, I found a lot of advantages in me, but I am unfortunate, I haven't used JBuilder, I don't know if they are not the same.
Eclipse has a Lomboz plugin that contains all the configurations of all servers. You can configure Web Model, and EJB Model, I choose the JBoss server, because I heard that he is not worthless.
As for the jboss under Eclipse, it is very simple. As long as Google is searching 'Eclipse deployment', there are many, and Mr. Jiang Yan, Lenovo, wrote a configuration, but everyone don't look at his EJB deployment, it is really garbage. According to him, it is difficult for beginners to learn the first EJB!
Do you still come to see my helloworld!
Excerpt from http://www.objectlearn.com/support/docs/firstejb.jsp
In fact, I just help you translate it, huh, huh. Look at the original text can be on the upper website.
Ok, don't say nonsense. Start now. Yes, be sure to ensure that your Lomboz and Eclipse have been configured.
1. Create a new Lomboz J2EE Project called "MyfirstejbProject". Don't change any other places, Next.
2. Then you can enter this interface:
I saw it, plus a new modules in this EJB Modules called MyBeans.
Then select the Target Server option. That's it.
Choose our already configured JBoss.
3. Ok, now if you don't report an error. Just point finish!
4. The first EJB module has been completed, it can generate EJB and EJB HOME, but the implementation class developed needs yourself! How do you write an implementation class below?
5.
This pair can understand, but someone wants to ask, where is this thing come? Main interface, perfernece under the Window menu, point him! Haha, there is a full choice of Lomboz inside.
6.ok pull, follow the picture below to lose the name:
This time Finish will generate a TestSessionBean.java. This is the generated implementation class.
7. Then fill in this implementation class. How to fill it? Don't change source code, don't do it, do this:
then,
This will be added to the method, don't manually add the code, this will let your component interface can't find what you write!
Then change this method of this implementation:
Public string helloworld () {
Return "Hello from Lomboz!";
} // This knows what it means?
Up to now, even if we have made an EJB program, just miss the main interface, some things, but don't be afraid, Eclipse will give you automatic generation. Will it? Next, we need to do such steps:
a) Add this EJBBEAN just written to EJB .b) Generate a primary interface and component interface.
c) Deploy him to the server.
d) Write a client program to experiment with him.
Easy! Really Easy!
8. This is a) that step, add him into the EJB. It is the EJB established in EJB Modules.
9. Everyone, now everyone finds this interface with the fastest speed.
Then do this:
This action is the task of completing task B).
10. OK, now do C), is to deploy the EJB just written to the server, and follow the two pictures below.
Looking for a console to see if your deployment is unsuccessful, if it is successful. You can do d). If you are not successful, come again! If it is still unsuccessful. Looking for me.
11. Now we have to write a customer program to experiment him, it is excited!
Re-establish a Java project, so that the EJB function can be displayed.
The newly established project called this name MyejbClientProject, in fact, what is called.
Point next to next page When you want to put the myejbclientproject we just made in Project! Otherwise it is done.
Then find this item under the New menu, Create An EJB Test Client. Point.
12. This is configured. This is actually not used.
You can see this class after finish: TestClient.java.
Modify this method
Public void testbean () {
Try {
com.testing.session.testsssion
MyBean = gethome (). CREATE ();
// --------------------------------------
// this is the place you make your caver
System.out.println (MyBean.helloworld ());
} catch (remoteException E) {
E.PrintStackTrace ();
} catch (createException e) {
E.PrintStackTrace ();
} catch (namingexception e) {
E.PrintStackTrace ();
}
}
OK, Save and then run! ! ! ! success! ! !
OK, a simplest EJB is done. I can finally enter the third chapter!