highsource / jaxb-tools

The most advanced JAXB2 Maven Plugin for XML Schema compilation.
Other
429 stars 99 forks source link

Java 9 support #114

Closed johnpoth closed 6 years ago

johnpoth commented 7 years ago

When using Java 9 build 156 and v0.13.1 of the plugin on Apache Camel I get:

[WARNING] Error injecting: org.jvnet.mjiip.v_2.XJC2Mojo
java.lang.IllegalAccessError: superclass access check failed: class org.jvnet.jaxb2.maven2.resolver.tools.MavenCatalogResolver (in unnamed module @0x1b5a1d85) cannot access class com.sun.org.apache.xml.internal.resolver.tools.CatalogResolver (in module java.xml) because module java.xml does not export com.sun.org.apache.xml.internal.resolver.tools to unnamed module @0x1b5a1d85
    at java.base/java.lang.ClassLoader.defineClass1(Native Method)
    at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:977)
    at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:172)
    at java.base/java.net.URLClassLoader.defineClass(URLClassLoader.java:543)
    at java.base/java.net.URLClassLoader.access$100(URLClassLoader.java:83)
    at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:451)
    at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:445)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:444)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClassFromSelf(ClassRealm.java:401)
    at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:42)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
    at java.base/java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.base/java.lang.Class.privateGetDeclaredConstructors(Class.java:3053)
    at java.base/java.lang.Class.getDeclaredConstructors(Class.java:2315)
    at com.google.inject.spi.InjectionPoint.forConstructorOf(InjectionPoint.java:245)
    at com.google.inject.internal.ConstructorBindingImpl.create(ConstructorBindingImpl.java:99)
    at com.google.inject.internal.InjectorImpl.createUninitializedBinding(InjectorImpl.java:658)
    at com.google.inject.internal.InjectorImpl.createJustInTimeBinding(InjectorImpl.java:881)
    at com.google.inject.internal.InjectorImpl.createJustInTimeBindingRecursive(InjectorImpl.java:804)
    at com.google.inject.internal.InjectorImpl.getJustInTimeBinding(InjectorImpl.java:282)
    at com.google.inject.internal.InjectorImpl.getBindingOrThrow(InjectorImpl.java:214)
    at com.google.inject.internal.InjectorImpl.getProviderOrThrow(InjectorImpl.java:1005)
    at com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.java:1037)
    at com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.java:1000)
    at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1050)
    at org.eclipse.sisu.space.AbstractDeferredClass.get(AbstractDeferredClass.java:48)
    at com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:81)
    at com.google.inject.internal.InternalFactoryToInitializableAdapter.provision(InternalFactoryToInitializableAdapter.java:53)
    at com.google.inject.internal.ProviderInternalFactory$1.call(ProviderInternalFactory.java:65)
    at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:115)
    at org.eclipse.sisu.bean.BeanScheduler$Activator.onProvision(BeanScheduler.java:176)
    at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:126)
    at com.google.inject.internal.ProvisionListenerStackCallback.provision(ProvisionListenerStackCallback.java:68)
    at com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:63)
    at com.google.inject.internal.InternalFactoryToInitializableAdapter.get(InternalFactoryToInitializableAdapter.java:45)
    at com.google.inject.internal.InjectorImpl$2$1.call(InjectorImpl.java:1015)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1091)
    at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1011)
    at org.eclipse.sisu.inject.Guice4$1.get(Guice4.java:162)
    at org.eclipse.sisu.inject.LazyBeanEntry.getValue(LazyBeanEntry.java:81)
    at org.eclipse.sisu.plexus.LazyPlexusBean.getValue(LazyPlexusBean.java:51)
    at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:263)
    at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:255)
    at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:517)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:121)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:543)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)

Work around is to set

export MAVEN_OPTS="--add-exports=java.xml/com.sun.org.apache.xml.internal.resolver.tools=ALL-UNNAMED --add-exports=java.xml/com.sun.org.apache.xml.internal.resolver=ALL-UNNAMED --add-modules java.activation"

which works. The plugin doesn't seem to support forking so I don't see another workaround.

Thanks!

nipafx commented 7 years ago

To make the setting project specific I used ${maven.projectBasedir}/.mvn/jvm.config. I needed an additional module, so it looks as follows:

