This topic takes you step by step through creating a session bean, deploying it to WebLogic Server 5.1.0 and creating a client for it.
Copy EJB-related files from WebSphere\AppServer\hosts\default_host\WSsamples_app\servlets\WebSphereSamples into a directory structure according to the package statements (e.g. %TG_HOME%\samples\java\ejb\WebSphere\HelloEJB\com\ibm\ejb\cb\samples\hello\tier2), so the example is resided close to our delivered ejb samples:
Hello.java
HelloBean.java
HelloBeanResourceBundle.java
HelloHome.java
Start Together and create new project in %TG_HOME%\samples\java\ejb\WebSphere\HelloEJB\com\ibm\ejb\cb\samples\hello\tier2
Together automatically recognizes the structure of parent
directories, so that upper folders correspond to the package
statements. This helps avoid errors.
Click on the Bean implementation class, go to
SessionEJB and look at the properties
Together recognizes fully qualified names of the classes, interfaces etc.
Go to Properties | SessionEJB | Properties of the HelloBean and set "JNDI name to bind to" to HelloHome (it was not recognized by Together since stored in XML file rather than in sources. )
Ok, we're now ready to take off!
Uncomment weblogic.httpd.register.servlets=weblogic.servlet.ServletServlet string in %WL_HOME%\weblogic.properties. This string allows to run unregistered servlets from the servlet classpath.
Start WLS Server (manually from the Start menu, or using our starter plug-in).
Start deployment to WLS5.1. All checkboxes, except for Create Database Table for CM EJB should be on.
Specify correct paths / host / password / whatever required by the Expert and click Finish.
In XMLEditor for ejb-jar.xml go to ejb-jar/enterprise-beans/session/Description (*) and observe that description for the HelloBean was retrieved directly from the sources, without any user's intervention! Check that EJBName is short "HelloBean". Click Ok to continue.
In XMLEditor for weblogic-ejb-jar.xml go to weblogic-ejb-jar/weblogic-enterprise-bean/ejb-name and make sure it is "HelloBean"; the associated JNDI name in weblogic-ejb-jar/weblogic-enterprise-bean/jndi-name is "HelloHome". This name is taken from the properties, which were specified in step 3. Click Ok to continue.
After a while you'll see a message in Together's Message pane:
WLS51: Finished with 0 Errors, 0 Warnings
WLS console shows something like:
Fri Aug 25 12:06:44 GMT+02:00 2000:
EJB home interface: 'com.ibm.ejb.cb.samples.hello.tier2.HelloHome' deployed bound to the JNDI name: 'HelloHome'
Ok, deployment is now complete. Let's make ourselves busy with the client.
Copy client-related files into the proper directory structure (for example, %TG_HOME%\samples\java\ejb\WebSphere\HelloEJB\WebSphereSamples\HelloEJB).
Go to the Project Properties and add second source root path %TG_HOME%\samples\java\ejb\WebSphere\HelloEJB\WebSphereSamples\HelloEJB. Though our EJB and client files reside in different folders, it is very easy to access the sources since source paths of our project point to the very end of hierarchy!
Build the project (actually one don't need to compile everything, but client and put "togetherEJB.jar" or "DEPLOYED_togetherEJB.jar" to the project classpath. Unfortunately, the step is not automated in b1013, therefore, easy to call "Build the project")
Go to the output directory and copy compiled client classes (%OUT_DIR%\WebSphereSamples\HelloEJB\*.class) to the server's servletclasses folder (%WL_HOME%\myserver\servletclasses\WebSphereSamples\HelloEJB).
Open http://localhost:7001/servlets/WebSphereSamples/HelloEJB/HelloEJBServlet in your browser and observe "Hello from Hello EJB Sample!"