|
While Java has been less then perfect as a client, it's certainly
hard to top when it comes to servers. In fact J2EE servers are fast
becoming a commodity which support EJBs largely in a plug-and-play
fashion.
Asta's origin includes technology which allows the developer to
quickly build thin fast rich clients capable of accessing a wide
variety of RDBMS servers residing on Windows and non-Windows platforms.
Asta servers support client applications running on Windows, Palm, and
Win CE.
As Asta continues to evolve, it is natural to introduce a technology
which allows a J2EE server to directly support a native Windows client.
As is depicted in the diagram below, JAsta extends the Asta
functionality to include an EJB client API. This new API calls JAsta
on the J2EE server which in turn calls the EJB.
The "magic" behind the scenes is a servlet which in turn calls a
proxy service. This service, the heart of JAsta, calls the EJB as
needed making certain stateless and stateful, local and remote, session
and entity EJB functionality is all available to the native Windows
applications. Of course all this happens "efficiently over the wire"
in a manner which has become synonymous with Asta.
Java Application Servers are the proven choice for Enterprise
Application Servers and Enterprise Java Beans are the accepted method
of coding Java Application Servers. Why not use Java where it belongs,
on the server, with small, fast Windows thin clients?
JAsta and JBoss
The JBoss configuration tested includes Tomcat. As of this writing
the current stable versions of the JBoss-Tomcat distribution is JBoss
2.4.4 and Tomcat 4.0.1 (Catalina). I suspect it's possible to use the
JBoss which does not include Tomcat (or Jetty) to get JAsta running
with JBoss (and it may even be easier for some) but I prefer the
combination distribution because it does work "as-is".
Theoretically JBoss itself offers effortless deployment of EJBs. I
have found this to be close to truth when it comes to practice.
 by Carl Mosca |
The best programmer I know and I used to debate about good theories
which cannot be put into practice. He always argued they are not
really good theories if they could not be put into practice. I still
won't admit I might have been wrong because I can't give up on the
semantics I think we were really debating.
|
Anyhow the jasta.war file is just about all it takes to get JAsta
going on JBoss. This file (jasta.war) should be copied into the deploy
directory like any other package/bean/war one might want to deploy.
Because the magic of JAsta starts with a call to a servlet and we are
using Tomcat, it's also important to put a copy of jndi.properties in
Tomcat's conf directory or in the CLASSPATH. On our test environment
this is the catalina/conf directory under the JBOSS_DIST directory.
From the top
Now that we've got the quick-and-dirty what's needed for your
average JBoss-aware developer, let's start at the beginning. By the
way I am working on a Win2000 machine.
What's needed?
- JBoss (the distribution with Tomcat) from jboss.org
- JDK 1.3+
Before you attempt to install JBoss you should have the JDK
installed and make certain your JAVA_HOME environment variable is set.
If you are just getting started with Java a visit to Sun's tutorials on
setting up a Java development environment (on any platform) will be
worth the trip. I am going to assume the JDK 1.3+ is installed and
usable.
To install JBoss, unzip the distribution archive into the directory
of choice.
 by Carl Mosca |
I used the default name which includes the version of
JBoss and Tomcat. If I were on my Linux box I'd create a symbolic link
to the directory but here in Win32 land I'll keep the ten-dollar
directory name and use environment variables when I am at the
command-line.
|
In my case I unzipped to D:\ and I ended up with my top level JBoss
directory being D:\JBoss-2.4.4_Tomcat-4.0.1 (which I have pointed to by
the JBOSS_DIST environment variable for convenience). So after you
unzip JBoss, I recommend adding a system environment variable called
JBOSS_DIST. This should point to the directory to which JBoss was
unzipped. Therefore if you change to %JBOSS_DIST% you should see two
directories called jboss and catalina.
In case you are not familiar with adding environment variables
here's a quick explanation. Go to your desktop and right-click the
"My Computer" icon. Select "Properties" and then go to the "Advanced"
tab. Click the "Environment Variables" button and then click the "New"
button under the list box which contains "System Variables". The
variable name in this case is "JBOSS_DIST" (without the double quotes).
The variable value in my case is "D:\ JBoss-2.4.4_Tomcat-4.0.1" (again
no quotes). After you click the "Ok" button the environment variable
will be saved. The *next* time you open a command prompt (I tend to
live with at least one open), it will have the new variable set.
Change to the jboss\bin directory and type "run_with_catalina".
Press enter and assuming the JDK and JBoss installation are OK,
JBoss will start. You will see a bunch of messages (which may be
reviewed in the server.log file found in the %JBOSS_DIST%\jboss\log
directory) and then finally the "JBoss started" message (or something
close to that) will appear. At some point you should review the log
just so you'll become familiar with it. If there are any startup or
deployment problems you will want to start there.
Now that we've see it run, let's terminate the server by pressing
Ctrl-C. After some more messages fill the screen and add to the log
file, the "Shutdown complete" message will appear. This is followed
by a "Terminate batch job (Y/N)?" prompt. Enter "Y" to terminate.
The JAsta demo comes with two files we need to copy to the JBoss
deployment directory in order to make the demo run. The first one is
jasta.war (JAsta itself) and the second one is JAstaEjbDemo.jar (the
demo EJB we are going to call from our Delphi app).
Copy these two files to the %JBOSS_DIST%\jboss\deploy directory.
Because tomcat needs the access to the EJB interface we are also
going to copy JAstaEjbDemo.jar to the tomcat/lib directory. In our
case this is the %JBOSS_DIST%\catalina\lib directory. Now that we have
JAsta and our demo EJB installed we can restart JBoss (actually JBoss
will deploy without restarting). Remember go to the %JBOSS_DIST%\bin
directory and type "run_with_catalina" to get JBoss started.
Now it's time to run our JAsta Delphi client. Go to the JAsta demo
directory and type "JAstaTestClient". You will see a windows
application that looks like this.
If you are running JAsta on the same machine and you have not
modified the port settings, click the "Setup Connection" button.
 by Carl Mosca |
If you are running the client and server on separate machines, enter
the address in the JBoss Server text box before clicking the "Setup
Connection" button.
|
Now click the "Access EJB Server" tab and then click the
"Create EJB" button.
You should see a message which says "Created EJB Handle" at this
point. If you go back to the shell (DOS box) in which JBoss is
running you will see some activity there are well. Again the messages
here are also recorded to the JBoss log.
Now go back to the demo application and click the "Credit/Debit
Amount" button. You will then see a message indicating the current
balance. Repeat the operation and you should see an additional
increase in the balance.
There you have it. An EJB running on JBoss and accessed from a
native Windows app via JAsta!
|