User: kjenks
Date: 00/10/21 05:41:21
Modified: . jboss_win32_4.html jboss_win32_6.html
jboss_win32_1.html jboss_win32_2.html
jboss_win32_3.html jboss_win32_5.html
jboss_win32_7.html interestEJB.zip
Log:
Fixed Windows trail of "Getting Started" to reflect change in installation point
(C:\jboss) and some minor edits.
Revision Changes Path
1.3 +9 -9 jbossweb/jboss_win32_4.html
Index: jboss_win32_4.html
===================================================================
RCS file: /products/cvs/ejboss/jbossweb/jboss_win32_4.html,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- jboss_win32_4.html 2000/09/01 23:53:45 1.2
+++ jboss_win32_4.html 2000/10/21 12:41:20 1.3
@@ -39,19 +39,19 @@
<p>Note that the directory structure must be <i>exactly</i> like this, or it
won't work. Again a common mistake is to do a META_INF (underscore) instead of
META-INF, be careful with this one<br>
<br>
To deploy the Bean on the server, all
that's necessary is to copy the .jar file to the `deploy' directory on the server,
e.g.,</p>
- <pre>copy interest.jar "c:\Program Files\jboss2\deploy"</pre>
+ <pre>copy interest.jar c:\jboss\deploy</pre>
<p> You can do this as often as you like;
the server will detect that the file has changed and automatically re-deploy it.
During deployment you should see the following messages from the server:
- <pre>[Auto deploy] Auto deploy of file: c:\Program
Files\jboss2\deploy\interest.jar
-[Container factory] Deploying:file: c:\Program Files\jboss2\deploy\interest.jar
+ <pre>[Auto deploy] Auto deploy of file:/C:/jboss/deploy/interest.jar
+[Container factory] Undeploying:file:/C:/jboss/deploy/interest.jar
+[Container factory] Undeployed application: file:/C:/jboss/deploy/interest.jar
+[Container factory] Deploying:file:/C:/jboss/deploy/interest.jar
+[Verifier] Verifying file:/C:/jboss/tmp/deploy/tmpejbjar48317.jar
[Container factory] Deploying Interest
-[Container factory] Started: Interest
-[Container factory] Bound Interest to interest/Interest
-[Container factory] Deployed application:
-file: c:\Program Files\jboss2\deploy\interest.jar</pre>
+[Container factory] Deployed application: file:/C:/jboss/deploy/interest.jar</pre>
<p>If you see a message like this:
- <pre>[Container factory] Deploying:file:c:\Program
Files\jboss2\deploy\interest.jar
+ <pre>[Container factory] Deploying:file:c:\jboss\deploy\interest.jar
[Container factory] Deployed application:
-file:c:\Program Files\jboss2\deploy\interest.jar</pre>
+file:c:\jboss\deploy\interest.jar</pre>
<p>then no Beans have been deployed -- the server always reports the Beans
that it detects. This usually means that the deployment descriptor
<code>ejb-jar.xml</code> is badly structured, or missing, or in the wrong directory.
Note that the server doesn't need to have the CLASSPATH set with your classes it
is done automatically from the deploy directory.<br>
If everything has gone according to plan,
you should now have a Bean deployed on the server. We will now create a simple test
client that runs one of its methods, just to prove that it's working.</p>
<p> </p>
1.3 +4 -4 jbossweb/jboss_win32_6.html
Index: jboss_win32_6.html
===================================================================
RCS file: /products/cvs/ejboss/jbossweb/jboss_win32_6.html,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- jboss_win32_6.html 2000/09/01 23:53:45 1.2
+++ jboss_win32_6.html 2000/10/21 12:41:20 1.3
@@ -28,9 +28,9 @@
java.lang.ClassNotFoundException: com.web_tomorrow.interest.InterestHome]</pre>
<p> A `communication exception' is the
exception that represents any error that can't readily be ascribed to a definite
cause. If you get this message you need to pay attention to the CLASSPATH on the
client. Note that the server doesn't need a classpath setting since it works from the
deploy directory.<br>
If the client program is at the top of
the directory hierarchy, with the Bean classes below it, then we can run it like this:
- <pre>cd "\Program Files\jboss2\examples\interest"
+ <pre>cd \jboss\examples\interest
java -classpath %CLASSPATH%;..\..\lib\ext\ejb.jar;..\..\client\jboss-client.jar;.
InterestClient </pre>
- <p> Once again, this needs to go in a .bat
file or a Makefile; you won't want to type it more than once. Note the long CLASSPATH;
it needs to include the jBoss client classes and the EJB classes as well as the
standard classpath (if any).<br>
+ <p> Once again, this needs to go in a
<CODE>.bat file</CODE> or a Makefile; you won't want to type it more than once. Note
the long CLASSPATH; it needs to include the jBoss client classes and the EJB classes
as well as the standard classpath (if any).<br>
If all is well, the test client produces
the following output:
<table border="0" bgcolor="#ffff80" cellspacing="4">
<tr>
@@ -42,7 +42,7 @@
</td>
</tr>
</table>
- If it doesn't produce this output but you
see a "MalformedURLException" try installing jboss in another directory that
doesn't contain space in it's path (typically some installations on windows don't like
C:\Program Files (the space).<br>
+ If it doesn't produce this output but you
see a "MalformedURLException" try installing jBoss in a directory that
doesn't contain space in its path (typically some installations on Windows don't like
C:\Program Files (the space).<br>
Another common problem you can see here
is a "class not found exception" make sure you include all the jars.<br>
<br>
The Bean should produce an output on the
server as well; this is to show that the Bean has executed on the server, not the
client. Look for something like this in the server log:
@@ -56,7 +56,7 @@
Well, that's it. We covered coding, compiling and deploying the Bean, and
coding and running a simple test client. If you found this article useful, drop me a
line at <a href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a> ; if
there's enough response I may be persuaded to produce some more sophisticated
tutorials.
<p>Kevin Boone, June 2000 (original author)</p>
<p>Gregory Pierce, July 2000 (ported to Windows platforms)</p>
- <p>Ken Jenks, July 2000 (editing)</p>
+ <p>Ken Jenks, July and October 2000 (editing)</p>
<p>
<table align="CENTER" border="1" cellspacing="0" cellpadding="4">
<tr>
1.3 +19 -6 jbossweb/jboss_win32_1.html
Index: jboss_win32_1.html
===================================================================
RCS file: /products/cvs/ejboss/jbossweb/jboss_win32_1.html,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- jboss_win32_1.html 2000/09/01 23:53:45 1.2
+++ jboss_win32_1.html 2000/10/21 12:41:20 1.3
@@ -25,13 +25,22 @@
You will <i>need</i> the JDK binaries
directory in your PATH (this is essential: see below) not just for the user account
which is doing the installation, but also for the user account that will run the
server.<br>
If you are running the server on Windows
NT as Administrator, you should check that the JDK binaries are in the PATH even for
Administrator. (Administrator and ordinary users normally have different PATH
settings. <code>Start | Settings | Control Panel | System | Environment tab | Path
variable</code>. In the Value field, put <code>c:\jdk1.3\bin;</code> in front. Click
Set. Click OK.)</p>
<p>Now you can download, install and test the jBoss server. At the time of
writing the most recent version of jBoss is 2.0. You can get jBoss from <a
href="http://www.jboss.org/">www.jboss.org</a>.<br>
- jBoss is <a
href="http://jboss.org/jBoss2/install.htm">distributed using Install Anywhere</a>
which is a signed Java applet that works pretty well on Windows. By default Install
Anywhere will put jBoss in <a href="file:///c:/Program Files/jboss2"><code>c:\Program
Files\jboss2</code></a>. (This may not be a good place if you're using Windows 95
because of the space in the path name. Try <a
href="file:///c:/jboss"><code>c:\jboss</code></a> instead.)<br>
- On a Windows NT system, you will not need
Administrator priviledges. Although Install Anywhere may malfunction (you'll need to
use "Other Java-enabled Platforms" instead) jBoss will work perfectly well
if installed in a user directory and run as an ordinary user. I will assume in this
tutorial that you are installing in <code>c:\Program Files\jboss2</code>. If you
haven't, change the paths as appropriate.</p>
- <p>You could try running the server now. You can either run the program from
the menu like <code>Start | Programs | jboss2 | Server_jboss2</code> or change to the
<code>bin</code> directory (note the quotation marks) and run</p>
- <pre>cd "c:\Program Files\jboss2\bin"
+ jBoss is <a
href="http://jboss.org/binary.htm">distributed as a Zip file</a>. You should extract
jBoss into <a href="file:///c:/jboss"><code>c:\jboss</code></a>. (If you need to put
jBoss in another place, try to install it in a folder without a space in the name
because spaces cause problems when folder names are used in environment variables like
%CLASSPATH%. If you must install in a folder with a space, like <CODE>Program
Files</CODE>, try using the "short name" <CODE>Progra~1</CODE> in environment
variables.)<br>
+ <!-- Commented out for the day when InstallAnywhere reappears... -- KJ
jBoss is <a
href="http://jboss.org/binary.htm">distributed using Install Anywhere</a> which is a
signed Java applet that works pretty well on Windows. By default Install Anywhere will
put jBoss in <a href="file:///c:/jboss"><code>c:\jboss</code></a>. (If you need to put
jBoss in another place, try to install it in a folder without a space in the name
because spaces cause problems when folder names are used in environment variables like
%CLASSPATH%. If you must install in a folder with a space, like <CODE>Program
Files</CODE>, try using the "short name" <CODE>Progra~1</CODE> in environment
variables.)<br> -->
+ On a Windows NT system, you will not need
Administrator priviledges. <!-- Commented out... -- KJ Although Install Anywhere
may malfunction (you'll need to use "Other Java-enabled Platforms" instead)
--> jBoss itself will work perfectly well if installed in a user directory and run
as an ordinary user. I will assume in this tutorial that you are installing in
<code>c:\jboss</code>. If you haven't, change the paths as appropriate.</p>
+ <p>You could try running the server now. <!-- Again, commented out until
InstallAnywhere comes back. -- KJ You can either run the program from the menu like
<code>Start | Programs | jboss2 | Server_jboss2</code> or o --> Open a Command Prompt
(DOS window), change to the <code>\jboss\bin</code> directory and run</p>
+ <pre>cd c:\jboss\bin
java -jar run.jar</pre>
<p> The server should start without any
error messages or exceptions being thrown. It will produce about three pages of output
on startup.<br>
+
+ To deploy your beans, put them in
<CODE>C:\jboss\deploy\</CODE>. jBoss' AutoDeploy system will detect a new or revised
<CODE>.jar</CODE> file and automatically deploy your beans. If you still have the
jBoss window open, you'll see some messages scroll by as your bean deploys. (Note:
<CODE>C:\jboss\deploy\</CODE> must exist when you start jBoss or you'll need to
restart the server to activate the AutoDeploy mechanism.) <br>
+
+
+<!-- Commented out. There are no test beans in the BETA release. -- KJ
The jBoss distribution is supplied with
one test Bean, packaged as <code>bank.jar</code> in the `deploy' subdirectory, which
is where Beans are placed to deploy them. The effect of this is to deploy the `bank'
bean when the server starts up. This is fine the first time, as it tests that the SQL
server is working, but you can usefully move <code>bank.jar</code> out of the
<code>deploy</code> directory when you are sure that everything's OK, and the server
will start up more quickly.<br>
+-->
+
+
On Windows networks it can be useful to
share this 'deploy' directory so that others may simply drag and drop the .jar files
containing beans into the container for deployment.
<p>
<table border="1" cellspacing="0" cellpadding="5" bgcolor="#ffff80">
@@ -40,6 +49,10 @@
<th>Corrective Action</th>
</tr>
<tr valign="top">
+ <td>File not found</td>
+ <td>The file transfer process may have left UNIX linefeeds in
your RUN.BAT file. Open RUN.BAT with Wordpad, select all of the the text, copy, close
Wordpad, open RUN.BAT in Notepad, paste, save.</td>
+ </tr>
+ <tr valign="top">
<td>Bad command or file name</td>
<td>The JDK binaries aren't in the PATH. Check your PATH
environment variable. On Windows 95 and 98, you may need to edit
<code>C:\AUTOEXEC.BAT</code> and restart your computer.</td>
</tr>
@@ -52,10 +65,10 @@
<td>The JDK binaries aren't in the PATH. If you get this
message, the SQL server hasn't started, and there will be a whole heap of other errors
later. Check your PATH environment variable. On Windows 95 and 98, you may need to
edit <code>C:\AUTOEXEC.BAT</code> and restart your computer.</td>
</tr>
<tr valign="top">
- <td>Failed to load Main-Class manifest attribute from<br>
+ <td>Failed to load Main-Class manifest attribute from
run.jar</td>
<td>You're not in the right directory and Java can't find file
run.jar. Try this:
- <pre>cd "c:\Program Files\jboss2\bin"
+ <pre>cd c:\jboss\bin
java -jar run.jar</pre>
</td>
</tr>
1.3 +24 -25 jbossweb/jboss_win32_2.html
Index: jboss_win32_2.html
===================================================================
RCS file: /products/cvs/ejboss/jbossweb/jboss_win32_2.html,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- jboss_win32_2.html 2000/09/01 23:53:45 1.2
+++ jboss_win32_2.html 2000/10/21 12:41:20 1.3
@@ -32,15 +32,14 @@
interest
{java source and class files here}</pre>
<p> The commands in this tutorial are
specific to the jBoss installation path, so the complete structure will look like this:
- <pre>Program Files
- jboss2
- examples
- interest
- com
- web_tomorrow
- interest
- {java source and class files here}</pre>
- <p> Create an <code>examples</code> folder
under <code>c:\Program Files\jboss2\</code>, then create an <code>interest</code>
folder under <code>examples\</code>. Now change to <code>c:\Program
Files\jboss2\examples\interest</code> and unzip the archive
<code>interestEJB.tar.gz</code>. It will create this structure automatically.
+ <pre>jboss
+ examples
+ interest
+ com
+ web_tomorrow
+ interest
+ {java source and class files here}</pre>
+ <p> Create an <code>examples</code> folder
under <code>c:\jboss\</code>, then create an <code>interest</code> folder under
<code>examples\</code>. Now change to <code>c:\jboss\examples\interest</code> and
unzip the archive <code>interestEJB.tar.gz</code>. It will create this structure
automatically.
<p><font face="helvetica,arial" size="5">EJBs: review</font></p>
<p>As a reminder, and Enterprise JavaBean has a minimum of three classes.</p>
<ul>
@@ -49,7 +48,7 @@
<li>The home interface. This specifies how a new Bean is created,
managed and deleted. As a minimum it should specify at least one <code>create()</code>
method. There should be an <code>ejbCreate()</code> method in the Bean class for each
<code>create()</code> method in the home interface. In this example, the home
interface is <code>com.web_tomorrow.InterestHome</code>
</ul>
<p> Of course, a Bean can include other
classes, or even other packages, but the classes listed above are the minimum. The
classes must be packaged into a JAR archive with a directory structure that reflects
the hierarchy of packages. In the example, the classes are in the package
<code>com.web_tomorrow.interest</code>, so they need to be in the directory
- <pre>c:\Program Files\jboss2\examples\interest\com\web_tomorrow\interest\</pre>
+ <pre>c:\jboss\examples\interest\com\web_tomorrow\interest\</pre>
<p>You will also need a directory called <code>META-INF</code> to store the
deployment descriptor (always called <code>ejb-jar.xml</code>) and -- optionally --
another XML file to tell the server about name mappings. With jBoss, this file must be
called <code>jboss.xml</code>.<br>
So before writing the classes, we need a
directory structure like this:
<pre>com
@@ -159,28 +158,28 @@
}
/**
- Empty method body
- */
+ * Empty method body
+ */
public InterestBean() {}
/**
- Empty method body
- */
+ * Empty method body
+ */
public void ejbCreate() {}
/**
- Empty method body
- */
+ * Empty method body
+ */
public void ejbRemove() {}
/**
- Empty method body
- */
+ * Empty method body
+ */
public void ejbActivate() {}
/**
- Empty method body
- */
+ * Empty method body
+ */
public void ejbPassivate() {}
/**
- Empty method body
- */
+ * Empty method body
+ */
public void setSessionContext(SessionContext sc) {}
} </pre>
</td>
@@ -188,10 +187,10 @@
</table>
<hr>
Notice that most of the methods are empty; they have to exist because they're
specified by the SessionBean interface, but they don't need to do anything in this
case.<br>
- If you haven't already done so, you
should create these .java files in the directory
<code>.\com\web_tomorrow\interest</code> (or unpack the archive with them in). Then
you can compile them using the commands</p>
- <pre>cd "\Program Files\jboss2\examples\interest"
+ If you haven't already done so, you
should create these <CODE>.java</CODE> files in the directory
<code>\jboss\examples\interest\com\web_tomorrow\interest</code> (or unpack the archive
with them in). Then you can compile them using the commands</p>
+ <pre>cd \jboss\examples\interest
javac -classpath ..\..\lib\ext\ejb.jar com\web_tomorrow\interest\*.java</pre>
- <p>(Naturally, you should the correct path if you haven't installed jBoss in
<code>c:\Program Files\jboss2</code>.) This should create three class files:
<code>InterestBean.class</code>, <code>Interest.class</code>, and
<code>InterestHome.class</code>. If you have `make' on your system, and you have
unpacked the archive, you can build all the classes just be running <code>make</code>
in the same directory as the Makefile.<br>
+ <p>(Naturally, you should the correct path if you haven't installed jBoss in
<code>c:\jboss</code>.) This should create three class files:
<code>InterestBean.class</code>, <code>Interest.class</code>, and
<code>InterestHome.class</code>. If you have `make' on your system, and you have
unpacked the archive, you can build all the classes just be running <code>make</code>
in the same directory as the Makefile.<br>
With the classes compiled, it's time to
create the deployment descriptor.
<p>
<table align="CENTER" border="1" cellspacing="0" cellpadding="4">
1.3 +42 -36 jbossweb/jboss_win32_3.html
Index: jboss_win32_3.html
===================================================================
RCS file: /products/cvs/ejboss/jbossweb/jboss_win32_3.html,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- jboss_win32_3.html 2000/09/01 23:53:45 1.2
+++ jboss_win32_3.html 2000/10/21 12:41:20 1.3
@@ -26,27 +26,30 @@
</tr>
</table>
<p>Now it's time to create the deployment descriptor. As a reminder, this file
tells the EJB server which classes form the Bean, the home interface and the remote
interface. If there is more than one Bean in the package, it indicates also how the
Beans interact with one another. In this simple example, there is only one Bean so we
won't need to worry about that part.<br>
- Most commercial EJB servers are supplied
with graphical tools for constructing the deployment descriptor. jBoss does have an
XML editor, but it's just as easy to construct the deployment descriptor manually.
Here it is:</p>
- <p><b>ejb-jar.xml: deployment descriptor for the Interest Bean</b><br>
+ Most commercial EJB servers are supplied
with graphical tools for constructing the deployment descriptor. jBoss does have an
XML editor, which runs like this: <PRE> cd C:\jboss\bin
+ java -jar ejx.jar</PRE>
+Here is an example of the deployment descriptor it creates:</p>
+ <p><b><CODE>ejb-jar.xml</CODE>: deployment descriptor for the Interest
Bean</b><br>
<hr>
<table border="0" bgcolor="#80ff80" cellspacing="4">
<tr>
<td>
<pre><?xml version="1.0"
encoding="Cp1252"?>
- <ejb-jar>
- <description>jBoss test application</description>
- <display-name>Test</display-name>
- <enterprise-beans>
- <session>
- <ejb-name>Interest</ejb-name>
- <home>com.web_tomorrow.interest.InterestHome</home>
- <remote>com.web_tomorrow.interest.Interest</remote>
- <ejb-class>com.web_tomorrow.interest.InterestBean</ejb-class>
- <session-type>Stateless</session-type>
- <transaction-type>Bean</transaction-type>
- </session>
- </enterprise-beans>
- </ejb-jar></pre>
+
+<ejb-jar>
+ <description>jBoss test application </description>
+ <display-name>Test</display-name>
+ <enterprise-beans>
+ <session>
+ <ejb-name>Interest</ejb-name>
+ <home>com.web_tomorrow.interest.InterestHome</home>
+ <remote>com.web_tomorrow.interest.Interest</remote>
+ <ejb-class>com.web_tomorrow.interest.InterestBean</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Bean</transaction-type>
+ </session>
+ </enterprise-beans>
+</ejb-jar></pre>
</td>
</tr>
</table>
@@ -54,44 +57,47 @@
The deployment descriptor must be called <code>ejb-jar.xml</code> and it must
be in the directory <code>.\META-INF</code>. A common mistake is to name this
directory `META_INF' (with an underscore, rather than a dash), which won't work.<br>
In principle what we deploy on the server
is an application, not a Bean. In this example our application consists of exactly one
Bean, so it comes to the same thing. In the deployment descriptor, the section</p>
<pre><ejb-name>Interest</ejb-name></pre>
- <p>assigns a name to the Bean. jboss in its standard configuration will put
the bean's home interface under the ejb-name moniker if you don't specify anything
else. In other words, when your applications want to access the bean through it's
home jboss will put it in JNDI under the ejb-name. </p>
+ <p>assigns a name to the Bean. jBoss in its standard configuration will put
the bean's home interface under the ejb-name moniker if you don't specify anything
else. In other words, when your applications want to access the bean through its home
jBoss will put it in JNDI under the ejb-name. </p>
<p>In practice client applications are not forced to use this name. Typically
a developer will not bother with specifying a different name for the
JNDI namespace. However a production installation of a complete application
comprising many beans, will usually use a different name than the one specified by the
developer. Typically it could use `[application name]/[bean name]', which is what we
shall use later.<br>
</p>
- <p> Although the deployment descriptor
format of the ejb-jar.xml file is common to all EJB servers, and precisely defined in
a DTD you can get from SUN, it doesn't specify some advanced stuff. Specifically it
does not know how to map ejb-name to a deployment JNDI such as the one we just
talked about. It also doesn't know how to map resources. The server may also need to
be told how to manage persistence and state. There is, as yet, no standard way of
specifying these things, and every server implementation does it differently. </p>
- <p>The approach taken by jBoss is it provides a standard behaviour that works
mostly from the ejb-jar.xml file. There is no need for additional information in most
cases. In case of advanced configurations we define the jboss.xml file that gives all
the relevant information to the container, such as JNDI mapping names, persistence
information, database mapping and advanced container configuration (interceptors and
plugins), please refer to the chapter on jboss.xml for detailed information of what it
can do, we will cover simple things here. <br>
+ <p> Although the deployment descriptor
format of the <CODE>ejb-jar.xml</CODE> file is common to all EJB servers, and
precisely defined in a DTD you can get from SUN, it doesn't specify some advanced
stuff. Specifically it does not know how to map ejb-name to a deployment
JNDI such as the one we just talked about. It also doesn't know how to map
resources. The server may also need to be told how to manage persistence and state.
There is, as yet, no standard way of specifying these things, and every server
implementation does it differently. </p>
+ <p>The approach taken by jBoss is it provides a standard behaviour that works
mostly from the <CODE>ejb-jar.xml</CODE> file. There is no need for additional
information in most cases. In case of advanced configurations we define the
<CODE>jboss.xml</CODE> file that gives all the relevant information to the container,
such as JNDI mapping names, persistence information, database mapping and advanced
container configuration (interceptors and plugins), please refer to the chapter on
<CODE>jboss.xml</CODE> for detailed information of what it can do. <br>
</p>
- <p>The standard behaviour of jboss is capable of working from ejb-jar.xml in
95% of cases and needs jboss.xml only if you need to specify specific deployment
information. </p>
- <p>An additional feature of the new metadata is that it works
"differentially". In clear what this means is that if you wish to override
the name of a bean you need to only specify that part of xml tags in the jboss.xml
file.</p>
+ <p>The standard behavior of jBoss is capable of working from
<CODE>ejb-jar.xml</CODE> in 95% of cases and needs <CODE>jboss.xml</CODE> only if you
need to specify specific deployment information. </p>
+ <p>An additional feature of the new metadata is that it works
"differentially." This means that if you wish to override the name of a
bean you need to only specify that part of XML tags in the <CODE>jboss.xml</CODE>
file.</p>
<p></p>
- <p><b>Using the ejb-name from ejb-jar.xml</b></p>
- <p>for most development purposes, as soon as you provide a ejb-jar.xml with
the beans the container will get the ejb-name as the JNDI name as standard
behaviour. This makes your development life easier.</p>
- <p>If you don't provide a jboss.xml file you will find your bean under the
name "Interest".</p>
- <p><b>Overriding ejb-name with a real JNDI name in jboss.xml</b></p>
- <p>If in deployment you would rather use the "myApp/myBean" naming
pattern you need to provide the following text in jboss.xml. </p>
- <p><b>jboss.xml: (Optional, this bit provided by the Bean deployer)</b><br>
+ <p><b>Using the ejb-name from <CODE>ejb-jar.xml</CODE></b></p>
+ <p>For most development purposes, as soon as you provide a
<CODE>ejb-jar.xml</CODE> with the beans the container will get the ejb-name as the
JNDI name as standard behaviour. This makes your development life
easier.</p>
+ <p>If you don't provide a <CODE>jboss.xml</CODE> file you will find your bean
under the name "Interest".</p>
+ <p><b>Overriding ejb-name with a real JNDI name in
<CODE>jboss.xml</CODE></b></p>
+ <p>If in deployment you would rather use the "myApp/myBean" naming
pattern you need to provide the following text in <CODE>jboss.xml</CODE>. </p>
+ <p><b><CODE>jboss.xml</CODE>: (Optional, this bit provided by the Bean
deployer)</b><br>
<hr>
<table border="0" bgcolor="#80ff80" cellspacing="4">
<tr>
<td>
<pre><jboss>
+ <secure>false</secure>
+ <container-configurations />
+ <resource-managers />
<enterprise-beans>
- <session>
- <ejb-name>Interest</ejb-name>
- <jndi-name>interest/Interest</jndi-name>
- </session>
- <secure>false</secure>
- </enterprise-beans></pre>
+ <session>
+ <ejb-name>Interest</ejb-name>
+ <jndi-name>interest/Interest</jndi-name>
+ <configuration-name></configuration-name>
+ </session>
+ </enterprise-beans>
+</jboss></pre>
</td>
</tr>
</table>
<hr>
</p>
- <p>All this file says is that the Bean called <code>Interest</code> is
assigned the JNDI name of <code>interest/Interest</code>.</p>
- <p>The indentation is just there for formatting and readability, it is non
important.
+ <p>All this file says is that the Bean called <code>Interest</code> is
assigned the JNDI name of <code>interest/Interest</code>. (The indentation is just
there for formatting and readability.)
<hr>
</p>
<p><br>
- So now we've got the deployment
descriptor <code>ejb-jar.xml</code>. Again jboss will happily run just from that file
and bind the object under "Interest" as standard JNDI name. We also
have the optional jboss.xml to provide another name "interest/Interest" to
overwrite the standard behaviour with JNDI. We also have the classes. It's time to
package them together.</p>
+ So now we've got the deployment
descriptor <code>ejb-jar.xml</code>. Again jBoss will happily run just from that file
and bind the object under "Interest" as standard JNDI name. We also
have the optional <CODE>jboss.xml</CODE> to provide another name
"interest/Interest" to overwrite the standard behaviour with JNDI. We also
have the classes. It's time to package them together.</p>
<p>
<table align="CENTER" border="1" cellspacing="0" cellpadding="4">
<tr>
1.3 +1 -1 jbossweb/jboss_win32_5.html
Index: jboss_win32_5.html
===================================================================
RCS file: /products/cvs/ejboss/jbossweb/jboss_win32_5.html,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- jboss_win32_5.html 2000/09/01 23:53:45 1.2
+++ jboss_win32_5.html 2000/10/21 12:41:20 1.3
@@ -139,7 +139,7 @@
</tr>
</table>
You will also need to pay attention to the CLASSPATH when compiling. Even
though the EJB classes will <i>run</i> on the server, they need to be identified to
the client so that the compiler can do the appropriate type checking. In the example
program I have put the client at the top level of the directory hierachy, so if the
CLASSPATH includes the current directory it will correctly find the EJB classes which
are in the directories beneath it.</p>
- <pre>cd "\Program Files\jboss2\examples\interest"
+ <pre>cd \jboss\examples\interest
javac -classpath ..\..\lib\ext\ejb.jar;. InterestClient.java</pre>
<p>This generates <code>InterestClient.class</code>.</p>
<p>
1.2 +111 -66 jbossweb/jboss_win32_7.html
Index: jboss_win32_7.html
===================================================================
RCS file: /products/cvs/ejboss/jbossweb/jboss_win32_7.html,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- jboss_win32_7.html 2000/08/29 23:12:36 1.1
+++ jboss_win32_7.html 2000/10/21 12:41:20 1.2
@@ -42,12 +42,13 @@
Now navigate over to
<CODE>C:\Jakarta\jakarta-tomcat</CODE> and double-click on <CODE>build.bat</CODE>.<br>
- Then open a command prompt (DOS shell) and
enter these commands:
+ Then open a Command Prompt (DOS shell) and
enter these commands:
<PRE>cd \Jakarta\jakarta-tomcat
build.bat dist
</PRE>
-(Leave that command prompt open -- we'll need it again later.)<br>
+(Leave that Command Prompt open -- we'll need it again later.)<br>
+<!-- Commented out. jBoss no longer uses port 8080. -- KJ
Edit file
<CODE>\Jakarta\dist\tomcat\conf\server.xml</CODE>. Change the port from 8080 to
<B>9090</B> (so we don't interfere with jBoss' Web server on port 8080). (Note that
future builds of jBoss won't use 8080, so this will not be an issue for long.)
<TABLE BORDER=0 BGCOLOR="#C0C0FF" CELLSPACING=4><TR><TD><PRE>
<Connector
@@ -58,23 +59,27 @@
</Connector>
</PRE></TD></TR></TABLE>
+-->
+
+
+
Edit
<CODE>\Jakarta\dist\tomcat\bin\tomcat.bat</CODE> and add these lines in the CLASSPATH
section:
<TABLE BORDER=0 BGCOLOR="#C0C0FF" CELLSPACING=4><TR><TD><PRE>
-set CLASSPATH=%CLASSPATH%;\progra~1\jboss2\client\jboss-client.jar
-set CLASSPATH=%CLASSPATH%;\progra~1\jboss2\client\jnp-client.jar
-set CLASSPATH=%CLASSPATH%;\progra~1\jboss2\lib\ext\ejb.jar
-set CLASSPATH=%CLASSPATH%;\progra~1\jboss2\examples\interest\interest-client.jar
+set CLASSPATH=%CLASSPATH%;c:\jboss\client\jboss-client.jar
+set CLASSPATH=%CLASSPATH%;c:\jboss\client\jnp-client.jar
+set CLASSPATH=%CLASSPATH%;c:\jboss\lib\ext\ejb.jar
+set CLASSPATH=%CLASSPATH%;c:\jboss\examples\interest\interest-client.jar
</PRE></TD></TR></TABLE>
Test your Tomcat installation by running Tomcat then using a Web browser to access
it. To run Tomcat, explore to <CODE>C:\Jakarta\dist\tomcat\bin\</CODE> and
double-click on <CODE>startup.bat</CODE>.<br>
- Now use a Web browser to open <CODE><A
TARGET="_new" HREF="http://localhost:9090/">http://localhost:9090/</A></CODE> (or use
your actual domain name or IP address instead of localhost). You should see the
default Tomcat home page. Click on Servlet Examples then click on Execute next to
Hello World. This should run the HelloWorldExample servlet in
<CODE>\Jakarta\dist\tomcat\webapps\examples.war</CODE>. If that doesn't work, you need
to re-check your Tomcat installation.<br>
+ Now use a Web browser to open <CODE><A
TARGET="_new" HREF="http://localhost:8080/">http://localhost:8080/</A></CODE> (or use
your actual domain name or IP address instead of localhost). You should see the
default Tomcat home page. Click on Servlet Examples then click on Execute next to
Hello World. This should run the HelloWorldExample servlet in
<CODE>\Jakarta\dist\tomcat\webapps\examples.war</CODE>. If that doesn't work, you need
to re-check your Tomcat installation.<br>
To stop Tomcat, explore to
<CODE>C:\Jakarta\dist\tomcat\bin\</CODE> and double-click on
<CODE>shutdown.bat</CODE>. It that doesn't work, you can ALT-TAB to the window and hit
CTRL-C or do whatever you usually do to kill a misbehaving program.<br>
- You may have noticed that the last .jar file
listed above doesn't exist yet. Assuming you put your example code from step 5 into
-<code>C:\Program Files\jboss2\examples\interest\</code> here's how to create that
jar file:
+ You may have noticed that
<CODE>c:\jboss\examples\interest\interest-client.jar</CODE> doesn't exist yet.
Assuming you put your example code from step 5 into
+<code>C:\jboss\examples\interest\</code> here's how to create that jar file:
<PRE>
-cd "C:\Program Files\jboss2\examples\interest\"
+cd C:\jboss\examples\interest\
jar cf interest-client.jar com
</PRE>
@@ -85,6 +90,17 @@
<p> <b>EJB.java: servlet interface to the `interest' EJB</b> <br>
<hr>
<TABLE BORDER=0 BGCOLOR="#80FF80" CELLSPACING=4><TR><TD><PRE>
+/**
+ * This simple servlet tests the `Interest' Enterprise JavaBean which is
+ * implemented in the package `com.web_tomorrow.interest'. For this to
+ * work, the Bean must be deployed on an EJB server.
+ * <P>
+ * <B>IMPORTANT</B> If you want to test this in a real client-server
+ * configuration, this class goes on the client. The URL of the naming
+ * provider specifed in the class must be changed from `localhost:1099'
+ * to the URL of the naming service on the server.
+ */
+
import java.io.*;
// Servlet stuff
@@ -100,13 +116,44 @@
/**
* This Servlet provides a user interface to an Enterprise Java Bean.
* The example EJB described in the jBoss documentation at
- * <http://jboss.org/> calculates compound interest. This servlet
- * is based on Hello.java, distributed with Apache JServ.
+ * http://jboss.org/ calculates compound interest.
* This servlet will call the Interest EJB, passing it a few
* parameters. The EJB will return a result, which the servlet
* will display to the Web client.
*/
public class EJB extends HttpServlet {
+
+ private Interest m_interest = null;
+
+ /**
+ * Sets up the naming provider, gets a context, gets a reference to
+ * the bean's Home interface, and creates an Interest object from
+ * the home interface, all to save time in doGet.
+ */
+ public void init() {
+ try {
+ // Set up the naming provider. This may not always be necessary,
+ // depending on how your Java system is configured.
+ System.setProperty("java.naming.factory.initial",
+ "org.jnp.interfaces.NamingContextFactory");
+ System.setProperty("java.naming.provider.url",
+ "localhost:1099");
+ // Get a naming context
+ InitialContext jndiContext = new InitialContext();
+
+ // Get a reference to the Interest Bean
+ Object ref = jndiContext.lookup("interest/Interest");
+
+ // Get a reference from this to the Bean's Home interface
+ InterestHome home = (InterestHome)
+ PortableRemoteObject.narrow (ref, InterestHome.class);
+
+ // Create an Interest object from the Home interface
+ m_interest = home.create();
+ } catch(Exception e) {
+ }
+ }
+
/**
* Handle the GET and HEAD methods by building a simple web page.
* HEAD is just like GET, except that the server returns only the
@@ -117,67 +164,65 @@
throws ServletException, IOException {
PrintWriter out;
- String title = "Servlet interface to EJB";
+ String title = "Servlet interface to EJB";
// set content type and other response header fields first
- response.setContentType("text/html");
+ response.setContentType("text/html");
// then write the data of the response
out = response.getWriter();
- out.println("<HTML><HEAD><TITLE>");
+ out.println("<HTML><HEAD><TITLE>");
out.println(title);
- out.println("</TITLE></HEAD><BODY bgcolor=\"#FFFFFF\">");
- out.println("<H1>" + title + "</H1>");
- out.println("<H2>Calling EJB...</H2>");
-
- /**
- This simple servlet tests the `Interest' Enterprise JavaBean which is
- implemented in the package `com.web_tomorrow.interest'. For this to
- work, the Bean must be deployed on an EJB server.
- <P>
- <B>IMPORTANT</B> If you want to test this in a real client-server
- configuration, this class goes on the client; the URL of the naming
- provider specifed in the class must be changed from `localhost:1099'
- to the URL of the naming service on the server
- */
-
- // Set up the naming provider; this may not always be necessary, depending
- // on how your Java system is configured.
- System.setProperty("java.naming.factory.initial",
- "org.jnp.interfaces.NamingContextFactory");
- System.setProperty("java.naming.provider.url",
- "localhost:1099");
-
- // Enclosing the whole process in a single `try' block is not an ideal way
- // to do exception handling, but I don't want to clutter the program up
- // with catch blocks
+ out.println("</TITLE></HEAD><BODY
bgcolor=\"#FFFFFF\">");
+ out.println("<H1>" + title + "</H1>");
+
+/* DEBUG JNDI
+ out.println("<H2>Listing the context...</H2>");
+
try {
- // Get a naming context
- InitialContext jndiContext = new InitialContext();
- out.println("Got context");
-
- // Get a reference to the Interest Bean
- Object ref = jndiContext.lookup("interest/Interest");
- out.println("Got reference");
-
- // Get a reference from this to the Bean's Home interface
- InterestHome home = (InterestHome)
- PortableRemoteObject.narrow (ref, InterestHome.class);
-
- // Create an Interest object from the Home interface
- Interest interest = home.create();
+ out.println("<UL>");
+ // Create the initial context
+ Context ctx = new InitialContext();
+
+ // Get listing of context
+ NamingEnumeration list = ctx.list("");
+
+ // Go through each item in list
+ while (list.hasMore()) {
+ NameClassPair nc = (NameClassPair)list.next();
+ out.println("<LI>" + nc.getName() + ": " +
nc.getClassName());
+ }
+
+ // Close the context when we're done
+ ctx.close();
+ } catch (NamingException e) {
+ out.println("<LI>List failed: " + e);
+ } finally {
+ out.println("</UL>");
+ }
+
+ // Done listing the context
+DEBUG JNDI */
+
+ out.println("<H2>Calling EJB...</H2>");
- // call the calculateCompoundInterest() method to do the calculation
- out.println ("Interest on 1000 units, at 10% per period, " +
- "compounded over 2 periods is:");
- out.println (interest.calculateCompoundInterest (1000, 0.10, 2));
+ try {
+ if (m_interest == null) {
+ out.println ("Could not connect to Interest bean. Is EJB Container
running?");
+ } else {
+
+ // call the calculateCompoundInterest() method to do the calculation
+ out.println ("Interest on 1000 units, at 10% per period, " +
+ "compounded over 2 periods is:");
+ out.println (m_interest.calculateCompoundInterest (1000, 0.10, 2));
+ }
} catch(Exception e) {
out.println(e.toString());
+ } finally {
+ out.println("</BODY></HTML>");
+ out.close();
}
-
- out.println("</BODY></HTML>");
- out.close();
}
}
</PRE></TD></TR></TABLE>
@@ -186,8 +231,8 @@
<PRE>
cd C:\Jakarta\dist\tomcat\webapps\examples\WEB-INF\classes
set JKCP=C:\Jakarta\dist\tomcat\lib\servlet.jar
-set JKCP=%JKCP%;\progra~1\jboss2\lib\ext\ejb.jar
-set JKCP=%JKCP%;\progra~1\jboss2\examples\interest
+set JKCP=%JKCP%;c:\jboss\lib\ext\ejb.jar
+set JKCP=%JKCP%;c:\jboss\examples\interest
javac -classpath %JKCP% EJB.java
</PRE>
This will compile and deploy the
@@ -200,7 +245,7 @@
Now you should be able to use your Web browser
to open the servlet which connects to the EJB running under jBoss:
<UL>
-<LI><A TARGET="_new"
HREF="http://localhost:9090/examples/EJB">http://localhost:9090/examples/EJB</A>
+<LI><A TARGET="_new"
HREF="http://localhost:8080/examples/servlet/EJB">http://localhost:8080/examples/servlet/EJB</A>
</UL>
If all is well, the test client produces
@@ -219,7 +264,7 @@
</BODY></HTML>
</pre>
</TD></TR></TABLE>
- If it doesn't produce this output but you see
a "MalformedURLException" try installing jBoss in another directory that doesn't
contain space in it's path (typically some installations on Windows don't like
<code>C:\Program Files</code> (the space). Another common problem you can see here is
a "class not found exception." Make sure you include all the jars.
+ If it doesn't produce this output but you see
a "MalformedURLException" try installing jBoss in another directory that doesn't
contain space in its path. Some installations on Windows don't like <code>C:\Program
Files</code> (the space). Another common problem you can see here is a "class not
found exception." Make sure you include all the jars.
<br>
Again, the Bean should produce an output on
the server as well; this is to show that
the Bean has executed on the server, not the client. Look for something like this
@@ -229,7 +274,7 @@
[Interest] Someone called `calculateCompoundInterest!'
</pre>
</TD></TR></TABLE>
-<p> Ken Jenks, July 2000
+<p> Ken Jenks, October 2000
<p>
<TABLE ALIGN="CENTER" BORDER=1 CELLSPACING=0 CELLPADDING=4>
<tr>
1.3 +145 -144 jbossweb/interestEJB.zip
<<Binary file>>