eclipse-ee4j / jaxb-ri

Jaxb RI
https://eclipse-ee4j.github.io/jaxb-ri/
BSD 3-Clause "New" or "Revised" License
205 stars 111 forks source link

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

Open Tomas-Kraus opened 9 years ago

Tomas-Kraus commented 9 years ago

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

More info here: https://github.com/jacobono/gradle-jaxb-plugin/issues/15

Affected Versions

[2.2.11]

Tomas-Kraus commented 6 years ago
Tomas-Kraus commented 9 years ago

@glassfishrobot Commented Reported by chengas123

Tomas-Kraus commented 9 years ago

@glassfishrobot Commented 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

Tomas-Kraus commented 9 years ago

@glassfishrobot Commented 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

Tomas-Kraus commented 9 years ago

@glassfishrobot Commented 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

Tomas-Kraus commented 9 years ago

@glassfishrobot Commented Was assigned to yaroska

Tomas-Kraus commented 7 years ago

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