Hi Javier,
The resean of this issue is with jar file version of PDFBox.
You have to update PDFBox version to 3.x
Then replace PDFDocument.Load() with Loader.loadPDF().
If you don't want to update the version of PDFBox then you can replace
PDDocument doc = PDDocument.load(new FileInputStream("C:\\Users\\BENZJAK\\Desktop\\template.pdf")); this code with
PDDocument doc = PDDocument.load(new File("C:\\Users\\BENZJAK\\Desktop\\template.pdf"));
For List<Object> tokens = parser.getTokens(); error:
getTokens() is removed from the newer version of PDFBox.
You can use
for (Object token : parser) {
// process token
}
Error: user.setValue(this.context(), key, arr.getString(0));
try user.setValue(getContext(), key, arr.getString(0)); to resolve above issue.
otherwise define context as
Icontext context = getContext();
try user.setValue(context, key, arr.getString(0));
Thanks
Javier,
This is likely due to a library conflict in the userlib directory. This forum post has a good answer for resolving this: https://community.mendix.com/link/spaces/java-actions/questions/115161
My approach is to go through the userlib file and delete any older jar file versions and their references. Before doing so, I copy the entire userlib directory to a separate location so I can refer to it.
Hope that helps,
Mike
This issue is caused by API changes and library upgrades after moving from Mendix 10.24 → 11.x, especially in:
Your errors are not random — they are due to breaking changes in dependencies.
PDDocument.load(...) not foundsymbol: method load(FileInputStream)
In newer PDFBox versions (used in Mendix 11), PDDocument.load(InputStream) is no longer available in the same way.
Use:
PDDocument doc = Loader.loadPDF(new File("C:\\Users\\BENZJAK\\Desktop\\template.pdf"));
Import:
import org.apache.pdfbox.Loader;
PDFStreamParser.getTokens() not foundsymbol: method getTokens()
In newer PDFBox versions, getTokens() was removed/changed.
You must explicitly call parse() and then access tokens:
PDFStreamParser parser = new PDFStreamParser(page); parser.parse(); List<Object> tokens = parser.getTokens();
If getTokens() is still unavailable in your version, use:
Iterator<?> tokens = parser.getTokenIterator();
this.context() not foundsymbol: method context()
In Mendix 11, this.context() is no longer valid.
Replace:
user.setValue(this.context(), key, arr.getString(0));
with:
user.setValue(getContext(), key, arr.getString(0));
PDDocument.load(...) → use Loader.loadPDF(...)getTokens() → use parse() + getTokens() or iteratorthis.context() → replace with getContext()After migration: