[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [smila-user] Problem in Pipelet Extension Bundle

Hi,

Am 10.05.2012 14:04, schrieb Lorenzo Eccher:
Hi folks,
I'm using SMILA 1.0.

Often happens that when I start SMILA (in eclipse) I found an error in log that tells me there are problems registernig bpel pipeline.

...
After some time spent to see what could be wrong, removing all my bpel and so on, I tried to debug that piece of code.

I found something strange in PipeletExtensionBundle.registerActivity.
A not Throwable NullPointerException was thorow.

I tried to spit in 2 lines
    PipeletManager.getServiceInstance().registerActivity(pipeletHolder);
so I had got
    PipeletManager pipeletManager = PipeletManager.getServiceInstance();
    pipeletManager.registerActivity(pipeletHolder);


And I saw that PipeletManager.getServiceInstance(); gave back a null pipeletManager.

If I wait few seconds here, the services are created and then the code runs right.

Now I wrote a workaround waiting that pipeletManager is not null.

It is a bug or there is something could be wrong in my configurations? Thanks
Yes, this is a bug in 1.0 which was fixed very soon afterwards. The dependencies of the services are such that it sometimes happens that OSGi starts them in the wrong order and then the PipeletManager will not be found at this place. You can use a more current nightly build instead.
Or you can try to apply the changes from revision 2247 ("cleanup some dependencies") to your workspace. I've attached a patch file with these changes to this mail.
To apply them, in Eclipse you do:
    Right-click in Package Explorer -> Team -> Apply Patch -> Apply path to workspace root etc.
Sorry for the inconvenience.

Regards,
Juergen.
Index: org.eclipse.smila.processing.bpel/META-INF/MANIFEST.MF
===================================================================
--- org.eclipse.smila.processing.bpel/META-INF/MANIFEST.MF	(revision 2246)
+++ org.eclipse.smila.processing.bpel/META-INF/MANIFEST.MF	(revision 2247)
@@ -2,7 +2,7 @@
 Bundle-ManifestVersion: 2
 Bundle-Name: SMILA BPEL Workflow Engine Integration
 Bundle-SymbolicName: org.eclipse.smila.processing.bpel
-Bundle-Version: 1.0.0.qualifier
+Bundle-Version: 1.0.1.qualifier
 Import-Package: org.apache.commons.io;version="1.4.0",
  org.apache.commons.io.filefilter;version="1.4.0",
  org.apache.commons.lang;version="2.4.0",
@@ -39,9 +39,9 @@
  org.osgi.framework;version="1.4.0",
  org.osgi.service.component;version="1.0.0"
 Export-Package: org.eclipse.smila.processing.bpel;version="1.0.0",
- org.eclipse.smila.processing.bpel.activities;version="1.0.0",
+ org.eclipse.smila.processing.bpel.activities;version="1.0.1",
  org.eclipse.smila.processing.bpel.counter;version="1.0.0",
- org.eclipse.smila.processing.bpel.internal;version="1.0.0",
+ org.eclipse.smila.processing.bpel.internal;version="1.0.1",
  org.eclipse.smila.processing.bpel.util;version="1.0.0"
 Service-Component: OSGI-INF/processor.xml, OSGI-INF/storage.xml, OSGI-INF/updatewatcher.xml, OSGI-INF/engine.xml, OSGI-INF/pipeletmanager.xml, OSGI-INF/requests.xml
 Bundle-Vendor: Attensity Europe GmbH and brox IT Solutions GmbH
Index: org.eclipse.smila.processing.bpel/code/src/org/eclipse/smila/processing/bpel/activities/PipeletExtensionBundle.java
===================================================================
--- org.eclipse.smila.processing.bpel/code/src/org/eclipse/smila/processing/bpel/activities/PipeletExtensionBundle.java	(revision 2246)
+++ org.eclipse.smila.processing.bpel/code/src/org/eclipse/smila/processing/bpel/activities/PipeletExtensionBundle.java	(revision 2247)
@@ -26,10 +26,29 @@
 /**
  * ODE extension bundle for compiling and invoking invokePipelet and invokeService extension activities.
  */
-public class PipeletExtensionBundle extends AbstractExtensionBundle {
+public final class PipeletExtensionBundle extends AbstractExtensionBundle {
+
+  private static final PipeletExtensionBundle INSTANCE = new PipeletExtensionBundle();
 
   /** for validating and parsing pipelet invocations from BPEL. */
-  private static final PipeletActivityValidator VALIDATOR = new PipeletActivityValidator();
+  private final PipeletActivityValidator _validator = new PipeletActivityValidator();
+
+  /** pipelet manager to use for pipelet invocations. */
+  private PipeletManager _pipeletManager;
+
+  /** don't create more than one instance. */
+  private PipeletExtensionBundle() {
+  }
+
+  /** get singleton instance. */
+  public static PipeletExtensionBundle getInstance() {
+    return INSTANCE;
+  }
+
+  /** inject manager instance. */
+  public void setPipeletManager(final PipeletManager pipeletManager) {
+    _pipeletManager = pipeletManager;
+  }
 
   @Override
   public String getNamespaceURI() {
@@ -42,24 +61,24 @@
   }
 
   /** invoke a pipelet. */
-  private static void invokeActivity(final ExtensionContext context, final Element element) {
+  private void invokeActivity(final ExtensionContext context, final Element element) {
     final OActivity activity = context.getOActivity();
     final String key = PipeletExtensionBundle.getActivityKey(activity);
-    PipeletManager.getServiceInstance().invokeActivity(key, context, element);
+    _pipeletManager.invokeActivity(key, context, element);
   }
 
   /** validate a pipelet invocation and register it in the PipeletManager. */
-  private static void registerActivity(final OExtensionActivity activity, final ExtensibleElement element,
+  private void registerActivity(final OExtensionActivity activity, final ExtensibleElement element,
     final CompilerContext compilerContext) {
     final OProcess process = activity.getOwner();
     final String key = getActivityKey(activity);
     final Element content = element.getNestedElement();
     final PipeletHolder pipeletHolder =
-      VALIDATOR.validateActivity(process, activity, content, key, compilerContext);
+      _validator.validateActivity(process, activity, content, key, compilerContext);
     try {
-      PipeletManager.getServiceInstance().registerActivity(pipeletHolder);
+      _pipeletManager.registerActivity(pipeletHolder);
     } catch (final ProcessingException ex) {
-      throw new CompilationException(VALIDATOR.createErrorCompilationMessage(key, "Error initialising pipelet: "
+      throw new CompilationException(_validator.createErrorCompilationMessage(key, "Error initialising pipelet: "
         + ex), ex);
     }
   }
@@ -87,7 +106,7 @@
     @Override
     public void run(final Object contexto, final Element element) throws FaultException {
       final ExtensionContext context = (ExtensionContext) contexto;
-      invokeActivity(context, element);
+      getInstance().invokeActivity(context, element);
     }
 
     /**
@@ -100,7 +119,7 @@
     public void validate(final Object compiler, final ExtensibleElement element) {
       final CompilerContext compilerContext = (CompilerContext) compiler;
       final OExtensionActivity activity = (OExtensionActivity) compilerContext.getCurrent();
-      registerActivity(activity, element, compilerContext);
+      getInstance().registerActivity(activity, element, compilerContext);
     }
   }
 
Index: org.eclipse.smila.processing.bpel/code/src/org/eclipse/smila/processing/bpel/activities/PipeletManager.java
===================================================================
--- org.eclipse.smila.processing.bpel/code/src/org/eclipse/smila/processing/bpel/activities/PipeletManager.java	(revision 2246)
+++ org.eclipse.smila.processing.bpel/code/src/org/eclipse/smila/processing/bpel/activities/PipeletManager.java	(revision 2247)
@@ -16,6 +16,7 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.ode.bpel.common.FaultException;
 import org.apache.ode.bpel.evar.ExternalVariableModuleException;
+import org.apache.ode.bpel.rtrep.common.extension.AbstractExtensionBundle;
 import org.apache.ode.bpel.rtrep.common.extension.ExtensionContext;
 import org.apache.ode.utils.DOMUtils;
 import org.eclipse.smila.blackboard.Blackboard;
@@ -25,17 +26,13 @@
 import org.eclipse.smila.processing.ProcessingException;
 import org.eclipse.smila.processing.bpel.RequestTable;
 import org.eclipse.smila.processing.bpel.counter.ProcessingPerformanceCounter;
+import org.eclipse.smila.processing.bpel.internal.ExtensionBundleProvider;
 import org.eclipse.smila.processing.bpel.util.MessageHelper;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 
-/**
- * Pipelet Manager and Invoker.
- */
-public final class PipeletManager implements PipeletTrackerListener {
-
-  /** current service instance. */
-  private static PipeletManager s_serviceInstance;
+/** Pipelet Manager and Invoker. */
+public final class PipeletManager implements PipeletTrackerListener, ExtensionBundleProvider {
 
   /** Map of class names to currently active simple pipelet classes. */
   private final Map<String, Class<? extends Pipelet>> _activePipeletClasses =
@@ -50,14 +47,11 @@
   /** local logger. */
   private final Log _log = LogFactory.getLog(getClass());
 
-  /** get the current service instance. */
-  public static PipeletManager getServiceInstance() {
-    return s_serviceInstance;
-  }
-
-  /** declarative service activation method. */
-  protected void activate() {
-    s_serviceInstance = this;
+  @Override
+  public AbstractExtensionBundle getExtensionBundle() {
+    final PipeletExtensionBundle bundle = PipeletExtensionBundle.getInstance();
+    bundle.setPipeletManager(this);
+    return bundle;
   }
 
   /** invoke a pipelet. */
Index: org.eclipse.smila.processing.bpel/code/src/org/eclipse/smila/processing/bpel/internal/OdeBpelEngine.java
===================================================================
--- org.eclipse.smila.processing.bpel/code/src/org/eclipse/smila/processing/bpel/internal/OdeBpelEngine.java	(revision 2246)
+++ org.eclipse.smila.processing.bpel/code/src/org/eclipse/smila/processing/bpel/internal/OdeBpelEngine.java	(revision 2247)
@@ -27,7 +27,6 @@
 import org.eclipse.smila.processing.ProcessingException;
 import org.eclipse.smila.processing.WorkflowProcessor;
 import org.eclipse.smila.processing.bpel.BpelEngine;
-import org.eclipse.smila.processing.bpel.activities.PipeletExtensionBundle;
 import org.eclipse.smila.processing.bpel.util.BpelConstants;
 import org.eclipse.smila.processing.bpel.util.ConfigurationHelper;
 import org.w3c.dom.Element;
@@ -41,6 +40,9 @@
   /** Workflow deployment manager for the ODEServer. */
   private DeploymentManager _deploymentManager;
 
+  /** service providing an extension bundle for ODE. */
+  private ExtensionBundleProvider _extensionProvider;
+
   /** local logger. */
   private final Log _log = LogFactory.getLog(getClass());
 
@@ -52,7 +54,7 @@
         new ODEConfigProperties(properties, ConfigurationHelper.PROP_PREFIX_ODE);
       final WebServiceContextFactory processingContext = new WebServiceContextFactory();
       _odeServer = new ODEServer(odeConfig, processingContext);
-      _odeServer.registerExtensionBundle(new PipeletExtensionBundle());
+      _odeServer.registerExtensionBundle(_extensionProvider.getExtensionBundle());
       _deploymentManager = new DeploymentManager();
     } catch (final Exception ex) {
       _log.error("Start of BPEL workflow service failed: Unknown fatal error. "
@@ -60,6 +62,18 @@
     }
   }
 
+  /** bind DS service reference. */
+  public void setExtensionProvider(final ExtensionBundleProvider extensionProvider) {
+    _extensionProvider = extensionProvider;
+  }
+
+  /** unbind DS service reference. */
+  public void unsetExtensionProvider(final ExtensionBundleProvider extensionProvider) {
+    if (_extensionProvider == extensionProvider) {
+      _extensionProvider = null;
+    }
+  }
+
   /** shutdown engine. */
   protected void deactivate() {
     _odeServer.shutdown();
Index: org.eclipse.smila.processing.bpel/code/src/org/eclipse/smila/processing/bpel/internal/ExtensionBundleProvider.java
===================================================================
--- org.eclipse.smila.processing.bpel/code/src/org/eclipse/smila/processing/bpel/internal/ExtensionBundleProvider.java	(revision 0)
+++ org.eclipse.smila.processing.bpel/code/src/org/eclipse/smila/processing/bpel/internal/ExtensionBundleProvider.java	(revision 2247)
@@ -0,0 +1,16 @@
+/***********************************************************************************************************************
+ * Copyright (c) 2008, 2012 Attensity Europe GmbH and brox IT Solutions GmbH. All rights reserved. This program and the
+ * accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this
+ * distribution, and is available at http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors: Juergen Schumacher (Attensity Europe GmbH) - implementation
+ **********************************************************************************************************************/
+package org.eclipse.smila.processing.bpel.internal;
+
+import org.apache.ode.bpel.rtrep.common.extension.AbstractExtensionBundle;
+
+/** interface for services creating ODE extension bundles. */
+public interface ExtensionBundleProvider {
+  /** get extension bundle instance. */
+  AbstractExtensionBundle getExtensionBundle();
+}

Property changes on: org.eclipse.smila.processing.bpel/code/src/org/eclipse/smila/processing/bpel/internal/ExtensionBundleProvider.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:eol-style
   + native

Index: org.eclipse.smila.processing.bpel/OSGI-INF/engine.xml
===================================================================
--- org.eclipse.smila.processing.bpel/OSGI-INF/engine.xml	(revision 2246)
+++ org.eclipse.smila.processing.bpel/OSGI-INF/engine.xml	(revision 2247)
@@ -4,5 +4,5 @@
    <service>
       <provide interface="org.eclipse.smila.processing.bpel.BpelEngine"/>
    </service>
-   <reference cardinality="1..1" interface="org.eclipse.smila.processing.bpel.activities.PipeletManager" name="PipeletManager" policy="static"/>
+   <reference bind="setExtensionProvider" cardinality="1..1" interface="org.eclipse.smila.processing.bpel.internal.ExtensionBundleProvider" name="ExtensionBundleProvider" policy="static"/>
 </scr:component>
Index: org.eclipse.smila.processing.bpel/OSGI-INF/pipeletmanager.xml
===================================================================
--- org.eclipse.smila.processing.bpel/OSGI-INF/pipeletmanager.xml	(revision 2246)
+++ org.eclipse.smila.processing.bpel/OSGI-INF/pipeletmanager.xml	(revision 2247)
@@ -3,7 +3,7 @@
   <implementation class="org.eclipse.smila.processing.bpel.activities.PipeletManager"/>
   <service>
      <provide interface="org.eclipse.smila.processing.PipeletTrackerListener"/>
-     <provide interface="org.eclipse.smila.processing.bpel.activities.PipeletManager"/>
+     <provide interface="org.eclipse.smila.processing.bpel.internal.ExtensionBundleProvider"/>
   </service>
   <reference interface="org.eclipse.smila.processing.bpel.RequestTable" name="RequestTable"
     cardinality="1..1" policy="static" bind="setRequestTable" unbind="unsetRequestTable" />