I'm getting NPE's when reloading persistent subscriptions.
RouterFilePersistence.reloadResource initializes the resource BEFORE
adding the resource to the epr->resource map in the resource manager. The
issue is that initializing my NotificationProducer based resource precedes
initializing the SubscriptionManager. initializeCompleted is called and
the resource manager expects to find the SubscriptionManager resource, but
no such luck and an NPE occurs.
The following patch to RouterFilePersistence.java (for muse 2.2.0) seems
to fix this:
Index:
modules/muse-core/src/org/apache/muse/core/routing/RouterFilePersistence.java
===================================================================
---
modules/muse-core/src/org/apache/muse/core/routing/RouterFilePersistence.java
(revision 573048)
+++
modules/muse-core/src/org/apache/muse/core/routing/RouterFilePersistence.java
(working copy)
@@ -22,6 +22,7 @@
import java.io.File;
import java.io.IOException;
+import java.util.Iterator;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -94,6 +95,29 @@
*
* [EMAIL PROTECTED]
* <br><br>
+ * Initialize the resources AFTER loading and registering with the
Resource
+ * Manager so that initialization with inter-resource dependencies can
+ * succeed.
+ *
+ */
+ public void reload() throws SoapFault
+ {
+ super.reload();
+
+ // initialize the resources AFTER adding them to the resource
manager's
+ // epr->resource map
+ ResourceManager manager = getResourceManager();
+ Iterator resourceIter = manager.getResourceEPRs();
+ while (resourceIter.hasNext()) {
+ EndpointReference epr = (EndpointReference)resourceIter.next();
+ manager.getResource(epr).initialize();
+ }
+ }
+
+ /**
+ *
+ * [EMAIL PROTECTED]
+ * <br><br>
* This implementation treats the XML fragment as a
wsa:ReferenceParameters
* element. It creates an EPR for the given resource type (context path)
* and then adds the reference parameters to it. Finally, it creates an
@@ -138,9 +162,8 @@
resource.setEndpointReference(epr);
//
- // continue initialization/registration
+ // continue registration
//
- resource.initialize();
manager.addResource(epr, resource);
return resource;
Essentially, the patch loads all resources and adds them to the resource
manager's epr->resource map. Then, all resources are initialized.
Am I missing something here? Should file-based persistence work without
the above patch or is this a legitimate bug within muse?
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]