jaxb-api icon indicating copy to clipboard operation
jaxb-api copied to clipboard

Mapping of old Java EE artifacts to new Jakarta artifacts

Open sebersole opened this issue 3 years ago • 12 comments

Would be awesome if there were an actual mapping of artifacts from Java EE -> Jakarta EE.

E.g. after hours of looking I am unable to determine how to convert a build that works perfectly well with Java EE XJC, but no idea what the related Jakarta artifacts are.

Specifically having trouble with

  • org.jvnet.jaxb2_commons:jaxb2-basics:0.12.0
  • org.jvnet.jaxb2_commons:jaxb2-basics-ant:0.12.0

Though I've only gotten this far after hours of trying to track down how to achieve this in Jakarta EE.

sebersole avatar Sep 20 '21 16:09 sebersole

have you tried https://github.com/highsource/jaxb2-basics ?

lukasj avatar Sep 20 '21 18:09 lukasj

I have.

java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException

sebersole avatar Sep 20 '21 20:09 sebersole

Here are dependencies I have currently, which seems to be the closest but which leads to that above exception

    xjc 'jakarta.xml.bind:jakarta.xml.bind-api:3.0.1'
    xjc 'org.glassfish.jaxb:jaxb-runtime:3.0.1'
    xjc 'org.jvnet.jaxb2_commons:jaxb2-basics:1.11.1'
    xjc 'org.jvnet.jaxb2_commons:jaxb2-basics-ant:1.11.1'
    xjc 'org.glassfish.jaxb:jaxb-xjc:3.0.2'

sebersole avatar Sep 20 '21 20:09 sebersole

why

xjc 'org.glassfish.jaxb:jaxb-runtime:3.0.1'
xjc 'org.glassfish.jaxb:jaxb-xjc:3.0.2'

are not at the same version? I'm not saying that will help, just that it looks strange to me.

There are two things I'd check/try:

  • look at the dependency tree to see which exact version of the jaxb-xjc artifact is being used (this artifact has the same packages in javax (2.x) as well as in jakarta (3.x) versions)
  • try to add javax.xml.bind:jaxb-api:2.3.1 to your dependencies, that should resolve (hide?) the Error

lukasj avatar Sep 20 '21 20:09 lukasj

note that jaxb2-basics (formerly jaxb2-commons project at java.net) has been community driven with no involvement of the jaxb(-ri) team since its beginning - if my memory works well after those ~15 years...

lukasj avatar Sep 20 '21 20:09 lukasj

Just an oversight as I have been trying combinations. As you said, no difference.

I know its complicated, but its super frustrating to continually run into these kind of situations trying to migrate to Jakarta EE. Its not like jaxb2-basics is a super obscure, unused project.

sebersole avatar Sep 20 '21 20:09 sebersole

I agree with you. We just have to deal with current situation somehow.... There is that Eclipse Transformer project, some similar alternative from Apache but I don't think they help in this case. An option could be to backport fix for https://github.com/eclipse-ee4j/jaxb-ri/issues/1475 with reverted logic to 2.x version (EE8 branch) - add sth '-target 3.0' to generate 'jakarta'-ready code. The thing is that the code generated by plugins probably won't compile, so one would have to do some post-processing after running xjc. Just thinking loud...

lukasj avatar Sep 20 '21 21:09 lukasj

I played around and got a working version of jaxb2-basics. Actually did not really even take much change.

https://github.com/highsource/jaxb2-basics/pull/129

sebersole avatar Sep 20 '21 22:09 sebersole

Sorry when highjacking this issue, but there seems to be some expertise here about the topic.

I have projects which use the plugins from https://github.com/javaee/jaxb2-commons together with the Apache CXF XJC Plugin (https://github.com/apache/cxf-xjc-utils/tree/master/cxf-xjc-plugin). The later has been upgraded to JavaEE9 (Jakarta.*) recently. But the last commit in https://github.com/javaee/jaxb2-commons has is dated back to 2017. Is there any successor to this project which I have missed?

Update: The basics plugin in https://github.com/javaee/jaxb2-commons seems to be the predecessor of the Highsource https://github.com/highsource/jaxb2-basics plugin.

cachescrubber avatar May 25 '22 13:05 cachescrubber

I upgraded the other jaxb2-commons plugins in https://github.com/javaee/jaxb2-commons/pull/46. Actually no big changes necessary besides the obvious dependency upgrades.

cachescrubber avatar May 25 '22 14:05 cachescrubber

Hi everyone Currently working with Matt on updating highsource projects for jakarta migration Also did get remaining old plugins into jaxb-basics (issue raised by @cachescrubber )

Keep updated, release will be soon available

laurentschoelens avatar Jul 14 '23 21:07 laurentschoelens

Hi everyone Currently working with Matt on updating highsource projects for jakarta migration Also did get remaining old plugins into jaxb-basics (issue raised by @cachescrubber )

Keep updated, release will be soon available

See https://github.com/highsource/jaxb2-basics/pull/167 merged into master

laurentschoelens avatar Jul 15 '23 06:07 laurentschoelens