Plugin: ClassNotFoundException: org.tukaani.xz.FilterOptions

Hello,

We have a plugin we wrote ourselves to check the attachments uploaded to a Jira ticket. It can currently handle ZIP files, and now I wanted to extend it to include 7zip.
To do this, I am using the dependency “org.apache.commons/commons-compress,” which in turn requires “org.tukaani/xz”.

<dependency>
 <groupId>org.apache.commons</groupId>
 <artifactId>commons-compress</artifactId>
 <version>1.27.1</version>
 <scope>provided</scope>
</dependency>
<dependency>
 <groupId>org.tukaani</groupId>
 <artifactId>xz</artifactId>
 <version>1.10</version>
 <scope>compile</scope>
</dependency>

Setting the scope of the dependency “org.tukaani/xz” to “provided” did not help either. However, the packages were definitely included in the actual jar, regardless of which scope I used.

I have also integrated this, but I am getting the following error message from Jira

java.lang.ClassNotFoundException: org.tukaani.xz.FilterOptions
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1353)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1162)
at org.apache.commons.compress.archivers.sevenz.Coders.<clinit>(Coders.java:204)
at org.apache.commons.compress.archivers.sevenz.SevenZFile.buildDecoderStack(SevenZFile.java:589)
at org.apache.commons.compress.archivers.sevenz.SevenZFile.reopenFolderInputStream(SevenZFile.java:1588)
at org.apache.commons.compress.archivers.sevenz.SevenZFile.buildDecodingStream(SevenZFile.java:649)
at org.apache.commons.compress.archivers.sevenz.SevenZFile.getNextEntry(SevenZFile.java:866)

I also tried adding the packages from “tukaani” to the export and import settings. I tried several different spellings. But that didn’t help at all.

<!-- Add package to export here -->
<Export-Package>
 org.tukaani.xz*
</Export-Package>

<!-- Add package import here -->
<Import-Package>
 org.tukaani.xz*,
 *;resolution:=optional
</Import-Package>

And when I look at the OSGI control, the packages are also pulled during import and export.

Does anyone have any idea what else I can do?
I have some experience with Spring, but not in depth.

I have resolved my issues.
I am unable to fully explain why it is now functioning and was not previously.
I adjusted the dependencies to

<dependency>
	<groupId>org.apache.commons</groupId>
	<artifactId>commons-compress</artifactId>
	<version>1.27.1</version>
	<scope>compile</scope>
	<exclusions>
		<exclusion>
			<groupId>org.apache.commons</groupId>
			<artifactId>commons-lang3</artifactId>
		</exclusion>
		<exclusion>
			<groupId>commons-codec</groupId>
			<artifactId>commons-codec</artifactId>
		</exclusion>
	</exclusions>
</dependency>
<dependency>
	<groupId>commons-io</groupId>
	<artifactId>commons-io</artifactId>
	<version>2.20.0</version>
	<scope>provided</scope>
</dependency>
<dependency>
	<groupId>org.tukaani</groupId>
	<artifactId>xz</artifactId>
	<version>1.10</version>
	<scope>compile</scope>
</dependency>

And as in, I retrieve the “SevenZFile” objects on

SevenZFile archiveFile = SevenZFile.builder().setFile("FilePath").get()
1 Like