After generating the COM4J code to wrap a COM object, via the tlbimp.jar, I was getting the following error when calling the createComObjectName method on the ClassFactory:
QueryInterface failed : Access is denied. : .\com4j.cpp:163 at com4j.ComThread.execute(ComThread.java:203) at com4j.Task.execute(Task.java:25) at com4j.COM4J.createInstance(COM4J.java:97) at example.ClassFactory.createComObjectName(ClassFactory.java:73)
The objects being called acts as a proxy to objects residing on another machine. The error is caused by running the COM code under a user account that was unable to access the COM object on the remote server. The COM application the object was part of used the current logged on user for authentication. When I switched to using the user account on the correct domain, the error disappeared.