Author: pier
Date: Wed Nov 3 09:20:23 2004
New Revision: 56492
Modified:
cocoon/whiteboard/kernel/sources/startup/org/apache/cocoon/kernel/startup/ServletLoader.java
Log:
Fix NPE in shutdown and better error messages on startup
Modified:
cocoon/whiteboard/kernel/sources/startup/org/apache/cocoon/kernel/startup/ServletLoader.java
==============================================================================
---
cocoon/whiteboard/kernel/sources/startup/org/apache/cocoon/kernel/startup/ServletLoader.java
(original)
+++
cocoon/whiteboard/kernel/sources/startup/org/apache/cocoon/kernel/startup/ServletLoader.java
Wed Nov 3 09:20:23 2004
@@ -97,13 +97,29 @@
if (configuration != null) {
URL configuration_url = context.getResource(configuration);
+
+ if (configuration_url == null) {
+ throw new IllegalArgumentException("Configuration file \""
+ + configuration + "\" not found");
+ }
+
Configuration conf =
ConfigurationBuilder.parse(configuration_url);
descriptors = instances = conf;
} else {
String desc_par =
context.getInitParameter("kernel-descriptors");
String inst_par = context.getInitParameter("kernel-instances");
+
URL desc_url = context.getResource(desc_par);
URL inst_url = context.getResource(inst_par);
+
+ if (desc_url == null) {
+ throw new IllegalArgumentException("Descriptors
configuration "
+ + "file \"" + desc_par + "\" not found");
+ } else if (inst_url == null) {
+ throw new IllegalArgumentException("Instances
configuration "
+ + "file \"" + inst_par + "\" not found");
+ }
+
descriptors = ConfigurationBuilder.parse(desc_url);
instances = ConfigurationBuilder.parse(inst_url);
}
@@ -143,6 +159,7 @@
* <p>Receive notification of destruction.</p>
*/
public void contextDestroyed(ServletContextEvent event) {
+ if (this.kernel == null) return;
ServletContext context = event.getServletContext();
context.removeAttribute(ServletLoader.ATTRIBUTE);
try {