--add-modules java.activation,java.xml.bind
--add-exports java.xml/com.sun.org.apache.xml.internal.resolver=ALL-UNNAMED
--add-exports java.xml/com.sun.org.apache.xml.internal.resolver.tools=ALL-UNNAMED

This is really just a workaround - I think the plugin should allow to be run in its own process so that JVM arguments can be passed to it.

ptahchiev commented 6 years ago

Yep, same exception here. Any plans when we will see this resolved?

highsource commented 6 years ago

@johnpoth @nicolaiparlog @ptahchiev

Sorry guys, I have no knowledge of Java 9 module system and no idea what's happening here and how to fix it. No idea, no plans, sorry.

ptahchiev commented 6 years ago

I believe what's happening is you depend on:

                <jaxb22.version>2.2.11</jaxb22.version>

but there's already a 2.3.0 version of JAXB which ships a jaxb-jxc-jdk9 module:

http://repo1.maven.org/maven2/org/glassfish/jaxb/jaxb-jxc-jdk9/

I believe what you should do is create a new branch of the maven plugin which declares the jdk9 dependencies and release a new version that supports jdk9.

hendriks73 commented 6 years ago

Anything to get this resolved soon, would be much appreciated. People are trying to migrate to Java9 and actually Java10 now.

patexoid commented 6 years ago

I moved to org.apache.cxf:cxf-xjc-plugin, some headache with configuration and it works fine for me

highsource commented 6 years ago

I hear you, but, as said above have zero Java 9 exp so far.

dzmitryh commented 6 years ago

as far as I understand(correct me if I'm wrong) the fix for it is already in java-9 branch according to discussion there -> https://github.com/highsource/maven-jaxb2-plugin/issues/120 so question is what blocks us to relase it ?

highsource commented 6 years ago

120 is open. Some work was done but there was a number of problems reported.

highsource commented 6 years ago

@nicolaiparlog @dzmitryh @hendriks73 @ptahchiev

Hi everyone,

I've just added the maven-jaxb23-plugin on the java-9 branch. With this plugin, the tests/java-9 by @nicolaiparlog more or less works. You still have to turn off episode generation, but schema bindings are considered.

Could you please give it a try on your projects. Thank you.

Best wishes, Alexey

nipafx commented 6 years ago

Does that mean the additional --add-exports and --add-modules are no longer necessary? I went looking for the jvm.config file I created, but couldn't find it. I assume that means it's not needed anymore. That would be great! :)

(Will give the new version a try this week or next.)

highsource commented 6 years ago

@nicolaiparlog To be honest, I have no idea. The java-9 test worked on my machine under Java 9 as it is. If don't know if this is due to my setup or it generally works. This is why I'm asking you to please give it a try.

Please also check if maven-jaxb23-plugin works under Java 8 for you. I would like to know if there are compatibility issues, would there be a need for Java <= 8 version of maven-jaxb23-plugin and Java >=9 version maven-jaxb23-plugin or would one variant suffice.

nipafx commented 6 years ago

I summarized my observations and answers to some of your questions in this comment on #120.

As I see it, this issue can be closed.

SamSuffit commented 6 years ago

java9 branch tested at work. It works fine (with episode generation set to off) Any idea of when it could be released ?

highsource commented 6 years ago

@SamSuffit See #120 let's continue the discussion there.

aznan2 commented 6 years ago

Great! Now get to fixing jaxb2-basics :)

adlmez commented 6 years ago

+1

adlmez commented 6 years ago

Thanks a lot !

highsource commented 6 years ago

@nicolaiparlog @ptahchiev @dzmitryh @hendriks73 et al.

I've just released maven-jaxb2-plugin version 0.14.0 to the Central Maven Repo. Will appear there in an hour or so.

Please test it. maven-jaxb2-plugin or maven-jaxb23-plugin should work under Java 9 as well as 1.7 and 1.8.

maven-jaxb20-plugin, maven-jaxb22-plugin, maven-jaxb22-plugin should work under 1.7 and 1.8.

Java 1.6 is no longer supported.

highsource commented 6 years ago

@aznan2 See https://github.com/highsource/jaxb2-basics/releases/tag/0.12.0

SamSuffit commented 6 years ago

Thanks a lot !

dzmitryh commented 6 years ago

Well done guys!