Access Enterprise Java Beans in Borland Enterprise Server 5.2.1 from .NET Using J-Integra® for .NET

Java/J2EE .NET Interoperability Products Page

This example demonstrates how to access Enterprise Java Beans in Borland Enterprise Server 5.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.

Synopsis

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 Borland Enterprise Server 5.2.1.

The Steps to Follow will show you how to deploy J-Integra® for .NET as a Java Servlet in BES 5.2.1 to interpret the HTTP requests from a .NET client. Refer to the diagram below for an overview of the scenario:

Access Enterprise Java Beans in Borland Enterprise Server 5.2.1 from .NET Using J-Integra® for .NET

Note: $USER_INSTALL_DIR$ is the directory where J-Integra® for .NET has been installed. If this location contains whitespace characters (e.g. C:\Program Files\...), you may need to include it within "" when referencing it at the command-line. BES_HOME is the directory where BES 5.2.1 has been installed.

Prerequisites

  1. 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.

  2. A platform with BES 5.2.1 and J-Integra® for .NET 1.5.1265 (or higher) installed. This will be known throughout the example as the Java platform.

  3. A version of JDK installed on the Java platform, and the bin directory included in the path. This required for the jar utility.

  4. Verify that GenService is installed correctly on the .NET platform.

Steps to Follow

  1. Run Janetor to Configure J-Integra® for .NET

  2. Generate a Web Application aRchive (WAR file)

  3. Deploy the EJB and WAR file on BES 5.2.1

  4. Run GenNet and Compile the Proxies

  5. Compile and Run the .NET Client

Run Janetor to Configure J-Integra® for .NET

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.

  1. Windows

    Launch Janetor from the Windows Start Menu.

    Command-Line
    java -jar $USER_INSTALL_DIR$\lib\janetor.jar
    	
  2. Select File - Open and open janet.xml located in $USER_INSTALL_DIR$\examples\bes_521_http\java_server.

  3. Install your J-Integra® for .NET product license. See Installing the J-Integra® for .NET license for further information.

  4. 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 BES 5.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 BES 5.2.1 provider URL.

    Using Janetor Configuration Tool setup Local Objects

    Do not exit Janetor yet as you'll need it for the next step.

Generate a Web Application Archive (WAR file)

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.

You will then need to update the WAR file with the Borland deployment descriptor file.

  1. Back in Janetor, go to File - Export web application archive.

  2. The screenshot below shows the Export web application archive window. See the documentation for Janetor for a description of all the fields. Change Output file as necessary.

    Using Janetor generate WAR file with Java Proxy

  3. Before clicking OK to generate the WAR file, notice that there is an EJB reference. This is a reference to the EJB example. Clicking Edit shows the details:

    Using Janetor Configuration Tool add  EJB reference

    To generate the WAR file click OK.

  4. Before you exit Janetor, save the configuration by going to File - Save.

  5. You will now need to modify the WAR file to include the Borland specific web application deployment descriptor. At the command-line, change directory to $USER_INSTALL_DIR$\examples\bes_521_http\java_server and enter:

    jar uvf hellojanetweb.war WEB-INF\web-borland.xml
    	

    This will update the WAR file with the Borland specific deployment descriptor.

Deploy the EJB and WAR file on BES 5.2.1

Perform this step on the Java platform.

In this step, you will deploy both the EJB and the WAR file from Janetor on BES 5.2.1 by creating an Enterprise Application aRchive (EAR file). The EJB represents a simple "Hello World" example, and is included with this example.

  1. At the command-line, change directory to $USER_INSTALL_DIR$\examples\bes_521_http\java_server and enter:

    jar cvf janetexample.ear hellojanetejb.jar hellojanetweb.war META-INF
    	

    This will create the EAR file, janetexample.ear which can be now deployed in BES 5.2.1.

  2. Start BES 5.2.1 and launch the Management Console. Deploy the resulting EAR file (accept all defaults). Once deployed, the Management Console should show something similar:

    Deploying the EAR file in BES 5.2.1

Run GenNet and Compile the Proxies

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.

Note: GenNet saves configuration details to an XML file. For your convenience, the settings described below have already been saved to the file gennet.xml in the directory $USER_INSTALL_DIR$\examples\bes_521_http\java_server. If you'd prefer not to manually enter the settings as instructed below, simply copy this file over to $USER_INSTALL_DIR$ before starting GenNet.
  1. Windows

    Launch GenNet from the Start Menu.

    Command-Line

    Change directory to $USER_INSTALL_DIR$ and then enter:

    java -jar lib\gennet.jar
    	
  2. The first screen of GenNet shows a list of machines that have GenService running (screenshot not shown). Select the appropriate one and click Next.

  3. 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\bes_521_http\java_server\hellojanetejb.jar
    - BES_HOME\lib\asrt.jar

    Using GenNet generate .NET Assemblies for Java Objects

    Move on to the next step by clicking Next.

  4. 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):

    - com.intrinsyc.janet.JNDIContext
    - com.intrinsyc.hello.HelloJanetHome
    - com.intrinsyc.hello.HelloJanet

    Using GenNet adding Java classes to be exported to .NET

    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.

    Using GenNet filter referenced Java Classes

    Move on to the next step by clicking Next.

  5. The next screen prompts you to specify the .NET Assembly name along with the output directory. The screenshot may show a different output directory than what Output Directory is, but it should be pointing to $USER_INSTALL_DIR$\examples\bes_521_http\vbnet_client\bin\Debug.

    Setting .Net Assembly and proxy's output directory

  6. You should see a message that the proxy generation was successful. Click Exit to exit GenNet.

    GenNet generates .NET Proxy successfully

Compile and Run the .NET Client

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.

Note: In the .NET code, notice that a call is made to RemotingConfiguration.Configure("remoting_http.config");
  1. Modify remoting_http.config to look like:

    <configuration>
       <system.runtime.remoting>
         <application>
           <client url="http://localhost:8080/janetexample">
             <activated type="com.intrinsyc.janet.JNDIContext, JanetExample"/>
           </client>
           <channels>
             <channel ref="http">
               <clientProviders>
                 <formatter ref="binary"/>
               </clientProviders>
             </channel>
           </channels>
         </application>
       </system.runtime.remoting>
    </configuration>
    	

    Notice that http://localhost:8080/janetexample matches what was entered under Local Objects in Janetor. Change accordingly if necessary.

  2. Load vbnet_client.sln located in $USER_INSTALL_DIR$\examples\bes_521_http\vbnet_client and press F5 to run, or simply run the executable in the bin\Debug directory.

    Note: If you happen to have an older version of Visual Studio .NET, it is still possible to compile the code, but you will not be able to open the solution file. See build.bat in $USER_INSTALL_DIR$\examples\bes_521_http\vbnet_client.
  3. You should see the Hello World! form:

    VB client window

  4. Enter a name and click on Submit. A message box displays the results:

    VB client accessing EJB successfully

© 2005 Intrinsyc Software Inc. Legal