Facing Java Compile Issue while running

0
javasource\communitycommons\Misc.java:643: error: incompatible types: List<RandomAccessRead> cannot be converted to List<InputStream> mergePdf.addSources(sources); ^javasource\communitycommons\StringUtils.java:231: error: cannot find symbol return IOUtils.toString(BOMInputStream.builder().setInputStream(inputStream).get(), charset); ^ symbol: method builder() location: class BOMInputStreammain\javasource\saml20\implementation\delegation\XPathExpressionPool.java:81: warning: [removal] finalize() in Object has been deprecated and marked for removal protected void finalize() throws Throwable { ^ 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. Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output 2 errors 1 warningFAILURE: 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 9s
asked
2 answers
1

This is not an issue with java library content - you don't want to edit java libraries to correct this. This is an issue with conflicting jar files in the userlib directory of your app. To resolve this, I usually:

  • In Studio Pro, select Show App Directory in Explorer from the App menu
  • In the popup window, open the Userlib directory
  • Look for files that have the same name, but different version numbers at the end of the file
  • Delete all but the most recent version number (and any RequiredLib files that point to older versions of a file)
  • Once you've done that, try to restart your app and see if the error is resolved.

Hope that helps,

Mike


P.S. here is a forum post with additional information and a different approach to resolving these kinds of errors https://community.mendix.com/link/spaces/java-actions/questions/115161

answered
0

This looks more like a library/version conflict than an actual logic issue in Misc.java.


From the errors:

  • BOMInputStream.builder() not found usually means the commons-io version in your project is older than the one expected by the current CommunityCommons code.
  • mergePdf.addSources(sources) failing with List<RandomAccessRead> cannot be converted to List<InputStream> points to a PDFBox API mismatch, again suggesting incompatible jar versions in userlib or vendorlib. This is consistent with CommunityCommons compile issues reported after module/library upgrades.


So instead of directly editing javasource\communitycommons\Misc.java first, I would suggest:

  1. check userlib and vendorlib for duplicate or old jars
  2. make sure only the correct version of commons-io is present
  3. remove obsolete conflicting jars left by older module versions
  4. clean deployment / rebuild the app


There is already a Mendix Community report for the same BOMInputStream.builder() error, and the accepted answer was to remove obsolete jars such as old commons-io and related dependencies from userlib. Another answer also mentions that other modules like SCIM can bring conflicting versions.

answered