Running a LuciadLightspeed sample from your IDE causes the following errors:
In the console:
Internal error occurred. It might be necessary to restart the application. Error message: Specify a model before calling the layer method.
In a sample dialog box:
The sample could not discover any layer factories. If you want to make use of the service registry, enable annotation processing in your IDE/compiler.
These errors occur with samples that make use of the LuciadLightspeed service registry, such as the decoding samples and layer factory samples.
Why does this happen ?
LuciadLightspeed makes use of a service registry to provide instant application services. Java annotations are used to automatically register LuciadLightspeed services with the registry.
The service registry has been pre-populated in the release, so the samples work correctly when you launch the sample script files from a freshly unzipped release. If you include the sample code in your IDE, however, the IDE needs to process the annotations when it is compiling the samples.
Benefits of using a service registry
LuciadLightspeed samples use a service registry to provide instant data format services. The support provided for each data format, such as its model decoder and layer factory, is registered as a service that can be looked up, retrieved and activated. The service registry allows you to use a look-up mechanism to query all supported model decoders and layer factories at run-time. The LuciadLightspeed look-up mechanism supports both the built-in formats, as well as your own, custom-defined or custom-configured data formats.
For more information, see the Services documentation.
LuciadLightspeed makes use of a service registry to provide instant application services. Java annotations are used to automatically register LuciadLightspeed services with the registry, and the IDE must be configured to process the annotations when it is compiling the samples.
Activate annotation processing in the compilation settings of your IDE when you compile your project. All major IDE implementations support annotation processing.
Activating annotation processing in IntelliJ
In IntelliJ, find the annotation processor settings in the Settings panel, and select the check box. IntelliJ automatically discovers the library.
Activating annotation processing in Eclipse
In Eclipse, open the project properties, and find the annotation processing option with the compiler settings. Activate the option, and add the library
Activating annotation processing in Netbeans
In NetBeans, open the project properties, and add the library
lib/lcd_annotations.jarto the compile-time libraries in the Libraries panel. In the Build | Compiling panel, find the options that enable annotation processing and activate them.
The NetBeans IDE contains a known bug that prevents annotation processing from working properly in combination with the Compile on Save option. Disable this option to work around this bug.
Make sure that the JAR files containing the annotation processor (lcd_annotations*) are in the compiler classpath. If your IDE requires you to explicitly declare annotation processors, point it to
Fully re-build your project. A META-INF directory appears in the directory with the compiled project classes.