The problem occurs during layers rendering. I set the title for the layers I put inside mapContent, but eventually layers without a title are being rendered. This can be seen when errors occur. The name of the layer that was affected by the error is always null in the exception description. When I print out the problem I can see what happened but I have no idea which layer did this affect.
The source of the issue is in the class org.geotools.renderer.lite.CompositingGroup. There is a method
public static List<CompositingGroup> splitOnCompositingBase(Graphics2D graphics, Rectangle screenSize, MapContent mc)
In this class (line 79) a layer is being cloned. Unfortunately the title is not being passed to the cloned layer.
I think that calling a different constructor:
public FeatureLayer(FeatureSource featureSource, Style style, String title)
public FeatureLayer(FeatureSource featureSource, Style style)
would solve the problem.
OS: Windows 7 Professional