Drools Rule - Event not forwarded: "Object is not an instance of declaring class"

184 views
Skip to first unread message

Andreas Grünwald

unread,
Sep 4, 2013, 6:04:06 AM9/4/13
to openeng...@googlegroups.com
Hello,
i am trying to call a method of the Jira Issue service domain since yesterday, however I am still caught with a drools rule problem. The workflow is as follows:

  1. I am running a component called "synchronizerService". 
  2. Within this component (after startup) I use the utilsService and wiringService to connect to a connector of the domain "Spreadsheet" called "MSSpreadsheetService".
  3. I call a method of the "MSSpreadsheetService" to raise a test event. The event is initialized and fired.
  4. I created a drools rules called "InsertSpreadsheetEvent.rule" which is fired when org.cdlflex.domain.spreadsheet.event.InsertRecordEvent(). This works so far.
  5. Within the rule I perform the following steps:
  6. connect to the issue domain with: IssueDomain issueService = (IssueDomain) OsgiHelper.getResponseProxy(e, IssueDomain.class);
  7. Create a new Issue: org.openengsb.domain.issue.Issue issue = new org.openengsb.domain.issue.Issue();
  8. try to persist the issue: issueService.createIssue(issue);
  9. (8) does not work. Please see the message below. Based on the thrown exception (see below; I  caught h it with drools and printed it to the System.out) I have no idea what the problem is. 
I already checked:

