Troubleshooting Event Handlers

As you develop event handlers, use the debugging options in the Design Tool to identify problems. Here are additional conditions you may need to address when developing or maintaining models that have event handlers associated with them.

Debugging tools show results that do not match the object's definition.

Event handler name is displayed in red.

A Reset Needed or Update Needed icon is displayed on the status bar.

Error message: An error occurred while communicating with the script manager

Callback method is not allowed within an event handler

Script manager does not start.

Java: Startup synchronization problems when additional JAR files are in scripts\lib folder.

.NET: Runtime errors result from crossing domain boundaries

Model is not recognizing source files that have been imported.

Deployment error with saved model

Problems with Web Builder application's event handlers for recordsets and attributes.

Troubleshooting Summary

Debugging tools show results that do not match the model object's definition.

This is not a event handler error, and may in fact be the appropriate behavior if an object has an event handler attached to it. Check to see if a lightning bolt () is displayed next to the object in question. This event handler may include logic that overrides or extends the object's behavior as defined in the Design Tool. For example, the recordset test used in the event handler example returns values that include a dollar sign not defined within the recordset itself.

Event handler name is displayed in red.

The name of an event handler is displayed in red if a model object has an event handler attached, but the event handler no longer exists (for example, the JAR or assembly file containing the handler has been removed, a class file is missing, or the source file was not available when handlers were rebuilt).

You cannot deploy a model with this problem, although the model itself can be saved. If the JAR file or the assembly file is the problem, simply rebuild the event handlers.

A Reset Needed or Update Needed icon is displayed on the status bar.

Under certain conditions, you may see one of the following symbols on the Design Tool status bar:

Update Needed The event handler JAR or assembly files stored on disk no longer match what is being used by the script manager (in memory).
Click (Reload Event Handlers) to update the JAR files.
Reset Needed The script manager cannot respond. If this condition occurs on the Host Integrator Server, the Server initiates a shutdown process. No manualreset is needed.

 

Error message: An error occurred while communicating with the script manager

If this event handler communication error is displayed while building event handlers, there may be a problem with the port being used by the script manager. Other problem sources are the version of the JRE or the JAR file being used by the script manager (Java), or an equivalent version discrepancy with .NET assembly files.

When a script manager communication error occurs on the Host Integrator Server, this information is sent to the log file and to the client application.

Script manager does not start.

The script manager is implemented as a separate process, and is required for normal server operation. The Design Tool and the Session Server each require a separate instance of the script manager, and the handling of script manager problems in each case differs.

Startup

Runtime

Java: Startup synchronization problems when additional JAR files are in scripts\lib folder.

For a given model, all JAR files or in the scripts\lib directory will be introspected for available event handlers using the Java reflection API, an introspection utility for Java classes. JAR files that do not contain event handler classes can be placed on the user class path, not in the model's scripts\lib directory, to avoid the overhead of introspection. Introspecting more than 1 MB of JAR files in the model's event handler directory may cause startup synchronization problems.

.NET: Runtime errors result from crossing domain boundaries

When using .NET Event Handlers, objects you store and retrieve from VHI contexts must be made effectively serializable due to the .NET remoting that occurs over application domains.

The script server dynamically loads and unloads the event handler classes using an Application Domain. In the event handler API, you can store arbitrary objects in six contexts: host session, client session, model context, RecordSet, Record, RecordLocation. Each of these expose Set...StateObject, Get...StateObject, and Is...StateObject methods. The values that you pass to these Set...StateObject methods cross from the event handler AppDomain to the script server AppDomain. Later, if you use Get...StateObject, the value passes back to the event handler AppDomain.

If you store an object using these methods, you could see an exception similar to these:

[VHI 4309] An unhandled System.Runtime.Serialization.SerializationException exception occurred in the 
abbreviations.LifeCycleHandler.ModelLoaded() event handler: Type 'yourType' in 
Assembly 'example, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable.
 
[VHI 4309] An unhandled System.IO.FileNotFoundException exception occurred in the 
abbreviations.LifeCycleHandler.ModelLoaded() event handler: Could not load file or 
assembly 'example, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its 
dependencies. The system cannot find the file specified.

These exceptions occur because the Common Language Runtime uses remoting to pass values between AppDomains. All values must either be serializable or a reference (a subclass of MarshalByRefObject). Follow the guidelines below to avoid this problem:

Model is not recognizing source files for event handlers that have been imported.

You can import event handlers from another model. Copying the source files requires a rebuild so that they can be added to the model JAR file.

Deployment error with saved model.

Resave a model if you make changes to one or more of the event handler files in the model package, even though you have not made changes to the model itself. Reload the model in the Design Tool, validate, and then save the model and redeploy or re-create the package for deployment. Event handler files are automatically included when you deploy a model.

Problems with Web Builder application's event handlers for recordsets and attributes.

If you use Web Builder to create web applications, there are limitations on recordset and attribute event handlers.

 

Related Topics
Bullet Debugging event handlers
Bullet Event handler guidelines