dev@glassfish.java.net

Re: Is this a bug or did I just misinterpret the set-web-env-entry command?

From: Tim Quinn <tim.quinn_at_oracle.com>
Date: Tue, 18 Jun 2013 06:43:38 -0500

Hi, Vince.

Ultimately it's up to the respective container to decide how to deal with these dynamic reconfiguration commands.

Having said that, I worked on the initial implementation of this bit of functionality quite a while back (while on the deployment team). Someone from deployment team or the web team might have more recent information, but I think if you disable and then re-enable the affected app you will then see the effects you expect. This effectively restarts the application - so the configuration changes can take effect - without restarting the entire server.

Can you try that?

IIRC the thinking at the time was that an application might use one or more of the dynamically reconfigurable items during its start-up. It could lead to inconsistent (and therefore surprising) or incorrect results if the container used a newly-modified setting immediately, given that the app would have started up with the old, unchanged value. So requiring an app restart made sure that the app always ran with a consistent set of configuration information.

I took a quick look at the published documentation and I did not see it mentioned that users must restart the app for the changes to take effect. That's probably worth a JIRA issue.

- Tim

On Jun 17, 2013, at 11:42 PM, Vince Kraemer wrote:

> I have deployed a web app that uses an env-entry. The name of the entry is EnvEntryName. The value is a String, "EnvEntryValue"... very original huh...
>
> Lets take a look at the output from the app "originally"
>
> vbkmbp:~ vkraemer$ curl http://localhost:8080/AppWithEnvEntryAndContextParam6/NewServlet
> <!DOCTYPE html>
> <html>
> <head>
> <title>Servlet NewServlet</title>
> </head>
> <body>
> <h1>Servlet NewServlet at /AppWithEnvEntryAndContextParam6</h1>
> <h2>Env: EnvEntryValue</h2>
> <h2>Context-Param: ParamValue</h2>
> <h2>Init-Param: InitParamValue</h2>
> </body>
> </html>
>
> Sweet.
>
> Now... we run the following command...
>
> vbkmbp:~ vkraemer$ /Applications/NetBeans/glassfish-4.0/bin/asadmin set-web-env-entry --name EnvEntryName --value NewEnvEntryValue --type java.lang.String --ignoredescriptoritem=false AppWithEnvEntryAndContextParam6
> Command set-web-env-entry executed successfully.
>
>
> If I rerun the 'curl'... I get the same output as I got BEFORE I ran the command.
>
> If I restart the domain... I see this...
>
> vbkmbp:~ vkraemer$ /Applications/NetBeans/glassfish-4.0/bin/asadmin restart-domain domain1
> Successfully restarted the domain
> Command restart-domain executed successfully.
> vbkmbp:~ vkraemer$ curl http://localhost:8080/AppWithEnvEntryAndContextParam6/NewServlet
> <!DOCTYPE html>
> <html>
> <head>
> <title>Servlet NewServlet</title>
> </head>
> <body>
> <h1>Servlet NewServlet at /AppWithEnvEntryAndContextParam6</h1>
> <h2>Env: NewEnvEntryValue</h2>
> <h2>Context-Param: ParamValue</h2>
> <h2>Init-Param: InitParamValue</h2>
> </body>
> </html>
>
> I will be honest... I would have expected the env-entry-value to have changed without a restart of the domain.
>
> requiring a restart seems to be a strong limitation of the value of the set-web-env-entry command.
>
> note: set-web-context-param seems to suffer a similar 'fate'....
>
> vbkmbp:~ vkraemer$ curl http://localhost:8080/AppWithEnvEntryAndContextParam6/NewServlet
> <!DOCTYPE html>
> <html>
> <head>
> <title>Servlet NewServlet</title>
> </head>
> <body>
> <h1>Servlet NewServlet at /AppWithEnvEntryAndContextParam6</h1>
> <h2>Env: NewEnvEntryValue</h2>
> <h2>Context-Param: ParamValue</h2>
> <h2>Init-Param: InitParamValue</h2>
> </body>
> </html>
>
> vbkmbp:~ vkraemer$ /Applications/NetBeans/glassfish-4.0/bin/asadmin set-web-context-param --value NewParamValue AppWithEnvEntryAndContextParam6Enter the value for the name option> ParamName
> Command set-web-context-param executed successfully.
>
> vbkmbp:~ vkraemer$ curl http://localhost:8080/AppWithEnvEntryAndContextParam6/NewServlet
> <!DOCTYPE html>
> <html>
> <head>
> <title>Servlet NewServlet</title>
> </head>
> <body>
> <h1>Servlet NewServlet at /AppWithEnvEntryAndContextParam6</h1>
> <h2>Env: NewEnvEntryValue</h2>
> <h2>Context-Param: ParamValue</h2>
> <h2>Init-Param: InitParamValue</h2>
> </body>
> </html>
>
> vbkmbp:~ vkraemer$ /Applications/NetBeans/glassfish-4.0/bin/asadmin restart-domain domain1
> Successfully restarted the domain
> Command restart-domain executed successfully.
>
> vbkmbp:~ vkraemer$ curl http://localhost:8080/AppWithEnvEntryAndContextParam6/NewServlet
> <!DOCTYPE html>
> <html>
> <head>
> <title>Servlet NewServlet</title>
> </head>
> <body>
> <h1>Servlet NewServlet at /AppWithEnvEntryAndContextParam6</h1>
> <h2>Env: NewEnvEntryValue</h2>
> <h2>Context-Param: NewParamValue</h2>
> <h2>Init-Param: InitParamValue</h2>
> </body>
> </html>
>
> Thanks,
> vbk
>
>