Restrictions When Accessing COM Objects from EJBs
The EJB specification places several restrictions on what EJBs can and can not do. This in turn affects what J-Integra can do. Specifically when using J-Integra to access a COM component from an EJB:
1. You must use DCOM mode (Native mode can not work since native code can not be used from EJBs).
2. You must call AuthInfo.setDefault(...) or AuthInfo.setThreadDefault(...) to establish authentication credentials (you can not let J-Integra use native code to pick up the credentials of the current user, since native code can not be used from EJBs).
3. You can not subscribe to events (this requires J-Integra to establish a ServerSocket, which is not allowed in EJBs).
4. You can not pass Java objects as parameters to method calls on COM components and have the COM component make callbacks (this requires J-Integra to establish a ServerSocket, which is not allowed in EJBs).
5. In addition, the J-Integra runtime normally makes use of threads. Because the creation of threads in EJBs is not allowed, work that the J-Integra runtime would normally perform in the background does not take place. Specifically the J-Integra runtime can not perform DCOM pinging, which tells remote servers that COM components are still in use by Java clients. The effect of this is that COM components will be released automatically after six minutes.
When running in DCOM mode the J-Integra runtime sends DCOM ping messages per the DCOM protocol to tell the COM server that the client is still alive. According to the DCOM specification, DCOM clients send these ping messages every two minutes. If 3 consecutive ping intervals (six minutes) goes by without the COM server receiving a ping message, the server assumes the client has either crashed or become unreachable due to a network failure and will release and cleanup its references (MSDN Article: Lifecycle Management and Marshalling). This behavior applies to all applications that use DCOM to communicate.
EJB Accessing COM Component Example
Please read the iPlanet example in order to see how to use COM components from EJBs.