Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.12 maven central version NoClassDefFoundErrors #422

Open
jstaerk opened this issue Jul 22, 2024 · 8 comments
Open

2.12 maven central version NoClassDefFoundErrors #422

jstaerk opened this issue Jul 22, 2024 · 8 comments

Comments

@jstaerk
Copy link
Collaborator

jstaerk commented Jul 22, 2024

Mustang deployed via maven throws exceptions like

java.lang.NoClassDefFoundError: org/apache/xmpbox/xml/XmpParsingException

the jar file of the validator is only 3.5 instead of 53.5mb in size and reminds very much of the uber jar discussion #297

The Class-Path manifest attribute in C:\Users\jstaerk\.m2\repository\org\mustangproject\library\2.12.0\library-2.12.0.jar referenced one or more files that do not exist: file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/slf4j-api-2.0.9.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/Saxon-HE-12.4.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/xmlresolver-5.2.2.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/httpclient5-5.1.3.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/httpcore5-h2-5.1.3.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/commons-codec-1.15.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/httpcore5-5.1.3.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/xmlresolver-5.2.2-data.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/jackson-databind-2.17.1.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/jackson-annotations-2.17.1.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/jackson-core-2.17.1.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/fop-2.9.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/fop-util-2.9.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/xmlgraphics-commons-2.9.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/fop-events-2.9.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/qdox-1.12.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/commons-io-2.11.0.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/fop-core-2.9.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/batik-anim-1.17.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/batik-css-1.17.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/batik-dom-1.17.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/batik-ext-1.17.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/batik-parser-1.17.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/batik-shared-resources-1.17.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/batik-svg-dom-1.17.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/batik-util-1.17.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/batik-constants-1.17.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/batik-i18n-1.17.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/xml-apis-ext-1.3.04.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/batik-awt-util-1.17.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/batik-bridge-1.17.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/batik-script-1.17.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/batik-xml-1.17.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/batik-extension-1.17.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/batik-gvt-1.17.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/batik-transcoder-1.17.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/batik-svggen-1.17.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/batik-codec-1.17.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/jakarta.xml.bind-api-4.0.2.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/jakarta.activation-api-2.1.3.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/angus-activation-2.0.2.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/preflight-3.0.2.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/xmpbox-3.0.2.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/pdfbox-3.0.2.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/pdfbox-io-3.0.2.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/fontbox-3.0.2.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/commons-logging-1.3.0.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/dom4j-2.1.4.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/en16931-cii2ubl-2.2.4.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/ph-commons-11.1.6.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/jsr305-3.0.2.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/ph-jaxb-11.1.6.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/ph-xml-11.1.6.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/ph-datetime-11.1.6.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/ph-cii-d16b-3.0.2.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/ph-jaxb-adapter-11.1.0.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/ph-ubl21-9.0.1.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/ph-xsds-xmldsig-3.0.0.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/ph-xsds-xades132-3.0.0.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/ph-xsds-xades141-3.0.0.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/ph-xsds-ccts-cct-schemamodule-3.0.0.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/ph-ubl22-9.0.1.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/ph-xsds-xmldsig11-3.0.0.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/ph-ubl23-9.0.1.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/ph-ubl24-9.0.1.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/jaxb-runtime-4.0.5.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/jaxb-core-4.0.5.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/txw2-4.0.5.jar,file:/C:/Users/jstaerk/.m2/repository/org/mustangproject/library/2.12.0/istack-commons-runtime-4.1.2.jar
@jstaerk jstaerk changed the title 2.12 maven central version 2.12 maven central version NoClassDefFoundErrors Jul 22, 2024
@jstaerk
Copy link
Collaborator Author

jstaerk commented Jul 22, 2024

workaround/fix? apparently as described in #297 adding the classifier in the POM

		<dependency>
			<groupId>org.mustangproject</groupId>
			<artifactId>validator</artifactId>
			<version>2.12.0</version>
			<classifier>shaded</classifier>
		</dependency>

@melo0187
Copy link

Had similar NoClassDefFoundError and specifying the shaded variant solved this issue for me, too.

In a build.gradle.kts file it would look like this:
implementation("org.mustangproject:library:2.12.0:shaded")

@hypfvieh
Copy link
Contributor

hypfvieh commented Aug 7, 2024

For me it looks like the POM of the non-shaded version is broken in 2.12.0.

When adding the non-shaded library to a project, all dependencies are missing (pdfbox, jdom etc). Looking at the POM uploaded at maven central shows, that there is not a single non-test dependency declared in the library-pom nor in the parent.

This is really weird and forces the user to define all additional dependencies manually (without knowing which are missing or which versions should be used). I fixed it in my project by taking the missing dependencies from the POM found in this repo, but I think the POM should contain the required dependencies in the next release.

@jstaerk
Copy link
Collaborator Author

jstaerk commented Aug 15, 2024

It doesnt seem to be broken, it just no longer contains transitive dependencies. Not only do I currently have no idea how to change that, I also don't know why this does not seem to have been the case since the fix for #297 was a long time way ago :-(
We need both versions. I would prefer having the shaded one being the default, however.

@hypfvieh
Copy link
Contributor

Using a (fat) shaded-jar as default is not very common and seems confusing to me.

It will cause issues when you have a JPMS compliant project. It will also be an issue if you have a bigger project (or a JEE project) where you have a lot of dependencies already in your classpath. As soon as mustang will be added, it may provide classes which are not from mustang but from mustang's dependencies conflicting with the dependencies already defined in the project (e.g. slf4j, XML libraries, PDFBox, Apache-Batik (which is also used when POI is part of the project) etc).

Therefore I would advice to keep the shaded jar as it is now: found with another classifier.

I only had a quick look at the pom's of the project. They definitely need some love and improvements. I see lots of duplicated lines (which are already defined in parent and will be inherited), plugins and the used versions and configuration can be put in PluginManagement section and only needs to be referenced in the appropriate module later on.

Maybe I find some spare time this weekend, then I would take a closer look and provide a PR for POM cleaning.

@hypfvieh
Copy link
Contributor

A bit earlier than I thought, but I opened a PR (#446) to cleanup the POMs.

@phermsdorf
Copy link

Great! Thanks @hypfvieh for providing the pull request.

I also stumbled about the missing dependencies in maven central.

Who can review and merge this PR?

Thanks, bye Peter

@hypfvieh
Copy link
Contributor

Just looked at latest release 2.13.0 in Maven Central, still all non-test dependencies missing in library artifact pom :-(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants