How do we call a custom java bean from a service task defined in BPMN xml file? - bpmn

I am trying to use a boundary timer event in BPMN XML file , to trigger the service task which will call out a custom java bean after some period defined in timer definition.
Below is the implemented code:
<serviceTask id="servicetask1" name="Task2"
flowable:async="true" flowable:class="com.leave.request.handler.SampleTask"></serviceTask>
<boundaryEvent id="boundarytimer1" name="Timer"
attachedToRef="tlReviewTask" cancelActivity="true">
<timerEventDefinition>
<timeDuration>PT30S</timeDuration>
</timerEventDefinition>
</boundaryEvent>
<sequenceFlow id="flow16" sourceRef="boundarytimer1"
targetRef="servicetask1"></sequenceFlow>
1.In the above, I have defined a timer boundary event having the duration of 30sec(PT30S).
2.Once the time duration is complete, the service task will be triggered thru the sequence flow.
3.In service task , have used the delegate expression which will call out Sampletask Bean , the custom Javadelegate class created in my SpringBoot Java Project.
4.The time event is getting triggered , but the Bean class is not called and getting the exception snip attached below.
<serviceTask id="servicetask1" name="Task2"
flowable:async="true" flowable:class="com.leave.request.handler.SampleTask"[enter image description here](https://i.stack.imgur.com/YSsg5.png)></serviceTask>
Tried this solution:
<serviceTask id="servicetask1" name="Task2"
flowable:async="true" flowable:delegateExpression="${sampleTask}"></serviceTask>
Used this delegateExpresssion, but still the same issue.

The screenshot of the exception shows that Flowable uses reflection (it isnot looking up a spring bean name used in an expression). It is trying to find an instantiate the class "com.leave.request.handler.SampleTask", but cannot fin it in the class path. Please double check if
the class name and package are spelled correctly and the class is in the correct package folder
the folder is part of the src folders and gets compiled
the class compiles successfully before startup and is included in the runtime
a default constructor is available and accessible

Related

Geb/Groovy : Page object class considered as a property in another when refering to with "to" option

I am new to Groovy programing and I am currently trying to test a web app with Geb and Spock on IntelliJ IDE. I wanted to try a simple script first without using Spock, that is why I use a simple main class for creating Browser and so on and run some basic tests (understand: verifying if I am at the correct page).
Everything was working well but I had a lot of page class that were melt in the same folder as my main class, modules and so on. So I decided to clean up by using packages. Here is my project folders:
src
---main
------groovy
------------app
---------------module
---------------pages
---------------templates
module folder contains the modules used in my pages
pages folder contains the actual page the browser will browse
templates folder contains some super pages class for not repeating content through pages instances.
My class Main with main method is in app folder.
So I re-run the code that was previously working well (when every source files were in the same folder) and I get an error Exception in thread "main" groovy.lang.MissingPropertyException: No such property: homePage for class: app.pages.loginPage
The line that seems to be the problem is this one (in loginPage.groovy) :
loginButton(to: homePage){$("input", id: "loginButton_submit")}
Which is in the static content of loginPage class.
I don't understand why I get this error as loginPage and homePage are in the same package. I guess I don't understand some groovy stuff here or compiling mechanics.
Here is the error messages I got :
The package is the correct one both in homePage and loginPage (they are in the same one) so the class seems to be resolved. But when running, `homePage` is considered as a static property of `loginPage`I suppose and as it is not declared in `loginPage` properties it cannot work. Here is my log :
Exception in thread "main" groovy.lang.MissingPropertyException: No such property: homePage for class: app.pages.loginPage
at groovy.lang.MetaClassImpl.invokeStaticMissingProperty(MetaClassImpl.java:1004)
at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:1859)
at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:1835)
at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:3735)
at org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:175)
at groovy.lang.Closure.getPropertyTryThese(Closure.java:312)
at groovy.lang.Closure.getPropertyOwnerFirst(Closure.java:306)
at groovy.lang.Closure.getProperty(Closure.java:295)
at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:50)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:307)
at app.pages.loginPage$__clinit__closure4.doCall(loginPage.groovy:28)...
Do you have any ideas ?
Check to see if the package your homePage belongs to was updated when you moved it from "main" to "pages":
package app.pages
class homePage extends Page {
}
If the package is incorrect or undeclared on the homePage class your loginPage will not be able to resolve it
Finally solved it thanks to this comment:
Note that by convention class names in Java and Groovy usually start with a capital letter.
All my classes where considered as variable. I still don't get why the behavior is different in default package so if anyone has a clue...
Thanks all for your help.

