Problems with javabeans activex bridge!

Problems with javabeans activex bridge!

Post by mattt » Sat, 05 Jun 2004 00:07:34


I've run into a rather odd problem. get Methods seem to return values
from the wrong methods! For example, let's pretend my activex control
stores values about a person. getName would return their age, while
getAge might return null! Something is also going wrong with my method
that accepts input and returns a value (okay, it is a money conversion
program!)... it is returning null!

They are consistently returning the same, wrong values each time.

I have verified that all these methods work perfectly by running the
code in JBuilder with a Main class.

Any idea what to do?

(also, has anybody had any luck getting the activex bridge to work
with vb .NET, with or [hopefully] without vb6?)


Problems with javabeans activex bridge!

Post by richard_wa » Sat, 12 Jun 2004 01:49:55

The problem is more likely to be with the ActiveX side. It sounds like
a version problem between the version of the ActiveX component you are
actually running and the interface definition that was used to
generate the Java bridging components. ActiveX methods can be
referenced by number so if the interface looks like (VB-ish syntax):

public Function foo()
public Function getName() as String
public Function getAge() as Long

Then foo would be called as function number 0, getName as function
number 1, getAge as function number 2.

If the interface used to be simpler in the past, e.g. only 2 functions

public Function getName() as String
public Function getAge() as Long

Then getName() would be 0, getAge would be 1 and there would be no
function number 2. So this could explain the functionality that you're
seeing; java expects getName to be number 1, but it's really 0 so when
you call getName you actually end up calling getAge and when you call
getAge you actually call a nonexistent function; the null return is
probably hiding an exception that's being thrown somewhere in the
system (probably within the COM subsystem).

You need to recreate the intermediate pieces of the bridge; however
your bridging software does so; making sure that the ActiveX component
you point it at is up-to-date with the binary one you will call at
runtime (on all the machines you'll ever run on!).

If you're also writing the ActiveX component then you need to be aware
that changing the interface that component offers requires rebuilding
of all the clients as well as any intermediate bridging components
that you are using.


- Richard