HELP: Using Java OLE Server Objects from Delphi

Hello,

I want to do just that: I have Visual J++ from MS. It comes with an example
on how to write a JAVA Ole Server that can be called from Visual Basic
(Yes, I know this is swearing in the Church, but bear with me: I feel the
same: But it DOES work ...)

I baed my example on the example from the Book: Delphi 2 Unleashed: I have
enclosed some of my modified example here.

In particular, look at procedure TForm1.GetClass,  and my comments before
the definition.

************** Start Code Example ***************
............
unit main;

itnerface

uses SysUtils, Windows, Messages, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Ole2, OleAuto, Menus,  ExtCtrls;

type

// Also trie this :
// IFooObject = class(IDispatch)  

IFooObject = class(IDispatch)
  //dummy: array[1..1000] of longInt ;
  public
    function GCD(u: LongInt; v: LongInt): LongInt; virtual; {stdcall}
pascal; abstract;
  end;

var
  Form1: TForm1;

implementation

const

  // This is actually the CEuclid JAVA Class Registered
  CLSID_MyDllObject: TGUID = (
    D1:$33B0ECE2;D2:$E706;D3:$11cf;D4:($A0,$C2,$00,$AA,$00,$A7,$1D,$D8));

//
// This procedure Gets hold of the Server, AND the CoGetClassObject
actually SUCCEEDS !
// BUT the CreateInstance returns a NIL Pointer in P.
// Maybe P should be a Subclass of some other Class (than IUknown) ??
// The ERROR MESSAGE I get from the OleCheck(hr) method is : "Not enough
stoage is available to complete this operation"
//

procedure TForm1.GetClass(CLSID: TGUID; ClassContext: DWord);
var
  hr: HResult;
  ClassFactory: IClassFactory;
  P: IFooObject;
begin
  hr := CoGetClassObject(CLSID, ClassContext, nil,
                         IID_IClassFactory, ClassFactory);
  OleCheck(hr);
  hr := ClassFactory.CreateInstance(nil, {IID_IUnknown} CLSID_MyDllObject
{CLSID_IGCD}, P);

  if Succeeded(hr) then
    MessageOut('Object Exists')
  else begin
    MessageOut(GetOleError(hr));
    Exit;
  end;

  if IsEqualIID(CLSID, CLSID_MyDllObject) then begin
    ShowMessage((P.ClassName));         // Since IMarshal is not
implemented
    ShowMessage(IntToStr(P.GCD(12, 3))); // do this thing for inprocess
objs only
  end;

  OleCheck(ClassFactory.Release);
  OleCheck(P.Release);
end;

............

************** End Code Example ***************

DOES ANYONE KNOW HOW TO DO THIS ??

PLEASE E-MAIL ME DIRECT WITH YOUR FEEDBACK (AS WELL AS POSTING IT)

Thanks in advance...