I am trying to change the port that Sling runs on. Our project is building a 
Sling standalone jar that is executed to run the server. From reading the 
documentation I understand that the best way to change properties is via the 
file sling_install.properties. So, I created the file 
src/main/resources/sling_install.properties and added the line

org.osgi.service.http.port=4242


This does not work - the server still comes up on 8080. I verified that my 
desired port is written into sling/sling.properties after the server starts. 
Using the -p option on the command line works - I can change the port, however 
this is not our preferred way of doing this because we want our client code to 
stay in sync with whatever port we decide to use, and we'd rather have that 
defined within the property files.

I started digging into the code and I think I see a problem.  This is the chain 
of events I see:


*         MainDelegate.start(): the command line is null, so setCommandLine() 
is called.

*         MainDelegate.setCommandLine(): a HashMap is created in 'commandLine' 
and the default port is put into it. parseCommandLine() won't change anything 
and this value will remain.

*         MainDelegate.start(): Sling is constructed and 
loadPropertiesOverride() is in fact overridden. The commandLine map is loaded 
into properties.

*         Sling.loadConfigProperties(): after loading the property files 
loadPropertiesOverride() is called. This overwrites the port property.

So, it seems that no matter what the user does, the default port is going to 
override their setting. Is this a bug?

Reply via email to