Home : AutomationException: 0x80040154 - Class Not Registered
Q30926 - ERRMSG: AutomationException: 0x80040154 - Class Not Registered

AutomationException: 0x80040154 - Class Not Registered

 

After successfully generating and compiling the proxies and the client code, an exception similar to the one below is raised when attempting to run the Java client.

AutomationException: 0x80040154 - Class not registered
at com.linar.jintegra.bk.b(bk.java)
at com.linar.jintegra.Rpc.a(Rpc.java)
at com.linar.jintegra.bd.a(bd.java)
at com.linar.jintegra.Dispatch.createDispatch(Dispatch.java)
at com.linar.jintegra.Dispatch.(Dispatch.java)
....

The following will likely be found in the jintegra.log file (note that the timestamp and the GUID will be different):

993177000720 *: Error activating
f25a7722-78db-11d2-8e92-006008960167/88a7ae30-de1b-11d1-ab22-00a024d1c496:
AutomationException: 0x80040154 - Class not registered

1. Register the COM component

DLL

If the COM component is a DLL...

First of all, run regsvr32 on your COM component to make sure that it's registered with Windows.

You will get this error if attempting to use J-Integra to talk to a COM component that is hosted in a DLL. In order to access the DLL, it is necessary to configure a surrogate EXE, since DCOM can only be used to talk to EXEs. See the ATL DLL example for instructions on configuring such a surrogate using Setdllhost.

If your Java client and the DLL are both on the same machine, you have an option to run your Java client in native mode and do not need to use the Setdllhost.

OCX

If the COM component is a OCX...

You will get this error if attempting to use J-Integra to talk to an OCX component without embedding it in a Java frame. OCXs must be loaded in-process such as when they are embedded in a VB form. When the OCX is embedded in a Java frame, it's automatically loaded in-process. Therefore the OCX must be configured using Setdllhost if it's not embedded in a Java frame.

Make sure that the "Generate Java AWT classes" option of com2java is selected if your Java client embeds the OCX, and this option is not selected if the Java client does not embed the OCX. Otherwise you will get errors such as NullPointerException.

EXE

If the COM component is an EXE, you need to double click the EXE to run it, which will register the EXE automatically, before invoking it from your Java client.

2. If you continue to get this exception after running Setdllhost...

This exception may also be raised if the type library references COM objects that are hosted in DLLs or OCXs other than the one Setdllhost has been run on. Since these additional DLLs or OCXs are not processed by Setdllhost, no surrogate executable (dllhost.exe) would be set up for them, causing the exception. To verify, open the type library with OLEVIEW (oleview.exe), or run J-Integra's CheckConfig tool on the type library in question:

checkconfig /typelib "typelibfile"

All DLLs or OCXs hosting the COM objects referenced from the type library will be listed. An illustration of a CheckConfig log:

-----------------------------------
Class Name = ....
Class Id = ....
Class Name = COMObject Class
InprocServer32 = C:\Program Files\Common Files\FirstDll.DLL
("C:\Program Files\Common Files\FirstDll.DLL" file exists)
ThreadingModel = Both
ProgID = ....
Programmable = no value(259)
VersionIndependentProgID = ....
-----------------------------------
Class Name = ....
Class Id = ...
Class Name = AnotherCOMObject Class
InprocServer32 = C:\Program Files\Common Files\SecondDll.DLL
("C:\Program Files\Common Files\SecondDll.DLL" file exists)
ThreadingModel = Both
ProgID = ....
Programmable = no value(259)
VersionIndependentProgID = ....
-----------------------------------

Change to the directory containing the DLLs, and run the Setdllhost tool, passing it the names of the DLLs which export the classes you are using. For example:

> setdllhost FirstDll.dll SecondDll.dll ThirdDll.dll ... "MySurrogate"

You do not have to include the DLLs which export classes you do not use.

3. Instantiation fails

The "0x80040154 - Class not registered" exception also means "Class is registered but just can't be instantiated". For example:

COMObject comObject = new COMObject("");

In the above instantiation, new COMObject(""), may throw an exception which causes COMObject not to be instantiated, and hence a 0x80040154 exception will then be thrown. To solve this problem, instead of using new COMObject(""), use just new COMObject() or new COMObject("localhost").

Related Articles
No Related Articles Available.

Article Attachments
No Attachments Available.

Related External Links
No Related Links Available.
Help us improve this article...
What did you think of this article?

poor 
1
2
3
4
5
6
7
8
9
10

 excellent
Tell us why you rated the content this way. (optional)
 
Approved Comments...
No user comments available for this article.
Created on 6/23/2006.
Last Modified on 7/11/2006.
Last Modified by No Author Name Available!.
Article has been viewed 10815 times.
Rated 5 out of 10 based on 27 votes.
Print Article
Email Article