Make it Return a Client Jar

Once it starts, the server is going to do a ton of things to get your bean ready. One of them is to generate the class files that implement your two interfaces (the home and the component interfaces). And since they’re remote interfaces, the server will also create the remote stub classes for those interfaces. (Lots more on these later.) Well, the client needs the two interfaces and the two stubs. You could have given the client the interfaces, since you created those. But only the server can make the stub classes, and the client will never work without them. So your client application might be sitting there, all nice and compiled, and just waiting for you to give it the stub classes so that it can actually run.

Fortunately, you can ask the RI deploytool to give you a client jar that has everything the client needs (and a lot more, it turns out, but since this isn’t a real production environment, we’re just going to let that go).

Virtually all EJB application servers must create the stub classes, so you’ll have to find out where your server puts them, so you can give them to the client.

Select the Return Client Jar checkbox (put it in the projects/advice directory)

Click Next >

image with no caption

Get Head First EJB now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.