Samples of Threading Issues

The following are samples of the threading issues that may be encountered if the com.sun.faces.enableThreading context parameter is NOT set to false in your AppEngine's web.xml configuration file.

Error: Server Error - WebConfiguration.java

This problem did not  manifest itself when the application was launched from within Eclipse, but once the application was deployed to the Google AppEngine platform a "500 Server Error" message was displayed in the browser window upon visiting the site (see figure shown below).

Figure 1: Screenshot of "500 Server Error" Message

Signing into the Google AppEngine console for your web application and reviewing the log files generated by your application will reveal the following exception:

java.lang.NoClassDefFoundError: javax.naming.InitialContext is a restricted class. Please see the Google App Engine developer's guide for more details.

The "com.sun.faces.config.WebConfiguration.processJndiEntries - Stack Trace" document provides a comprehensive stack trace illustrating that the problem was caused when the  processJndiEntries(String) method  of the WebConfiguration class was invoked in line 109 of the attached WebConfiguration.java class.  

Solution

As the javax.naming.InitialContext is not supported in the Google AppEngine at this time, the body of the processJndiEntries(String) method has been commented out (see below).

    /**

     * <p>Process all JNDI entries.</p>

     * @param contextName the context name

     */

    private void processJndiEntries(String contextName) {

/* FIXME AppEngine javax.naming.Context is not supported by Google App Engine's Java runtime environment


        Context initialContext = null;

        try {

            initialContext = new InitialContext();

        } catch (NamingException ne) {

            if (LOGGER.isLoggable(Level.WARNING)) {

                LOGGER.log(Level.WARNING, ne.toString(), ne);

            }

        }


        if (initialContext != null) {

            // process environment entries

            for (WebEnvironmentEntry entry : WebEnvironmentEntry.values()) {

                String entryName = entry.getQualifiedName();

                String value = null;


                try {

                    value = (String) initialContext.lookup(entryName);

                } catch (NamingException root) {

                    if (LOGGER.isLoggable(Level.FINE)) {

                        LOGGER.fine(root.toString());

                    }

                }


                if (value != null) {

                    if (LOGGER.isLoggable(Level.INFO)) {

                        // special logic for ClientStateSavingPassword

                        if (!entry

                              .equals(WebEnvironmentEntry.ClientStateSavingPassword)) {

                            if (LOGGER

                                  .isLoggable(loggingLevel)) {

                                LOGGER.log(loggingLevel,

                                           "jsf.config.webconfig.enventryinfo",

                                           new Object[]{contextName,

                                                        entryName,

                                                        value});

                            }

                        } else {

                            if (LOGGER

                                  .isLoggable(loggingLevel)) {

                                LOGGER.log(loggingLevel,

                                           "jsf.config.webconfig.enventry.clientencrypt",

                                           contextName);

                            }

                        }

                    }

                    envEntries.put(entry, value);

                }

            }

        }


*/

    }

A patched version of the WebConfiguration.java source code file should be placed in the src/com/sun/faces/config directory in your web application's project directory.

Error: Server Error - ConfigManager.java

Once the problem with the WebConfguration class has been successfully addressed, the next issue that will warrant attention is the ConfigManager class source code file should be placed in the src/com/sun/faces/config directory in your web application's project directory.  If you re-deploy your web application to the Google AppEngine servers and attempt to visit the web site, the browser will display another "500 Server Error" window.

Upon signing into the application's control panel and reviewing the logs captured for the site, a message similar  following message will be visible:
com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! access denied (java.lang.RuntimePermission modifyThreadGroup)
The "com.sun.faces.config.ConfigManager.initialize - Stack Trace" document provides a comprehensive stack trace illustrating that the problem was caused when the initialize(ServletContext) method of the ConfigManager class was invoked.

Solution

The attached ConfigManger.java source code file should be placed in the src/com/sun/faces/config directory in your web application's project directory.

Error: Server Error - ConfigureListener.java

Just when you thought you may be out of the woods, there is attempt to create threads in the ConfigureListener class.  Once again, when you publish your application to the Google AppEngine site and attempt to access it, you may again encounter the following exception:
com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! access denied (java.lang.RuntimePermission modifyThreadGroup)
The attached "com.sun.faces.config.ConfigureListener.initConfigMonitoring(ServletContext) - Stack Trace" document is a copy of the stack trace encountered when the initConfigMonitoring method on the ConfigureListener object is invoked.

This problem will only manifest itself if the javax.faces.PROJECT_STAGE context  parameter in your web applications WEB-INF/web.xml file is set equal to "Development".  See the example below.

<context-param>

    <param-name>javax.faces.PROJECT_STAGE</param-name>

    <param-value>Development</param-value>

</context-param>

Solution

There are two options available to fix this particular problem.  The first of which is to place the attached Patched Version of the ConfigureListener.java source code in the src/com/sun/faces/config directory in your web application's project directory.

A second option would be to set the javax.faces.PROJEC_STAGE configuration parameter in the web.xml to some other value.  The following is a list of available options (Lubuke) for the javax.faces.PROJECT_STAGE configuration option..
  • Production 
  • Development
  • UnitTest
  • SystemTest
  • Extension