ndegoeij
I'm new here

Module with Executable gives ClassNotFoundException in Schedule Management

Jump to solution

Hey all,

We are working with FirstSpirit version 4.2.499.

I have created a Java class:

package nl.rijksoverheid.cis.docforsearchindex;

import ...

public class DocumentsForSearchIndexExecutable implements Executable {

   public Object execute(final Map<String, Object> stringObjectMap) throws ExecutionException {

      return execute(stringObjectMap, new PrintWriter(System.out, true), new PrintWriter(System.err, true));

   }

  

   public Object execute(final Map<String, Object> stringObjectMap, final Writer writer, final Writer writer1) throws ExecutionException {

      final Object context = stringObjectMap.get("context");

     

      final GuiScriptContext ctx = (GuiScriptContext) context;

      try {

         final DocumentsForSearchIndexScript dfsi = new DocumentsForSearchIndexScript(ctx);

      } catch (IOException e) {

         //...

      }

   }

}

I also have created a module.xml:

<module>

    <name>Documents for SearchIndex</name>

    <version>1.0</version>

    <description>FirstSpirit Test Module.</description>

    <vendor>Ordina</vendor>

    <components>

        <public>

            <name>DocumentsForSearchIndexExecutable</name>

            <class>nl.rijksoverheid.cis.docforsearchindex.DocumentsForSearchIndexExecutable</class>

        </public>

    </components>

    <resources>

        <resource scope="module">lib/fs-documentforsearchindex.jar</resource>

    </resources>

</module>

When installing the module all goes fine but when I try to execute the Executable from within the server I get ClassNotFoundExceptions:

Open schedule management of the project.

Add a new entry, with a script:

#! executable-class

DocumentsForSearchIndexExecutable(context) //--> results in a ClassNotFoundExceptions.

What is going wrong in this process? Can anyone tell what I am missing here?

I have checked the fsm and it has the jar in the lib directory as well as the classes in the right package structure. Also I have tried to change the scope of the resource to server but with no result.

Thanks in advance.

0 Kudos
1 Solution

Accepted Solutions

Hi Nando,

please try removing "(context)" and only put the (full qualified!) class name in the second line:

#!executable-class

nl.rijksoverheid.cis.docforsearchindex.DocumentsForSearchIndexExecutable

Michael

View solution in original post

0 Kudos
4 Replies
Peter_Jodeleit
Crownpeak employee

If I'm not mistaken this is a limitation of v4.2. It should work when you change the scope of the resource to "server".

Peter
0 Kudos

Hi Peter,

Thank you for your reply, however as I already mentioned in the last alinea this had no result, although I did try it once more. Also now I have tried Michaela Pahl's example (https://community.e-spirit.com/community/developer/blog/2013/03/21/a-simple-executable-example) with the source code which I found here (https://github.com/e-Spirit/Knowledgebase---SimpleExecutableExample).

This example also does not work with FirstSpirit version 4.2.499 and gives the same ClassNotFoundException (after setting the resource scope to server!) when trying to run the example from the schedule management.

Any other ideas or solutions?

0 Kudos

Hi Nando,

please try removing "(context)" and only put the (full qualified!) class name in the second line:

#!executable-class

nl.rijksoverheid.cis.docforsearchindex.DocumentsForSearchIndexExecutable

Michael

0 Kudos

Hi Michael,

That was the thing I was missing. Thank you very much, this is exactly what I was looking for.

Nando

0 Kudos