Accessing Java from ASP in Native Mode

Java/J2EE COM Interoperability Products Page

This example demonstrates how to access the Java from ASP in Native Mode. J-Integra® for COM is a Java interoperability component that bridges Java and ASPs. It provides bi-directional access of Java objects and COM components.

Summary

This example shows how to access a simple Java class from ASP using J-Integra® in native mode.

Introduction

In this example you will modify the Accessing a Simple Java Class from Active Server Pages to take advantage of J-Integra®'s native mode, which loads the JVM either out-process or in-process into the ASP environment. Just like DCOM mode, you can access all public fields and methods (including static ones) in Java objects, without modifying the Java classes:

When using native mode with ASP, the JVM must be installed on the same machine as the ASP server. You can find more information about J-Integra®'s native mode in the Introduction to J-Integra® Native Mode.

Prerequisites

Run the Accessing a Simple Java Class from Active Server Pages example, as this example reuses the code demonstrated there.

Content

  1. Native Mode Out-process
  2. Native Mode In-process
  3. Troubleshooting

1. Native Mode Out-process

Change the JVM registration to use Native Mode

You are going to change the registration of the JVM on the ASP machine so that rather than being accessed via DCOM, it is accessed via native code out-process.

  1. First, un-register the existing definition (which uses DCOM mode) using the regjvmcmd command in the d:\jintegra\bin directory:

    > regjvmcmd /unregister aspjvm

  2. Next, re-register it in native mode out-process:

    > regjvmcmd /native aspjvm

  3. Alternatively you can run the regjvm.exe GUI tool to register the JVM:


  4. Run the DCOMBridge program in native mode:

    > set PATH=%PATH%;C:\jintegra\bin

    > set CLASSPATH=%CLASSPATH%;.;C:\jintegra\lib\jintegra.jar

    > javac DCOMBridgeJvm.java

    > java -DJINTEGRA_NATIVE_MODE DCOMBridgeJvm

Restart your ASP server

Restart your IIS:

When you access the ASP page you should see the Values output as follows:

 

2. Native Mode In-process

Change the JVM registration to use Native Mode

You are going to change the registration of the JVM on the ASP machine so that rather than being accessed via DCOM, it is accessed via native code in-process.

  1. First, un-register the existing definition (which uses DCOM mode) using the regjvmcmd command in the d:\jintegra\bin directory:

    > regjvmcmd /unregister aspjvm

  2. Next, re-register it in native mode in-process:

    > regjvmcmd /native /inproc aspjvm
    D:\jintegra\lib\jintegra.jar;d:\jintegra\lib;d:\pure
    D:\jdk1.3.1\jre\bin\classic\jvm.dll DCOMBridgeJvm

  3. Alternatively you can run the regjvm.exe GUI tool to register the JVM:


  4. When using native mode in-process you do not need to run the DCOMBridge program.

  5. Update your CLASSPATH at the System Variable level (Settings -> Control Panel -> System -> Advanced -> Environment Variables... -> System variables) to include the CLASSPATH of the Java class and jar files. Do NOT update it from User variables or command line.

  6. Update your PATH at the System Variable level (Settings -> Control Panel -> System -> Advanced -> Environment Variables... -> System variables) to include the J-Integra® bin directory. Do NOT update it from User variables or command line.

Restart your ASP server

Restart your IIS:

When you access the ASP page you should see the Values output as follows:

3. Troubleshooting

First check that the JVM is registered correctly. Ensure that the JVM DLL is correct, and that the CLASSPATH is correct. Use the 'regjvmcmd /list' command to see how it is registered.

If it still does not work, uncomment the Log.logImmediately(...) line in the DCOMBridgeJvm.java file, and change the log file to use an absolute file name ("c:\\temp\\jintegra.log"). Restart IIS/ASP and re-run the example, and see if the log file is created and if there are any obvious errors being reported.

If it still does not work, enable logging inside the J-Integra® moniker, by creating a registry value (a string) called logFile with the value c:\temp\jintmk.log under the HKEY_LOCAL_MACHINE\SOFTWARE\Linar\JintMkr key.

Here is a screen capture showing what it should look like. Again restart IIS/ASP and try to access the ASP page and then look to see if a log has been created. Look through it for obvious errors.

If it still does not work, contact us including the jintegra.log (if it exists) generated by the J-Integra® runtime, the jintmk.log generated by the J-Integra® Moniker, and the checkconfig.log generated by doing checkconfig config.log.

Once you do have it working, please disable the logging by commenting the Log.logImmediately() line, and deleting the logFile registry entry.