import com.indexdata.masterkey.config.MasterkeyConfiguration;\r
import com.indexdata.masterkey.config.ModuleConfiguration;\r
import com.indexdata.mkjsf.errors.ConfigurationException;\r
+import com.indexdata.mkjsf.errors.MissingConfigurationContextException;\r
import com.indexdata.mkjsf.utils.Utils;\r
\r
import static com.indexdata.mkjsf.utils.Utils.nl;\r
\r
private Configuration readConfig (Configurable configurable) throws ConfigurationException {\r
Configuration config = new Configuration();\r
- ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();\r
- ServletContext servletContext = (ServletContext) externalContext.getContext(); \r
- MasterkeyConfiguration mkConfigContext;\r
+ MasterkeyConfiguration mkConfigContext = null;\r
+ ExternalContext externalContext = null;\r
+ try {\r
+ externalContext = FacesContext.getCurrentInstance().getExternalContext(); \r
+ } catch (NullPointerException npe){\r
+ throw new MissingConfigurationContextException("No FacesContext available to get configuration context from: " + npe.getMessage());\r
+ }\r
+ ServletContext servletContext = (ServletContext) externalContext.getContext();\r
try {\r
mkConfigContext = MasterkeyConfiguration.getInstance(servletContext,\r
- "pazpar-application-jsf", ((HttpServletRequest) externalContext.getRequest()).getServerName());\r
+ "mkjsf", ((HttpServletRequest) externalContext.getRequest()).getServerName());\r
} catch (IOException e) {\r
throw new ConfigurationException(Mk2ConfigReader.class + " could not read configuration for '" + configurable.getModuleName() + "' using MasterKey configuration scheme: "+e.getMessage(),e);\r
} \r