groovy : unable to resolv class org.apache.pdfbox...

Bonjour :-)

 

When I upload this pdfbox-2.0.13.jar in Resources, it doesn't work. I cannot figure why.

My groovy script always failed on the line:

import org.apache.pdfbox.pdmodel.PDDocument

with this message 'cannot resolv class'.

I also notice that the automatic completion does not work when I am editing.

For Instance, the autocompletion should suggest several methods, like this one :

PDDocument.load()

So I upgraded my Bonita Studio and I tested a script with a completely different jar file in Resources : commons.math3-3.6.1.jar

This time, the behaviour is correct. Autocompletion and execution are fine.

 

I suspect that my pdfbox jar is not accepted, maybe because it depends on others libs but I can't find what they are. So I run the same script outside Bonita, in Visual Studio Code, and the script runs fine because Grab() gets all the dependencies needed.

commons-logging-1.2.jar , pdfbox-2.0.13.jar , fontbox-2.0.13.jar

 

But adding these libs in Resources does not solve the problem. Changing the version neither, I tried the latest 2.0.25.

What am I missing ? Is there anywhere a log file to trick the mystery bug ?

 

Thanks a lot for your help.

Hi Ioze,

In 2021.2 the dependency mechanism has been updated to use maven under the hood.
It means that you should not have to take too much care of guessing what transitive dependencies are required for a given dep.
The easiest way to add a dependency to a process (or a script used in that process) is to go in the project Overview > Extension view. Then you click on Add a custom extension > other…
From there, you can select the proper maven coordinate for your dependency (this dependency must be available on Maven Central or whatever remote repository you have configured).

So in your case, it is something like:

  • groupId: org.apache.pdfbox
  • artifactId: pdfbox
  • version: 2.0.13

Then in the process configuration of your process, navigate to Process dependencies > Other > Add... and select pdfbox-2.0.13. It should add pdfbox and its transitive dependencies in your process class-path.

HTH
Romain

Hi,

What version of Bonita are you using ?

The last one, installed on windows 10

Bonita Community Edition
Version : 2021.2
Version id : u0
Build id : 7.13.0
 

Thank you, Romain. :)

Merci Romain. It is working fine now.

Right Click on "My project" > Maven > Add Dependency