Skip to content
This repository has been archived by the owner on Feb 5, 2019. It is now read-only.

Bad pom dependencies lead to java.lang.NoClassDefFoundError: com/sun/xml/bind/api/ErrorListener #1070

Open
glassfishrobot opened this issue Mar 9, 2015 · 6 comments

Comments

@glassfishrobot
Copy link
Contributor

Running jaxb-xjc bombs out because there's no dependency declared on jaxb-core

More info here:
scubacabra/gradle-jaxb-plugin#15

Affected Versions

[2.2.11]

@glassfishrobot
Copy link
Contributor Author

Reported by chengas123

@glassfishrobot
Copy link
Contributor Author

Was assigned to yaroska

@glassfishrobot
Copy link
Contributor Author

yaroska said:
It's not clear where is the problem.

From poms I see that:
org.glassfish.jaxb:jaxb-xjc has dependency on org.glassfish.jaxb:jaxb-core
com.sun.xml.bind:jaxb-xjc depends on org.glassfish.jaxb:jaxb-xjc

@glassfishrobot
Copy link
Contributor Author

chengas123 said:
Iaroslav, there's no dependency on com.sun.xml.bind:jaxb-core though.

Also, com.sun.xml.bind:jaxb-xjc only optionally depends on org.glassfish.jaxb:jaxb-xjc, so it's not going to pull it in. I don't think it should even have an optional dependency though. An optional dependency is typically used if com.sun.xml.bind:jaxb-xjc had code referencing classes from org.glassfish.jaxb:jaxb-xjc because you wanted to provide some extra features for it or something, but didn't want to force everyone to pull that jar into their project since only some people would use it. However, in this case, there seems to be no reference at all to any classes in that jar even for optional functionality, so it'd be better to just remove that dependency entirely.

Most build systems can show the dependency graph. E.g. if you use gradle you can run "gradle dependencies"

Here's the dependency graph with 2.2.7:

runtime - Runtime classpath for source set 'main'.
--- com.sun.xml.bind:jaxb-xjc:2.2.7
--- com.sun.xml.bind:jaxb-core:2.2.7
+--- javax.xml.bind:jaxb-api:2.2.7
--- com.sun.istack:istack-commons-runtime:2.16

Here's the dependency graph with 2.2.11:

runtime - Runtime classpath for source set 'main'.
--- com.sun.xml.bind:jaxb-xjc:2.2.11

@glassfishrobot
Copy link
Contributor Author

yaroska said:
In the version 2.2.8 we fixed JAXB maven project. Because of this new groupId: org.glassfish.jaxb was introduced.
https://jaxb.java.net/nonav/2.2.11/docs/ch02.html#a-2-2-8

The old one 'com.sun.xml.bind' shouldn't be used. It exists only for building legacy jaxb-ri.zip bundle.

Here is current dependency tree for JAXB runtime:

[INFO] — maven-dependency-plugin:2.8:tree (default-cli) @ jaxb-runtime —
[INFO] org.glassfish.jaxb:jaxb-runtime:jar:2.2.12-SNAPSHOT
[INFO] +- org.glassfish.jaxb:jaxb-core:jar:2.2.12-SNAPSHOT:compile
[INFO] | +- javax.xml.bind:jaxb-api:jar:2.2.13-b150205.1422:compile
[INFO] | +- org.glassfish.jaxb:txw2:jar:2.2.12-SNAPSHOT:compile
[INFO] | - com.sun.istack:istack-commons-runtime:jar:2.21:compile
[INFO] +- org.jvnet.staxex:stax-ex:jar:1.7.7:compile
[INFO] +- com.sun.xml.fastinfoset:FastInfoset:jar:1.2.13:compile
[INFO] - junit:junit:jar:4.11:test
[INFO] - org.hamcrest:hamcrest-core:jar:1.3:test

@glassfishrobot
Copy link
Contributor Author

This issue was imported from java.net JIRA JAXB-1070

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

No branches or pull requests

1 participant