Access the EPartService after an RCP application has initialized

After my application initialized, I'm trying to automatically create a part within a part stack. I need the EPartService for this but I can't think of any way to properly get a hold of this service.
I've tried using the LifeCycle management to get the current IEclipseContext. However, whenever I try to access the service using the context, it's not found.
Any idea how I can do this?
You should be able to inject the EPartService in any of the defined methods in your life cycle class. However you won't be able to show a part until the application startup is complete. So use the App Startup Complete event, by adding a method like this to the life cycle class:
#Optional
#Inject
public void appStartupComplete(#UIEventTopic(UIEvents.UILifeCycle.APP_STARTUP_COMPLETE) Event event,
EPartService partService)
{
....
}

Listener in Testng

I have created a listener class in my project. Now what I have read in web there are two methods to add a listener either to your class or to testng file.
Please check in the folder structure. For now, I m using it like this in my java class but it is giving me error as in image attached:
#Listeners({Test.tes.Utils.ListenerUse.class})
From your screenshots, I understand that your test class HomeTestCases.java resides in the package Test.test.MyHomepageTestCases in src/test/java
You are trying to refer to the listener ListenerToUse.java that resides in the package Test.tes.Utilsin src/main/java.
When you use #Listeners(Test.tes.MyHomepageTestCases.MyHomepageTestCases.ListenerToUse.class)
Here you are basically telling Java to look for the listener class ListenerToUse inside Test.tes.MyHomepageTestCases.MyHomepageTestCases (as a nested class), but that's not the case because ListenerToUse is NOT a embedded class inside MyHomepageTestCases.java.
To fix the problem please do the following:
Change: #Listeners(Test.tes.MyHomepageTestCases.MyHomepageTestCases.ListenerToUse.class)
To: #Listeners(Test.tes.Utils.ListenerToUse.class)
I think the issue is you're mixing the package of your Listener, and the package of the class where you want to add it.
Your code now:
#Listeners(Test.tes.MyHomePageTestCases.MyHomePageTestCases.ListenerUse.class)
Correct package:
#Listeners(Test.tes.Utils.ListenerUse.class)
However, you've named your package "Test", which is (besides breaking Java naming conventions -> https://docs.oracle.com/javase/tutorial/java/package/namingpkgs.html) clashing with the TestNG Test class. On your screenshot, I can see that "Test" is grayed out. If you hover with your mouse over it, you'll probably see Eclipse has resolved it as "org.testng.annotations.Test". So you have two options:
Name your packages properly and try again
Expand the imports sections of your HomeTestCases class; manually add:
import Test.tes.Utils.ListenerUse;
and delete the following:
import org.testng.annotations.Test;

Windows Phone 8.1 File Picker UnauthorizedAccessException

I have a problem trying to replicate the File Picker example in link, I create a new application using a Universal Application Windows store template.
I extract the content of the class Scenario02 and create a similar one in my example. This class implements an interface called IFileOpenPickerContinuable which I extract from the class ContinuationManager and create a file in my project with the same name to implement that interface.
I don't get any compilation errors when I run the application. When the line openPicker.PickMultipleFilesAndContinue(); is executed, it throw a exception.
'UnauthorizedAccessException'(Access is denied. Exception from HRESULT: 0x80070005) exception.
In the Microsoft example they don't modify any of the manifests of the application. Do you know what can I be missing?
(Question solved in a question edit. Converted to a community wiki answer.)
The OP wrote:
Solved! The problem was trying to launch the data picker in the class constructor.

How to get a module instance in PRISM

I have a PRISM desktop app which loads modules from a directory with the help of the DirectoryModuleCatalog.
Everything is fine, except that I cannot find a way to get the instance of a loaded module.
IModuleManager and IModuleCatalog don't have a method like getInstance(ModuleInfo) or similar.
See
moduleManager.LoadModule(moduleInfo.ModuleName);
This line loads the module properly(moduleManager is of type IModuleManager), but what do I have to do next to get the actual instance of this module?
The modules are loaded on demand of the user, so I cannot register all modules at startup within the bootstrapper.
If by Module instance you mean the class that implement IModule, then you must explicitly register the instance into the container to be able to get it.
Although the aforementioned will work, you should not take that approach at all. The idea is that the module classes are specific to a particular module and should only be used for module initialization purposes.
I would place each module's Start method in a separate component (IStartable), register each component in the container with a different Id and resolve/import an IEnumerable to get all instances that have the start method.
Hope this helps