Getting Started with WebSphere Application Server
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Chapter 5 – Enterprise Java Beans 93<br />
car<br />
<br />
<br />
<br />
Listing 5.5 - Defining the configuration id of EJB testejb<br />
As shown in the above listing, this EJB is in group com.ibm.wasce.start <strong>with</strong> artifact as<br />
testejb. Its version number is 1.0 while its type is car. After deployed in Community<br />
Edition, the EJB will be placed in the following directory.<br />
/repository/com.ibm.wasce.start/testejb/1.0/testejb-1.0.car/<br />
5.2.2.2 Packaging the EJB<br />
Packaging the EJB means that you can bundle the EJB java class and deployment plan<br />
into a JAR package. You can do this by exporting the EJB project in Eclipse or just<br />
packaging the EJB resources <strong>with</strong> the jar script.<br />
5.2.2.3 Deploying the EJB<br />
To deploy the EJB jar package in Community Edition, use this command:<br />
/bin/deploy.[bat/sh] deploy –username system –password manager<br />
[jarfile]<br />
Note:<br />
In Community Edition, you don’t have to deploy EJBs <strong>with</strong> a deployment descriptor since<br />
your EJBs include annotations defined in the EJB 3.0 specification.<br />
5.3 Working <strong>with</strong> EJBs in Community Edition<br />
To make use of EJBs, a client must invoke the EJB interface methods. The client may be a<br />
servlet or an application client.<br />
5.3.1 Using EJBs in a servlet<br />
To make use of EJBs in a servlet you have to:<br />
1. Refer to the EJB in the Servlet<br />
2. Add the EJB to the dependency list of the servlet.<br />
5.3.1.1 Refer to the EJB in the servlet<br />
You can use the annotation @EJB to reference the EJB in a Java class. You can declare a<br />
class field referring to an EJB <strong>with</strong> this annotation in front of it. Listing 5.6 provides an<br />
example.