EJB/J2EE Frequently Asked Questions (FAQ)17-654: Analysis of Software
Artifacts |
Created 1/26/04
Updated
Author Mike
Merideth (mgm @ cs.cmu.edu)
Version 1.1
Strong words of caution: If you have never programmed in Java before,
werecommend that you consider using CORBA rather than EJB to make your
learningcurve easier. See the CORBA
FAQ(can be accessed via Blackboard).
You should choose an
application server and then try atutorial targeted for that server; I suggest JBossand the O’ReillyJBoss
Workbook. See morecomplete answers
later in this FAQ.
This is a personal
choice and depends on your level ofexperience with the products.
That said, I have
been experimenting with the two (JBoss andJ2EE), and, for new users, I am going
to have to recommend JBoss, as it wouldappear to be used in production
environments more frequently and has a moreactive user base. It is also
easier to install on the game/asl labmachines. The J2EE reference
implementation is not intended forproduction use (and, based on anecdotal
evidence, seems to put a larger load onthe machines). The more recent versions
of JBoss also have Eclipse integrationthrough JBoss-IDE.
The JBoss binaries (and source) are available for free download at http://www.jboss.org/downloads.
There is a summary
of free and open source tools for EJB here.
First, do we have an
installed J2EE application server? Yesand no.
We have JBoss installed at/afs/ece/class/ece846/java/jboss-3.2.3. Thegeneral problem is that each team that
decides to use this installation ofJBoss will need its own deployment/server
directory created in a location thatis not writeable by the class.
We have also cached
a copy of the 3.2.3 binary distribution (/afs/ece/class/ece846/java/jboss-3.2.3.tgz).
Installing this is as simple extracting this archive to your
localdirectory. See either the O’ReillyJBoss
Workbook or GettingStarted
with JBoss for more information.
In summary, JBoss is
very easy to install, so, you have twooptions: (1) you can install JBoss in
your own directory, or (2) if you contactMike Merideth, he will set up a server
instance in the ece846 JBoss
installation for youthat points to one of your own directories. If you choose option (2) you will still be
able to start,stop, and configure your own instance directories, but you will
not have fullcontrol of the JBoss distribution. However, option (2) will save
you approximately 50M of disk space (andmay ease some aspects of
administration).
After some experimentation, wehave decided not to support a common
installation of the J2EE referenceimplementation application server. However,
you can download it for linux, windows, or solaris from http://java.sun.com/j2ee/1.4/download.html#sdk. If the linux version fails to installbecause
it thinks that your JRE is invalid, see http://forum.java.sun.com/thread.jsp?forum=136&thread=468069&message=2190181and
then set your LD_LIBRARY_PATH to include the extracted package directory.
We will be covering
this in the J2EE recitation, in which wewill borrow material from the O’ReillyJBoss
Workbook. This link
showscommands and output that I captured while working through example 4.1. You
canalso look at the following:
O’Reilly Tutorials
http://www.oreilly.com/catalog/entjbeans3/workbooks/index.html
JBoss.org Quick
StartGuides
Getting Started with
JBoss (3.2.x servers)
http://jboss.org/docs/jbossj2ee.pdf
Others:
Jumping Into JBoss
http://www.developer.com/java/ejb/article.php/3071661
Thread discussing
running the J2EE examples on JBoss
http://www.jboss.org/index.html?module=bb&op=viewtopic&t=19436
The J2EE 1.4
Tutorial(Chaper 18) (June 2003)
About This Tutorial
-> About the Examples -> Buildingand Running the Examples (Gives
important information on configuring yourenvironment)
http://java.sun.com/j2ee/1.4/docs/tutorial/doc/
Developing
This tutorial
updates and expands the tutorial "WritingEnterprise Applications for the
Java 2 Enterprise Edition (J2EE) ReferenceImplementation" originally
written by Monica Pawlan in June 2000. Thetutorial provides an introduction to
the Java 2 Enterprise Edition (J2EE)Platform.
http://java.sun.com/developer/onlineTraining/J2EE/Intro2/j2ee.html
Writing
This tutorial
introduces you to the APIs, tools, andservices provided in the Java 2
Enterprise Edition (J2EE) ReferenceImplementation.
http://java.sun.com/developer/onlineTraining/J2EE/Intro/
http://java.sun.com/developer/onlineTraining/EJBIntro/
Learn how to write a
simple session Bean using theEnterprise JavaBeans component model.
http://java.sun.com/developer/onlineTraining/Beans/EJBTutorial/index.html
Java tutorials
http://java.sun.com/developer/onlineTraining/index.html
TheServerSide.com
http://www.theserverside.com/articles/index.jsp
We highly recommend
that you stick to using JDK 1.4.2 onLinux for your software development. If you
need Linux machines to run your software on, please contact theinstructor.
Yes. Eclipseintegration has been added recently.
See JBoss-IDE.
You should use the
BindingService. Read the following
instructions, or click here
for more information.
Preliminaries: My JBOSS_HOME variable is set to /afs/ece.cmu.edu/class/ece846/java/jboss-3.2.3/
There is a file
called ${JBOSS_HOME}/docs/examples/binding-manager/sample-bindings.xml. This
file specifies a number of jboss port configurations
such as ports-default, ports-01, and ports-02. Please note, however, that the number of port
configurations is less than the number of groups in the class using the
installed version of jboss. Therefore, you should create your own
configuration, following the conventions (increment the second digit of each
port number in the configuration, i.e., ports-default
specifies port 8080 for the web server, ports-01
specifies 8180, and ports-02
specifies 8280). You must update the
value of each of the ports in the configuration, not just port 8080.
To use a port
configuration from sample-bindings.xml, you must make a few modifications to the file
${JBOSS_HOME}/server/<your-server>/conf/jboss-service.xml.
Find the section of the file that looks like the XML code below. Note that <!-- is an open comment character in XML, and --> is the close comment
character. Therefore, notice that this
section is currently entirely commented out.
Instead, you want only the textual description to be commented out. Once the XML code is uncommented, you should
specify the port configuration that you want to use. By default, once this code is uncommented,
the system will use the ports-01
configuration. Instead, choose the port
configuration that you want from your modified sample-bindings.xml file.
<!--
| Binding service manager for port/host
mapping. This is a sample
| config
that demonstrates a JBoss instances with a server name 'jboss1'
| loading its bindings from an XML file
using the ServicesStoreFactory
| implementation
returned by the XMLServicesStoreFactory.
|
| ServerName:
The unique name assigned to a JBoss server instance for
| lookup
purposes. This allows a single ServicesStore to
handle mulitiple
| JBoss servers.
|
| StoreURL: The
URL string passed to org.jboss.services.binding.ServicesStore
| during
initialization that specifies how to connect to the bindings store.
| StoreFactory:
The org.jboss.services.binding.ServicesStoreFactory
interface
| implementation
to create to obtain the ServicesStore instance.
<mbean
code="org.jboss.services.binding.ServiceBindingManager"
name="jboss.system:service=ServiceBindingManager">
<attribute name="ServerName">ports-01</attribute>
<attribute
name="StoreURL">../docs/examples/binding-manager/sample-bindings.xml</attribute>
<attribute name="StoreFactoryClassName">
org.jboss.services.binding.XMLServicesStoreFactory
</attribute>
</mbean>
-->
It is used to define
the abstract schema for an entity bean.
Intuitively, for our
purposes, XDoclet allows you to workwith a single file (the EJB implementation)
and manage the creation of otherrequired EJB files via JavaDoc comments.
GettingStarted with JBoss states
that EJB XDoclet tags can be used to generate
EJB andvendor (JBoss, WebLogic, WebSphere, Orion) specific
deploymentdescriptors
Home andRemote Interface
PrimaryKey Class for Entity Beans
BulkData Object (also know as Value Object)
EJBWrapper classes
Theexamples in the O’Reilly workbook use a jndi.propertiesfile for each example
which specifies theserver location. The
classpath tothe jndi.properties file
is set in the ant script to include thisproperties file.
More information
(from Getting Started with JBoss):
In J2EE we have two types of clients; the
web clientis a
composition of servlets and JSPs, and other
clientsrunning outside
of the application server. The separation is
importantbecause web
clients can take advantage of running inside
theapplication server
like accessing the local (java:) namespace
of the JNDIserver or
using local interfaces on EJBs.
According to http://java.sun.com/developer/onlineTraining/EJBIntro/EJBIntro.html#EJBContainer,an
EJB can access its container in one of three ways:
·
Callbackmethods
·
EJBContext
·
JNDIENC