The content of assembly/*/etc/issue+issue+jira-root.connector  is:
domainType=issue
connectorType=jira
property.location.root=issue/jira

This should be in accordance to the service properties in the blueprint file of the jira issues connector: 

<service-properties>
  <entry key="domain" value="issue" />
  <entry key="connector" value="jira" />
  </service-properties>
</service-properties>


Can you please provide me with some information how to resolve this issue, where to start, etc.?
Thank you very much, Andreas


Failed issuing: object is not an instance of declaring class
java.lang.IllegalArgumentException: object is not an instance of declaring class
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.openengsb.core.util.DefaultOsgiUtilsService$ServiceTrackerInvocationHandler.invoke(DefaultOsgiUtilsService.java:94)
at $Proxy94.createIssue(Unknown Source)
at org.openengsb.Rule_InsertSpreadsheetEvent_ed95a8592b20462faa1790364316bfee.defaultConsequence(Unknown Source)
at org.openengsb.Rule_InsertSpreadsheetEvent_ed95a8592b20462faa1790364316bfeeDefaultConsequenceInvokerGenerated.evaluate(Unknown Source)
at org.openengsb.Rule_InsertSpreadsheetEvent_ed95a8592b20462faa1790364316bfeeDefaultConsequenceInvoker.evaluate(Unknown Source)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1287)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1221)
at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1456)
at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:710)
at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:674)
at org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:230)
at org.openengsb.core.workflow.drools.internal.WorkflowServiceImpl.processEvent(WorkflowServiceImpl.java:124)
at org.openengsb.core.workflow.drools.internal.ForwardHandler.forwardEvent(ForwardHandler.java:55)
at org.openengsb.core.workflow.drools.internal.ForwardHandler.handleInvoke(ForwardHandler.java:48)
at org.openengsb.core.common.AbstractOpenEngSBInvocationHandler.invoke(AbstractOpenEngSBInvocationHandler.java:55)
at $Proxy80.raiseInsertEvent(Unknown Source)
at Proxy0403f07b_0d1b_49ec_99b0_e821a3c184c3.raiseInsertEvent(Unknown Source)
at org.cdlflex.connector.spreadsheet.excel.internal.MSSpreadsheetService.resetCache(MSSpreadsheetService.java:208)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:319)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.openengsb.core.services.internal.security.SecurityInterceptor.invoke(SecurityInterceptor.java:69)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at $Proxy81.resetCache(Unknown Source)
at org.cdlflex.itpm.synchronizer.SynchronizerServiceImpl.wire(SynchronizerServiceImpl.java:294)
at org.cdlflex.itpm.synchronizer.SynchronizerServiceImpl.start(SynchronizerServiceImpl.java:181)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.apache.aries.blueprint.utils.ReflectionUtils.invoke(ReflectionUtils.java:297)
at org.apache.aries.blueprint.container.BeanRecipe.invoke(BeanRecipe.java:958)
at org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:712)
at org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:824)
at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:787)
at org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:79)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:88)
at org.apache.aries.blueprint.di.RefRecipe.internalCreate(RefRecipe.java:62)
at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:106)
at org.apache.aries.blueprint.container.ServiceRecipe.createService(ServiceRecipe.java:282)
at org.apache.aries.blueprint.container.ServiceRecipe.internalGetService(ServiceRecipe.java:249)
at org.apache.aries.blueprint.container.ServiceRecipe.internalCreate(ServiceRecipe.java:146)
at org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:79)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:88)
at org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:245)
at org.apache.aries.blueprint.container.BlueprintRepository.createAll(BlueprintRepository.java:183)
at org.apache.aries.blueprint.container.BlueprintContainerImpl.instantiateEagerComponents(BlueprintContainerImpl.java:668)
at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:370)
at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:261)
at org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:259)
at org.apache.aries.blueprint.container.BlueprintExtender.modifiedBundle(BlueprintExtender.java:222)
at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:500)
at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:433)
at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$AbstractTracked.track(BundleHookBundleTracker.java:725)
at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.bundleChanged(BundleHookBundleTracker.java:463)
at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$BundleEventHook.event(BundleHookBundleTracker.java:422)
at org.apache.felix.framework.util.SecureAction.invokeBundleEventHook(SecureAction.java:1103)
at org.apache.felix.framework.util.EventDispatcher.createWhitelistFromHooks(EventDispatcher.java:695)
at org.apache.felix.framework.util.EventDispatcher.fireBundleEvent(EventDispatcher.java:483)
at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:4244)
at org.apache.felix.framework.Felix.startBundle(Felix.java:1923)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:944)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:931)
at org.apache.karaf.bundle.command.Restart.doExecute(Restart.java:48)
at org.apache.karaf.bundle.command.BundlesCommand.doExecute(BundlesCommand.java:50)
at org.apache.karaf.bundle.command.BundlesCommandWithConfirmation.doExecute(BundlesCommandWithConfirmation.java:41)
at org.apache.karaf.shell.console.AbstractAction.execute(AbstractAction.java:33)
at org.apache.karaf.shell.console.OsgiCommandSupport.execute(OsgiCommandSupport.java:39)
at org.apache.karaf.shell.commands.basic.AbstractCommand.execute(AbstractCommand.java:33)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.apache.aries.proxy.impl.ProxyHandler$1.invoke(ProxyHandler.java:54)
at org.apache.aries.proxy.impl.ProxyHandler.invoke(ProxyHandler.java:119)
at org.apache.karaf.shell.console.commands.$BlueprintCommand290938531.execute(Unknown Source)
at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:78)
at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:477)
at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:403)
at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)
at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:89)
at org.apache.karaf.shell.console.impl.jline.ConsoleImpl.run(ConsoleImpl.java:182)
at java.lang.Thread.run(Thread.java:722)
at org.apache.karaf.shell.console.impl.jline.ConsoleFactoryService$3.doRun(ConsoleFactoryService.java:102)
at org.apache.karaf.shell.console.impl.jline.ConsoleFactoryService$3$1.run(ConsoleFactoryService.java:93)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:356)
at org.apache.karaf.shell.console.impl.jline.ConsoleFactoryService$3.run(ConsoleFactoryService.java:91)

Andreas Grünwald

unread,
Sep 4, 2013, 6:33:36 AM9/4/13
to openeng...@googlegroups.com
What is interesting is that I just found out that
IssueDomain issueService = (IssueDomain) OsgiHelper.getResponseProxy(e, IssueDomain.class);
retrieves the following object:
org.cdlflex.connector.spreadsheet.excel.internal.MSSpreadsheetService@f950855

How is that possible? MSSpreadsheetService is of the domain SpreadsheetDomain.class. Its domain is spreadsheet and its connector is "spreadsheet-excel".

Felix Mayerhuber

unread,
Sep 4, 2013, 6:39:40 AM9/4/13
to openeng...@googlegroups.com
Hi,

I suppose that the error is located at exactly this problem. Are you
sure the service (MSSpreadsheetService) is exported under the correct
data? How does the pom.xml of the corresponding bundle looks like?

kind regards
Felix

Am 2013-09-04 12:33, schrieb Andreas Gr�nwald:
> What is interesting is that I just found out that
> IssueDomain issueService = (IssueDomain) OsgiHelper.getResponseProxy(e,
> IssueDomain.class);
> retrieves the following object:
> org.cdlflex.connector.spreadsheet.excel.internal.MSSpreadsheetService@f950855
>
> How is that possible? MSSpreadsheetService is of the domain
> SpreadsheetDomain.class. Its domain is spreadsheet and its connector is
> "spreadsheet-excel".
>
>
>
> On Wednesday, September 4, 2013 12:04:06 PM UTC+2, Andreas Gr�nwald wrote:
>> Hello,
>> i am trying to call a method of the Jira Issue service domain since
>> yesterday, however I am still caught with a drools rule problem. The
>> workflow is as follows:
>>
>>
>> 1. I am running a component called "synchronizerService".
>> 2. Within this component (after startup) I use the utilsService and
>> wiringService to connect to a connector of the domain "Spreadsheet" called
>> "MSSpreadsheetService".
>> 3. I call a method of the "MSSpreadsheetService" to raise a test
>> event. The event is initialized and fired.
>> 4. I created a drools rules called "InsertSpreadsheetEvent.rule" which
>> is fired when org.cdlflex.domain.spreadsheet.event.InsertRecordEvent().
>> This works so far.
>> 5. Within the rule I perform the following steps:
>> 6. connect to the issue domain with: IssueDomain issueService =
>> (IssueDomain) OsgiHelper.getResponseProxy(e, IssueDomain.class);
>> 7. Create a new Issue: org.openengsb.domain.issue.Issue issue = new
>> org.openengsb.domain.issue.Issue();
>> 8. try to persist the issue: *issueService.createIssue(issue)*;
>> 9. (8) does not work. Please see the message below. Based on the

Andreas Grünwald

unread,
Sep 4, 2013, 7:02:13 AM9/4/13
to openeng...@googlegroups.com
Hello Felix,

As it seems the location of the service is determined by using the origin context of the event. The origin information of the event however contains (origin: spreadsheet+spreadsheet+excel+root). 
What I intended to do is to get access to the issueService via telling the OsgiHelper that I want to get the service of the type "IssueDomain.class" (call IssueDomain issueService = (IssueDomain) OsgiHelper.getResponseProxy(e, IssueDomain.class)). 

Do which export information in the pom.xml are you referring do? May you please provide an example of a pom with the export information that you are talking about?
I only can tell you that the pom's of the domains (SpreadsheetDomain for MSSpreadsheetService and IssueDomain for Jira Issues) contain the following information, respectively:


pom for spreadsheet domain:

  <properties>

    <bundle.namespace>${project.artifactId}</bundle.namespace>

    <domain.name>SpreadsheetDomain</domain.name>

    <domain.name.short>spreadsheet</domain.name.short>

  </properties>

....

    <plugin>

        <groupId>org.apache.felix</groupId>

        <artifactId>maven-bundle-plugin</artifactId>

        <configuration>

          <instructions>

            <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>

            <Domain-Name>${domain.name.short}</Domain-Name>

            <Domain-Interface>${project.artifactId}.${domain.name}</Domain-Interface>

            <DomainEvents-Interface>${project.artifactId}.${domain.name}Events</DomainEvents-Interface>

            <Delegation-Annotations>true</Delegation-Annotations>

            <Provide-Models>true</Provide-Models>

          </instructions>

        </configuration>

      </plugin>


pom for issue domain:

    <plugin>

        <groupId>org.apache.felix</groupId>

        <artifactId>maven-bundle-plugin</artifactId>

        <extensions>true</extensions>

        <configuration>

          <instructions>

            <Delegation-Annotations>true</Delegation-Annotations>

            <Provide-Models>true</Provide-Models>

            <Domain-Name>issue</Domain-Name>

            <Domain-Interface>org.openengsb.domain.issue.IssueDomain</Domain-Interface>

            <DomainEvents-Interface>org.openengsb.domain.issue.IssueDomainEvents</DomainEvents-Interface>

          </instructions>

        </configuration>

      </plugin>






On Wed, Sep 4, 2013 at 12:39 PM, Felix Mayerhuber <felix.ma...@gmail.com> wrote:
Hi,

I suppose that the error is located at exactly this problem. Are you sure the service (MSSpreadsheetService) is exported under the correct data? How does the pom.xml of the corresponding bundle looks like?

kind regards
Felix


--
You received this message because you are subscribed to a topic in the Google Groups "OpenEngSB user group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/openengsb-user/U7MSsvO1unY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to openengsb-user+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Andreas Grünwald

Michael Petritsch

unread,
Sep 4, 2013, 8:41:31 AM9/4/13
to openeng...@googlegroups.com
Hello Andreas,

can you try to inject the domainservice by defining it in the .global
file instead of using the getResponseProxy method? Does that work?

br
>> openengsb-use...@googlegroups.com.
>>
>> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
>
> --
> Andreas Grünwald
> Tel.: +43 650 77 82340
>
> --
> You received this message because you are subscribed to the Google Groups
> "OpenEngSB user group" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to openengsb-use...@googlegroups.com.

Andreas Grünwald

unread,
Sep 4, 2013, 9:44:29 AM9/4/13
to openeng...@googlegroups.com
Hello Michael,
how would that look like?

I cannot define 
org.openengsb.connector.jira.internal.domain.JiraServiceImpl jiraService

directly, because the service is internal and the events are not injected automatically? 
I could use the service factory (IssueServiceInstanceFactory), was that what you meant?  But in that case I don't know how to inject the events and the instanceId. Maybe you can give me an example?

Best regards,


Michael Petritsch

unread,
Sep 4, 2013, 11:38:01 AM9/4/13
to openeng...@googlegroups.com
Hi,

please use the interface of the implementation, not the implementation.

br

Andreas Pieber

unread,
Sep 4, 2013, 11:58:36 AM9/4/13
to OpenEngSB
In addition please use only the domain interface. If there are more than one provider the context or additional routing logic is responsible for getting you the right endpoint instance; it's not the requirement of the process itself!

Kind regards,
Andreas

Andreas Grünwald

unread,
Sep 4, 2013, 12:48:18 PM9/4/13
to openeng...@googlegroups.com
Hello,
actually this is my question: How do I call an (abstract) service implementation within the drools rule context correctly? As there is no documentation about that I don't know what the correct way of doing so is? 

Does the logic automatically inject the correct service if the abstract domain is defined in the .global-file? But if so, how can one select the appropriate implementation in the case that there are more than a single implementation?


Would be great if you could provide me with an example or something similar.
Best, Andreas

Michael Petritsch

unread,
Sep 9, 2013, 6:05:24 PM9/9/13
to openeng...@googlegroups.com
Hi Andreas,

if there is just a single service implementation for a service
interface, there are some services in the cdlflex framework that you
can take as an example. e.g. the backuprestore service. Look at the
service definitions in the application-context.xml. If you define it
like that you can add this service as a reference in another bundle's
application-context.xml or you can add it to the .globals file (as I
have mentioned in my previous mail) and use it in a drools rule.

I've never tried to implement more than one service for a single
interface though, so I don't have an answer for that case.

br

Andreas Pieber

unread,
Sep 10, 2013, 12:24:38 PM9/10/13
to OpenEngSB
Hey Andi,

Have you already checked the documentation? The wiring thing is explained here [1]. [2] contains the userinterface part to wiring. Here another point for service locations [3]. [4] shows how to combine different connectors.

While the documentation isn't perfect, it's definitely a rich well of information!

Kind regards,
Andreas

[1] http://requirements.openengsb.org/confluence/display/MANUAL/contextmanagement
[2] http://requirements.openengsb.org/confluence/display/MANUAL/wiring
[3] http://requirements.openengsb.org/confluence/display/MANUAL/Wiring+Services
[4] http://requirements.openengsb.org/confluence/display/MANUAL/howTo-combineCons
Reply all
Reply to author
Forward
0 new messages