Visual Basic Accessing EJBs Hosted in SilverStream Application Server

Java/J2EE COM Interoperability Products Page
// This example demonstrates a Visual Basic client accessing an EJB hosted in the SilverStream app server
// Make sure you have the standard examples working prior to attempting to run this example.
// SilverStream will soon be providing a more detailed article, including instructions on how to have the
// bridge running inside the SilverStream Application Server itself.
// Download the J-Integra® kit from
// In order to run this example copy it to \SilverStream30\samples\Examples3_EJB\myprojects\ejbDemoStateTax
// The first three steps below can be performed on any OS, such as Solaris.
// 1. Go to \SilverStream30\samples\Examples3_EJB\myprojects\ejbDemoStateTax and run
//    'java2com': java com.linar.java2com.Main
//    Specify "com.examples.statesalestaxdemo.SBStateSalesTax" as the class to analyze, "salestax" as
//    the name for the generated IDL file, click on "Names..." and remove "java.lang.Class" as being a class
//    to ignore, and click on "Generate ..."
// 2. Compile the generated wrapper classes: javac IID*.java
// 3. Start the bridge, making sure that the J-Integra® runtime (jintegra.jar) and the current directory
//    are in your CLASSPATH: java  -DJINTEGRA_DCOM_PORT=3000 DCOMBridge
// 4. Register the jvm on the VB client using regjvmcmd ejb hostname[3000]
//    where hostname is 'localhost' if running this JVM on the same machine as the VB client
// 5. Compile the generated IDL file: midl salestax.idl
// 6. Copy the salestax.tlb to the VB client machine, and register it: regtlb salestax.tlb ejb
// 7. On the VB client create a new VB "Standard EXE", add a reference to the salestax type library
//    using "Project|References", on the form with two text boxes called "state" and "amount" and
//    a button.
// 8. Double-click on the button, delete the generated event handler, and enter the following code:
Dim calc As salestax.ComExamplesStatesalestaxdemoSBStateSalesTax

Private Sub Form_Load()
Dim home As Object
Set home = GetObject("ejb:RMI/sssw/Examples3_EJB/StateSalesTaxDemo/SBStateSalesTax")
Set calc = home.Create
End Sub

Private Sub Command1_Click()
amount.Text = calc.calculateTheTax(state.Text, amount.Text)
End Sub
// 9. Start the VB client, and enter "NY" as the state, and "100" as the amount, and click on the button.  Then
//    try entering ABCD as the amount ... cool, eh?

public class DCOMBridge {
  static com.sssw.rt.util.AgrServerSession session = null;

  public static void main(String[] args) throws Exception {
    com.sssw.rt.util.AgRuntime.init(new"D:\\SilverStream30"), null, null);
    session = com.sssw.rt.util.AgRuntime.connect("localhost");

    com.linar.jintegra.Jvm.register("ejb", new EjbInstanciator());

class EjbInstanciator implements com.linar.jintegra.Instanciator {
  javax.naming.Context ctx;

  EjbInstanciator() throws javax.naming.NamingException {
    ctx = new javax.naming.InitialContext();

  public Object instanciate(String javaClass) throws com.linar.jintegra.AutomationException {
    try {
      return ctx.lookup(javaClass); // // Look up the object
    } catch (javax.naming.NamingException e) {
      throw new com.linar.jintegra.AutomationException(e);