geofence
geofence copied to clipboard
Fix GeoFence model
GeoFence at the moment has two different modules for the model:
- Internal model: https://github.com/geoserver/geofence/tree/master/src/services/core/model This module is used internally by the GeoFence webapp, and has hibernate annotations.
- External model: https://github.com/geoserver/geofence/tree/master/src/services/core/model-external This module is used by external modules which use GeoFence API. Annotations are not present here, so client apps do not need to bundle hibernate libraries for the annotations, which are not used outside the geofence webapp.
The external model is automatically generated by using the internal sources, performing some text search/replace operations and building it.
This brings two issues:
- you have to pay attention to which model you are importing in your module.
- you cannot mix the two modules, because they contain the very same class names and may cause issue with the classloaders. This brings another problem:
- the embedded geoserver-geofence modules are mutually exclusive:
gs-geofence(the client module, which needs an externally running geofence webapp) only needs the external model.gs-geofence-server(the module which runs an embedded geofence engine in geoserver) needs the internal model (it needs to persist the geofence data), and also has a dependecy vs gs-geofence for the accessmanager logic. It means thatgs-geofence-servershall have a mavenexclusionon the external model module; furthermore, running geoserver with both the gs-geofence and gs-geofence-server defined expicitly will import both models and won't run properly.
A solutions to this problem is removing the hibernate annotations and add the related .hbm files in the gf-persistence module.
This issue in particular prevents developing GeoServer + GeoFence using Eclipse the "normal" way, with Start.java, one has to use mvn jetty:run with the right command line options instead