Forum Discussion
Java MIP SDK 1.17.154: commitAsync() TemplateNotFoundError (C# OK; Java fails Win & Ubuntu)
TL;DR
- Java SDK 1.17.154: calling setLabel() then commitAsync() fails with TemplateNotFoundError (TemplateId=2ea3c830-...).
- Same label/code works on Java 1.16.x and C# 1.17.154.
- Policy cache cleared, templates/labels verified, token/tenant checked—issue persists.
Environment
- SDK (Java): 1.16.x (OK), 1.17.154 (FAIL)
- SDK (C#): 1.17.154 (OK)
- OS (Java): Windows 10/11 (win32 build), Ubuntu 20.04 / 22.04 / 24.04
- Java: Corretto/OpenJDK 17.0.16 (x64)
- Service/Tenant: Microsoft Purview Information Protection
- Auth: (e.g., user delegated token / app-only token)
Code Snippet (Java)
// Label apply options
LabelingOptions labelingOptions = new LabelingOptions();
labelingOptions.setAssignmentMethod(AssignmentMethod.PRIVILEGED);
labelingOptions.setDowngradeJustified(true);
labelingOptions.setJustificationMessage("Label Apply");
// Get label
Label label = fileEngine.getLabelById(labelId);
// Apply label (no explicit template handling)
fileHandler.setLabel(label, labelingOptions, new ProtectionSettings());
// Commit
File workFile = new File(domainFolder, UidUtil.makeUid());
CompletableFuture<Boolean> commitFuture = fileHandler.commitAsync(workFile.getAbsolutePath());
commitFuture.get(); // <-- Throws TemplateNotFoundError on 1.17.154
Stack trace excerpt:
Caused by: com.microsoft.informationprotection.internal.gen.Error: TemplateNotFoundError:
Could not find template with id: 2ea3c830-5a0e-4eea-b48b-c72186d453c0, BadInputError.Code=General,
CorrelationId=42ffaad4-3a0f-4986-ba9d-b5a79c5fd076 (ProtectionEngine),
CorrelationId=16819f70-e419-473f-9895-c756f3dd5e4b (FileHandler)
at com.microsoft.informationprotection.internal.gen.SdkWrapperJNI.SwigDirector_FileHandler_Observer_OnCommitFailure(SdkWrapperJNI.java:2688)
Expected Behavior
setLabel() should apply the label (and its protection) and commit successfully, as it does in Java 1.16 and C# 1.17.154.
Actual Behavior
commitAsync() fails with TemplateNotFoundError for the GUID referenced by the label’s ApplyProtectionAction.
What I’ve Tried
- Policy/cache refresh: Deleted %LOCALAPPDATA%\Microsoft\MSIP\ / ~/.mip/, reloaded engine.
- Template/label verification: Confirmed existence and publish scope in Purview portal & via PowerShell/Graph.
- Label actions check: policyEngine.getLabelActions(labelId) shows an ApplyProtectionAction with that GUID.
- Token/tenant sanity check: Correct scopes and same tenant.
- Rollback test: Java 1.16 works; C# 1.17.154 works.
Questions
- Any breaking change in Java 1.17 regarding how protection templates are resolved during setLabel()?
- Is this a known issue specific to Java SDK 1.17.154 (win32 & Ubuntu 20/22/24 builds)?
- Should we now explicitly use ProtectionDescriptor / SetProtection() in Java?
- Can someone review the service logs using the CorrelationIds above?
Happy to provide additional logs, PowerShell/Graph queries, or action dumps if needed. Thanks!
2 Replies
- johnaveryCopper Contributor
I had this same problem with v1.17.137 in C#. I tried upgrading to 1.17.154 as you suggested, but to no avail. I even tried latest version 1.17.158 as of this writing, but the issue remains. I had to roll back to version 1.16.159 to get things working again. It seems this behavior was introduced in 1.17.x. On my end, I get this error when attempting to apply a label to a file that has an encrypted protection template associated with it. I hope someone on the MIP SDK team sees this - if this is not fixed, I'll be unable to upgrade past v1.16.159. Please help!
- johnaveryCopper Contributor
I ran into this same problem in C# w/ version 1.17.137. Upgraded to 1.17.154 and 1.17.158 and the issue is still there Had to roll back to 1.16.159 to get around it. The problem occurs when attempting to commit a label to a file, when that label has an encrypted protection template applied to it. Seems like a breaking change may have been introduced in 1.17.x somewhere in the C++ code. I didn't see any mention of a change in protection behavior in the release notes for 1.17.x. I hope someone on the SDK team catches and fixes this, or I'll be unable to upgrade my package past 1.16.159. Please help!