FAILURE: Build failed with an exception (version 11.6.3)

0
I have this problem:C:\Mendix\Mendix-Batcom-batcom-version-11\javasource\bpoc\actions\TempMain.java:27: error: cannot find symbol PDDocument doc = PDDocument.load(new FileInputStream("C:\\Users\\BENZJAK\\Desktop\\template.pdf")); ^ symbol: method load(FileInputStream) location: class PDDocumentC:\Mendix\Mendix-Batcom-batcom-version-11\javasource\bpoc\actions\TempMain.java:37: error: cannot find symbol List<Object> tokens = parser.getTokens(); ^ symbol: method getTokens() location: variable parser of type PDFStreamParserC:\Mendix\Mendix-Batcom-batcom-version-11\javasource\mb_corporatedirectory\actions\Java_populateTempUser.java:57: error: cannot find symbol user.setValue(this.context(), key, arr.getString(0)); ^ symbol: method context()Note: Some input files use or override a deprecated API.Note: Recompile with -Xlint:deprecation for details.Note: Some input files use unchecked or unsafe operations.Note: Recompile with -Xlint:unchecked for details.3 errorsFAILURE: Build failed with an exception.* What went wrong:Execution failed for task ':compile'.> Compilation failed; see the compiler error output for details.* Try:> Run with --scan to get full insights.BUILD FAILED in 3sThis problem appeared when trying to compile the project migrated from version 10.24.13.
asked
3 answers
2

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

answered
0

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

answered
0

This issue is caused by API changes and library upgrades after moving from Mendix 10.24 → 11.x, especially in:

  • Apache PDFBox
  • Mendix Java API (IContext usage)

Your errors are not random — they are due to breaking changes in dependencies.

1. PDDocument.load(...) not found

symbol: method load(FileInputStream)

In newer PDFBox versions (used in Mendix 11), PDDocument.load(InputStream) is no longer available in the same way.

Fix:

Use:


PDDocument doc = Loader.loadPDF(new File("C:\\Users\\BENZJAK\\Desktop\\template.pdf"));

Import:


import org.apache.pdfbox.Loader;

2. PDFStreamParser.getTokens() not found

symbol: method getTokens()

In newer PDFBox versions, getTokens() was removed/changed.

Fix:

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();

3. this.context() not found

symbol: method context()

In Mendix 11, this.context() is no longer valid.

Fix:

Replace:


user.setValue(this.context(), key, arr.getString(0));

with:


user.setValue(getContext(), key, arr.getString(0));

Why this happens

  • Mendix 11 upgraded internal libraries (like PDFBox)
  • Some methods were removed or renamed
  • Java action templates were slightly updated (context handling)

  • PDDocument.load(...) → use Loader.loadPDF(...)
  • getTokens() → use parse() + getTokens() or iterator
  • this.context() → replace with getContext()

After migration:

  • Review all custom Java actions
  • Check third-party library changes (especially PDFBox)
  • Rebuild imports if needed


answered