This Question is Possibly Answered

1 "correct" answer available (4 pts) 2 "helpful" answers available (2 pts)
11 Replies Last post: Jul 28, 2008 2:49 PM by Vadim Ridosh  
Frank Senn   8 posts since
Jul 11, 2008
Currently Being Moderated

Jul 22, 2008 12:02 PM

Custom COM types

Hello,

 

 

 

it's not clear to me how to create custom COM types in a java COM server app.

 

 

 

 

 

I need to have a COM Server that works as a Protocol translator between to systems.

 

 

 

 

One is a VB6 application. Then I want to have custom objects, which I can send to VB6 app.

 

 

 

 

I'd tried this:

 

 

 

 

public OlaCOMAgent(CoClassMetaInfo coClassMetaInfo) {

 

 

 

super(coClassMetaInfo);

IClassFactoryServer classFactoryServer  = new IClassFactoryServer(OlaCOMAgent.class);

classFactoryServer.registerInterface(IDispatch.class, new IDispatchVTBL(classFactoryServer));

classFactoryServer.registerInterface(IOlaCOMAgent.class, new IDispatchVTBL(classFactoryServer));

classFactoryServer.registerInterface(IWorkcycle.class, new IDispatchVTBL(classFactoryServer));

}

 

OlaCOMAgent implements IOlaCOMAgent

 

 

 

Then I have a custom interface IWorkcycle. But I get this error when calling the COM server:

 

 

 

16:05:16,015 INFO  IClassFactoryServer The ola.IOlaCOMAgent interface was not registered for ola.OlaCOMAgent, because ola.server.IOlaCOMAgentVTBL class was not found. 16:05:16,125 INFO  IClassFactoryServer The ola.IOlaCOMAgent interface was not registered for ola.OlaCOMAgent, because ola.server.IOlaCOMAgentVTBL class was not found. 16:05:16,140 ERROR IClassFactoryServer java.lang.NoSuchFieldException: INTERFACE_IDENTIFIER at java.lang.Class.getDeclaredField(Unknown Source) at com.jniwrapper.win32.com.server.IClassFactoryServer.b(SourceFile:262) at com.jniwrapper.win32.com.server.IClassFactoryServer.registerInterface(SourceFile:177) at ola.OlaCOMAgent.<init>(OlaCOMAgent.java:46)

 

 

 

Do I have to create a VTBL class?  Can I have custom interfaces and send them to clients?

 

 

 

Thanks in advanced,

 

 

 

Frank Senn

Vladimir Ikryanov TeamDev Ltd. 404 posts since
Apr 24, 2006
Currently Being Moderated
3. Jul 22, 2008 6:01 PM in response to: Frank Senn
Re: Custom COM types

Hello Frank,

 

Please try to use the following code:

 


public class OlaCOMAgent extends IDispatchServer implements IOlaCOMAgent, IWorkcycle
{
    public OlaCOMAgent(CoClassMetaInfo classImpl)
    {
        super(classImpl);
    }
    
    public void registerInterfaces()
    {
        IClassFactoryServer server = new IClassFactoryServer(OlaCOMAgent.class);

        server.registerInterface(IDispatch.class, new IDispatchVTBL(server));
        server.registerInterface(IOlaCOMAgent.class, new IOlaCOMAgentVTBL(server));
        server.registerInterface(IWorkcycle.class, new IWorkcycleVTBL(server));
    }
}

 

Also please note that you should provide appropriate VTBL class for each your custom interface. If you have TLB or DLL with compiled interfaces description then you can use our ComfyJ Code Generator to create required VTBL classes (IWorkcycleVTBL and IOlaCOMAgentVTBL).

 

Regards,

Vladimir Ikryanov

Vladimir Ikryanov TeamDev Ltd. 404 posts since
Apr 24, 2006
Currently Being Moderated
5. Jul 23, 2008 10:55 AM in response to: Frank Senn
Re: Custom COM types

Hi Frank,

 

Actually creating TLB files is not the responsibility of ComfyJ. It just parse TLB files to provide Java proxies and stubs.

 

Way to obtain right TLB files depends on how your custom COM interfaces were created:

 

1. In case COM interfaces are provided by third-party library, TLB (it can also be named OLB) is always provided by library creator. This file can be provided standalone, or can be attached (as a Windows resource) to Dll file.

2. In case COM interfaces are written on your side, they are usually created as an IDL files. In this case, they can be compiled into TLB file by Microsoft's midl compiler.

 

In both cases, you can use Dll, TLB or OLB as an input file to ComfyJ's Code Generator to create right VTBL classes.

 

Regards,

Vladimir Ikryanov

Vladimir Ikryanov TeamDev Ltd. 404 posts since
Apr 24, 2006
Currently Being Moderated
7. Jul 23, 2008 6:53 PM in response to: Frank Senn
Re: Custom COM types

Hello Frank,

 

Could you please send us the DLL you have made? We will try to find out the reason of why VTBL classes are not generated with CodegenForComfyJ.

 

Regards,

Vladimir Ikryanov

Vladimir Ikryanov TeamDev Ltd. 404 posts since
Apr 24, 2006
Currently Being Moderated
9. Jul 24, 2008 10:53 AM in response to: Frank Senn
Re: Custom COM types

Hi Frank,

 

Thank you for letting us know.

 

Please contact us if you have any other questions. We will be happy to help you regards using our products.

 

Regards,

Vladimir Ikryanov

Vadim Ridosh TeamDev Ltd. 74 posts since
Jul 23, 2008
Currently Being Moderated
11. Jul 28, 2008 2:49 PM in response to: Frank Senn
Re: Custom COM types

 

Hello Frank,

 

 

When you pass pointer to your COM object to another COM method, you should pass it as IUnknownImpl-derived object (in your case, this should be IDispatchImpl object). Try to pass "handler" variable instead of "to".

 

 

If this won't help (it's possible if your VB6 method expects exactly _TestOrder interface instead of IDispatch), you can obtain ITestOrderImpl interface through the following line: to.queryInterface(IID.create(TestOrder.INTERFACE_IDENTIFIER), resultingTestOrder);

 

 

Regards,

Vadim Ridosh

 

 

More Like This

  • Retrieving data ...