Access Enterprise Java Beans in JBoss 3.2.1 from .NET Using J-Integra® for .NET |
This example demonstrates how to access Enterprise Java Beans in JBoss 3.2.1 from .NET client. J-Integra® for .NET is a Java interoperability component that bridges Java/J2EE and Microsoft .NET. It provides bi-directional access of Java objects and .NET components.
Use this example as a guideline to show you how to access your Enterprise JavaBeans (EJB) from a .NET client, using J-Integra® for .NET. This example will be deployed on JBoss 3.2.1 Application Server.
The Steps to Follow will show you how to deploy J-Integra® for .NET as a Java Servlet in JBoss 3.2.1 to interpret the HTTP requests from a .NET client. Refer to the diagram below for an overview of the scenario:
A platform with Microsoft Visual Studio .NET 2003 (7.1.3088 or higher) installed, or at least the .NET Framework 1.0.3705 or higher. This will be known throughout the example as the .NET platform.
A platform with JBoss 3.2.1 and J-Integra® for .NET 1.5.1265 (or higher) installed. Note that JBoss 3.2.1 will also require a JDK installed and JAVA_HOME pointing to that installation directory, as it does not come with a Java runtime. Make sure that JBoss 3.2.1 is sucessfully running by executing the run script located in JBOSS_DIST\bin.
This platform will be known throughout the example as the Java platform.
An installation of J2EE SDK on the Java platform. Throughout this example, J2EE_HOME is the directory where it has been installed.
Verify that GenService is installed correctly on the .NET platform.
Perform this step on the Java platform.
You will need to configure J-Integra® for .NET to act as a Servlet. This is done through the Janetor tool.
Launch Janetor from the Start Menu.
java -jar $USER_INSTALL_DIR$\lib\janetor.jar
Go to File - Open and open janet.xml located in $USER_INSTALL_DIR$\examples\jboss_321_http\java_server.
Install your J-Integra® for .NET product license. See Installing the J-Integra® for .NET license for further information.
Select default under Local Objects. Here you see that the J-Integra® for .NET Servlet can be accessed with a URI that will be constructed from the configuration details shown. Any Java classes will also be accessed as the specified Assembly name from the .NET client. If required, change the details to point to the JBoss 3.2.1 host name/port number.
In the EJB Context tab you see the properties required to access EJB's (not shown). If required, change Provider URL to your JBoss 3.2.1 provider URL.
Do not exit Janetor yet as you'll need it for the next step.
Perform this step on the Java platform.
In this step, you will use Janetor to generate a WAR file. This WAR file will include the J-Integra® for .NET runtime acting as a Java Servlet along with the EJB proxies required to access the EJB.
Back in Janetor, go to File - Export web application archive.
The screenshot below shows the Export web application archive window. See the documentation for Janetor for a description of all the fields.
To generate the WAR file click OK.
Before you exit Janetor, save the configuration by going to File - Save.
Perform this step on the Java platform.
In this step, you will deploy both the EJB and the WAR file from Janetor on JBoss 3.2.1. The EJB represents a simple CD catalogue and is described in the Container Managed Persistence section of the JBoss online documentation.
Copy the EJB, cd.jar located in $USER_INSTALL_DIR$\examples\jboss_321_http\java_server to the JBoss 3.2.1 "auto-deploy" directory. If you've installed the JBoss 3.2.1 distribution listed above, the deploy directory would be JBOSS_DIST\server\default\deploy.
Copy the WAR file, cd.war located in $USER_INSTALL_DIR$\examples\jboss_321_http\java_server to the JBoss 3.2.1 "auto-deploy" directory. If you've installed the JBoss 3.2.1 distribution listed above, the deploy directory would be JBOSS_DIST\server\default\deploy.
Start JBoss 3.2.1 by executing the run script located in JBOSS_DIST\bin. Watch the output for any exceptions encountered. If there are none, you have successfully deployed the EJB and WAR file.
Perform this step on the Java platform.
In this step, you will use the GenNet tool to generate .NET proxies for the EJB, along with the JNDI Context required to instanciate the Home object.
Launch GenNet from the Start Menu.
Change directory to $USER_INSTALL_DIR$ and then enter:
java -jar lib\gennet.jar
The first screen of GenNet shows a list of machines that have GenService running (screenshot not shown). Select the appropriate one and click Next.
The next screen prompts for the components (JAR files or directories)
to be added to the CLASSPATH. Each of these components are required
in order for the Java runtime to resolve references to Java classes when
generating .NET proxies. You'll need to add the following components:
- $USER_INSTALL_DIR$\examples\jboss_321_http\java_server\cdclient.jar
- J2EE_HOME\lib\j2ee.jar
Move on to the next step by clicking Next.
The next screen prompts for the specific Java classes that will
have .NET proxies generated for them. Click on Browse...
to add the following classes (use the CTRL key to select
multiple classes):
- org.jboss.docs.cmp.cd.interfaces.CDCollection
- org.jboss.docs.cmp.cd.interfaces.CD
- com.intrinsyc.janet.JNDIContext
- org.jboss.docs.cmp.cd.interfaces.CDHome
- org.jboss.docs.cmp.cd.interfaces.CDCollectionHome
Click on the Filter button and choose not to generate any proxies for the referenced classes as shown below. This will eliminate the number of .NET proxies created.
Move on to the next step by clicking Next.
The next screen prompts you to specify the .NET Assembly name along with the output directory. It should be pointing to $USER_INSTALL_DIR$\examples\jboss_321_http\vbnet_client\bin\Debug.
You should see a message that the proxy generation was successful. Click Exit to exit GenNet.
Perform this step on the .NET platform.
In this final step, you will configure the .NET client using a configuration file, then compile and run it.
Along with .NET proxies, GenNet generates .NET configuration files to be used as templates - one for the HTTP channel and one for the TCP channel. As the .NET client will be using HTTP to connect to the EJB, we will modify remoting_http.config. You can find this in the same directory that the proxies were generated in.
Modify remoting_http.config to look like:
<configuration> <system.runtime.remoting> <application> <client url="http://localhost:8080/cd"> <activated type="com.intrinsyc.janet.JNDIContext, cd"/> </client> <channels> <channel ref="http"> <clientProviders> <formatter ref="binary"/> </clientProviders> </channel> </channels> </application> </system.runtime.remoting> </configuration> |
Notice that http://localhost:8080/cd matches what was entered under Local Objects in Janetor. Change accordingly if necessary.
Load VbCdClient.sln located in $USER_INSTALL_DIR$\examples\jboss_321_http\vbnet_client with Visual Studio .NET 2003. Press F5 to run, or simply run the executable in the bin\Debug directory.
You should see the CD Catalogue form. Add a new artist/title, press Add, and you should see a success message.
Enter a search string from the artist or title just added, press Search and you should see the added record returned in the listbox:
To delete all records from the CD catalogue, press Delete All.
© 2007 Intrinsyc Software International, Inc. All rights reserved. Legal |