To prevent spam users, you can only post on this forum after registration, which is by invitation. If you want to post on the forum, please send me a mail (h DOT m DOT w DOT verbeek AT tue DOT nl) and I'll send you an invitation in return for an account.

InvocationTargetException while call of other Plugins

lubken
edited February 2011 in - Development
Hey,

I have a problem which I cannot solve since a couple of days. I try to call a Plugin, in this case the Alpha Miner just with the XLog as a parameter. I use a recently fetched Prom6 version.

I Iterate over all PluginParameterBindings with:
"for (Pair<Integer, PluginParameterBinding> plugin : context.getPluginManager().find(Plugin.class, Object.class, context.getPluginContextType(), false, false, false, XLog.class)){"

After this I try to get just the Alpha Miner with a string name equal checker: "if (plugin.getSecond().getPlugin().getName().equals("Alpha Miner")){" (in the final version I will use all Plugins applicable for certain Parameter and Return types)

According to the PluginParameterBinding javadoc I need to try to Bind the Plugin:
for (PluginParameterBinding pluginmethod:PluginParameterBinding.Factory.tryToBind(context.getPluginManager(),plugin.getSecond().getPlugin(),2,true,false,XLog.class)){
I think the for loop is at that point not necessary but anyway. The Pluginmethod which is just applicable to XLog is "2" according to my analysis. 

At this point the error occurs where i try to invoke the specified method: result = pluginmethod.invoke(context, log).getResults();

I get a "java.lang.reflect.InvocationTargetException" at the last presented line of code. I already checked that the specific method is applicable for the parameter type XLog and already checked out severl other error sources without results.

Did I misunderstand the concept of the PluginManager? Maybe a example with a working execution of another Plugin would help.

Thanks for your help and I hope I could make myself clear!

Best regards

Lukas

Comments

  • Hey Lukas,

    I would opt for the following code (where log is your XLog at hand):


    Petrinet net = context.tryToFindOrConstructFirstNamedObject(Petrinet.class, "Alpha Miner", Connection.class, "", log);


    This should give you the Petri net mined by the Alpha miner. If you're also interested in the corresponding initial marking, you could add


    Marking marking = null;
    for (InitialMarkingConnection conn : context.getConnectionManager().getConnections(InitialMarkingConnection.class, context, net)) {
        marking = conn.getObjectWithRole(InitialMarkingConnection.MARKING);
    }


    At the end, marking should be the initial marking, or null if the initial marking is not available.

    Kind regards,

    Eric Verbeek.

  • Hm,

    I'm quite sure that my post did not stop here. Apparently, it got truncated somewhere along the way. Anyways, the line  mentioned above should get you the Petri net you're after, but you might also be interested in the initial marking of that net. If so, you could use the following snippet:


    Marking initialMarking = null;
    for (InitialMarkingConnection conn : context.getConnectionManager().getConnections(InitialMarkingConnection.class, context, net)) {
        initialMarking = conn.getObjectWithRole(InitialMarkingConnection.MARKING);
    }


    At the end, initialMarking should be the initial marking, or null if it is not available.

    Cheers,

    Eric.
  • So this got truncated as well.

    There seems to be a problem with my second HR following the BLOCKQUOTE or something similar. Here's the remainder:

    At the end, initialMarking should be the initial marking, or null if it is not available.



    Cheers,



    Eric.

  • Off topic: the original post is now no longer truncated, I corrected a forum setting which caused it.

    On topic: Lukas, could you let us know if this worked???
    Joos Buijs

    Senior Data Scientist and process mining expert at APG (Dutch pension fund executor).
    Previously Assistant Professor in Process Mining at Eindhoven University of Technology
  • Thanks a lot Eric! 

    It works although I did not understand yet fully why to prefer this solution. But I check the source code and plays a little bit to find out.

    Regards

    Lukas
Sign In or Register to comment.