title: java.lang.NoSuchMethodException: sun.misc.Unsafe.defineClass(java.lang.String,[B,int,int,java.lang.ClassLoader,java.security.ProtectionDomain)
body: <p>I am trying to update my SpringBoot maven project to Java 17.</p>
  <pre><code>&lt;maven.compiler.source&gt;17&lt;/maven.compiler.source&gt;
  &lt;maven.compiler.target&gt;17&lt;/maven.compiler.target&gt;
  </code></pre>
  <p><a href="https://i.stack.imgur.com/B058n.png" rel="noreferrer"><img src="https://i.stack.imgur.com/B058n.png" alt="enter image description here" /></a></p>
  <p>I had working maven-jaxb2-plugin plugin defined which created java classes successfully from XSD files.</p>
  <pre><code>&lt;plugin&gt;
      &lt;groupId&gt;org.jvnet.jaxb2.maven2&lt;/groupId&gt;
      &lt;artifactId&gt;maven-jaxb2-plugin&lt;/artifactId&gt;
      &lt;version&gt;0.14.0&lt;/version&gt;
      &lt;executions&gt;
          &lt;execution&gt;
              &lt;id&gt;my_schema&lt;/id&gt;
              &lt;phase&gt;generate-sources&lt;/phase&gt;
              &lt;goals&gt;
                  &lt;goal&gt;generate&lt;/goal&gt;
              &lt;/goals&gt;
              &lt;configuration&gt;
                  &lt;schemaDirectory&gt;src/main/resources/my/files&lt;/schemaDirectory&gt;
                  &lt;schemaIncludes&gt;
                      &lt;include&gt;*.xsd&lt;/include&gt;
                  &lt;/schemaIncludes&gt;
                  &lt;bindingDirectory&gt;src/main/resources/my/files&lt;/bindingDirectory&gt;
                  &lt;bindingIncludes&gt;
                      &lt;include&gt;bindings.xml&lt;/include&gt;
                  &lt;/bindingIncludes&gt;
                  &lt;args&gt;
                      &lt;arg&gt;-extension&lt;/arg&gt;
                      &lt;arg&gt;-Xnamespace-prefix&lt;/arg&gt;
                  &lt;/args&gt;
              &lt;/configuration&gt;
          &lt;/execution&gt;
      &lt;/executions&gt;
  &lt;/plugin&gt;
  </code></pre>
  <p>But since the upgrade of java and the plugin I cannot do it.</p>
  <p>I definied the necessary dependencies for the plugin:</p>
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;com.sun.xml.bind&lt;/groupId&gt;
      &lt;artifactId&gt;jaxb-core&lt;/artifactId&gt;
      &lt;version&gt;3.0.2&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;javax.xml.bind&lt;/groupId&gt;
      &lt;artifactId&gt;jaxb-api&lt;/artifactId&gt;
      &lt;version&gt;2.3.1&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;com.sun.xml.bind&lt;/groupId&gt;
      &lt;artifactId&gt;jaxb-impl&lt;/artifactId&gt;
      &lt;version&gt;3.0.2&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;javax.activation&lt;/groupId&gt;
      &lt;artifactId&gt;activation&lt;/artifactId&gt;
      &lt;version&gt;1.1.1&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;jakarta.xml.bind&lt;/groupId&gt;
      &lt;artifactId&gt;jakarta.xml.bind-api&lt;/artifactId&gt;
      &lt;version&gt;3.0.1&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  <p>But I still receive an unknown error during maven build:</p>
  <pre><code>Oct 19, 2021 10:07:06 PM com.sun.xml.bind.v2.runtime.reflect.opt.Injector &lt;clinit&gt;
  SEVERE: null
  java.security.PrivilegedActionException: java.lang.NoSuchMethodException: sun.misc.Unsafe.defineClass(java.lang.String,[B,int,int,java.lang.ClassLoader,java.security.ProtectionDomain)
      at java.base/java.security.AccessController.doPrivileged(AccessController.java:573)
      at com.sun.xml.bind.v2.runtime.reflect.opt.Injector.&lt;clinit&gt;(Injector.java:197)
      at com.sun.xml.bind.v2.runtime.reflect.opt.AccessorInjector.prepare(AccessorInjector.java:81)
      at com.sun.xml.bind.v2.runtime.reflect.opt.OptimizedAccessorFactory.get(OptimizedAccessorFactory.java:179)
      at com.sun.xml.bind.v2.runtime.reflect.Accessor$FieldReflection.optimize(Accessor.java:285)
      at com.sun.xml.bind.v2.runtime.reflect.TransducedAccessor$CompositeTransducedAccessorImpl.&lt;init&gt;(TransducedAccessor.java:235)
      at com.sun.xml.bind.v2.runtime.reflect.TransducedAccessor.get(TransducedAccessor.java:175)
      at com.sun.xml.bind.v2.model.impl.RuntimeClassInfoImpl.calcTransducer(RuntimeClassInfoImpl.java:245)
      at com.sun.xml.bind.v2.model.impl.RuntimeClassInfoImpl.getTransducer(RuntimeClassInfoImpl.java:219)
      at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.createTransducer(RuntimeModelBuilder.java:145)
      at com.sun.xml.bind.v2.model.impl.SingleTypePropertyInfoImpl.getTransducer(SingleTypePropertyInfoImpl.java:140)
      at com.sun.xml.bind.v2.model.impl.RuntimeAttributePropertyInfoImpl.link(RuntimeAttributePropertyInfoImpl.java:78)
      at com.sun.xml.bind.v2.model.impl.ClassInfoImpl.link(ClassInfoImpl.java:1272)
      at com.sun.xml.bind.v2.model.impl.RuntimeClassInfoImpl.link(RuntimeClassInfoImpl.java:197)
      at com.sun.xml.bind.v2.model.impl.ModelBuilder.link(ModelBuilder.java:454)
      at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.link(RuntimeModelBuilder.java:133)
      at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:469)
      at com.sun.xml.bind.v2.runtime.JAXBContextImpl.&lt;init&gt;(JAXBContextImpl.java:303)
      at com.sun.xml.bind.v2.runtime.JAXBContextImpl.&lt;init&gt;(JAXBContextImpl.java:139)
      at com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1156)
      at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:165)
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
      at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.base/java.lang.reflect.Method.invoke(Method.java:568)
      at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:297)
      at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:286)
      at javax.xml.bind.ContextFinder.find(ContextFinder.java:409)
      at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:721)
      at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:662)
      at com.sun.tools.xjc.reader.xmlschema.bindinfo.BindInfo.getCustomizationContext(BindInfo.java:336)
      at com.sun.tools.xjc.reader.xmlschema.bindinfo.BindInfo.getCustomizationUnmarshaller(BindInfo.java:362)
      at com.sun.tools.xjc.reader.xmlschema.bindinfo.AnnotationParserFactoryImpl$1.&lt;init&gt;(AnnotationParserFactoryImpl.java:85)
      at com.sun.tools.xjc.reader.xmlschema.bindinfo.AnnotationParserFactoryImpl.create(AnnotationParserFactoryImpl.java:84)
      at com.sun.xml.xsom.impl.parser.NGCCRuntimeEx.createAnnotationParser(NGCCRuntimeEx.java:401)
      at com.sun.xml.xsom.impl.parser.state.annotation.action0(annotation.java:89)
      at com.sun.xml.xsom.impl.parser.state.annotation.enterElement(annotation.java:114)
      at com.sun.xml.xsom.impl.parser.state.NGCCRuntime.sendEnterElement(NGCCRuntime.java:422)
      at com.sun.xml.xsom.impl.parser.state.NGCCHandler.spawnChildFromEnterElement(NGCCHandler.java:114)
      at com.sun.xml.xsom.impl.parser.state.Schema.enterElement(Schema.java:317)
      at com.sun.xml.xsom.impl.parser.state.NGCCRuntime.sendEnterElement(NGCCRuntime.java:422)
      at com.sun.xml.xsom.impl.parser.state.NGCCHandler.revertToParentFromEnterElement(NGCCHandler.java:151)
      at com.sun.xml.xsom.impl.parser.state.foreignAttributes.enterElement(foreignAttributes.java:91)
      at com.sun.xml.xsom.impl.parser.state.NGCCRuntime.sendEnterElement(NGCCRuntime.java:422)
      at com.sun.xml.xsom.impl.parser.state.NGCCHandler.spawnChildFromEnterElement(NGCCHandler.java:114)
      at com.sun.xml.xsom.impl.parser.state.Schema.enterElement(Schema.java:229)
      at com.sun.xml.xsom.impl.parser.state.NGCCRuntime.sendEnterElement(NGCCRuntime.java:422)
      at com.sun.xml.xsom.impl.parser.state.Schema.enterElement(Schema.java:273)
      at com.sun.xml.xsom.impl.parser.state.NGCCRuntime.sendEnterElement(NGCCRuntime.java:422)
      at com.sun.xml.xsom.impl.parser.state.Schema.enterElement(Schema.java:309)
      at com.sun.xml.xsom.impl.parser.state.NGCCRuntime.sendEnterElement(NGCCRuntime.java:422)
      at com.sun.xml.xsom.impl.parser.state.Schema.enterElement(Schema.java:293)
      at com.sun.xml.xsom.impl.parser.state.NGCCRuntime.sendEnterElement(NGCCRuntime.java:422)
      at com.sun.xml.xsom.impl.parser.state.Schema.enterElement(Schema.java:221)
      at com.sun.xml.xsom.impl.parser.state.NGCCRuntime.sendEnterElement(NGCCRuntime.java:422)
      at com.sun.xml.xsom.impl.parser.state.Schema.enterElement(Schema.java:257)
      at com.sun.xml.xsom.impl.parser.state.NGCCRuntime.startElement(NGCCRuntime.java:263)
      at java.xml/org.xml.sax.helpers.XMLFilterImpl.startElement(XMLFilterImpl.java:539)
      at com.sun.tools.xjc.util.SubtreeCutter.startElement(SubtreeCutter.java:108)
      at com.sun.tools.xjc.reader.ExtensionBindingChecker.startElement(ExtensionBindingChecker.java:150)
      at java.xml/org.xml.sax.helpers.XMLFilterImpl.startElement(XMLFilterImpl.java:539)
      at com.sun.tools.xjc.reader.xmlschema.parser.IncorrectNamespaceURIChecker.startElement(IncorrectNamespaceURIChecker.java:128)
      at java.xml/org.xml.sax.helpers.XMLFilterImpl.startElement(XMLFilterImpl.java:539)
      at com.sun.tools.xjc.reader.xmlschema.parser.CustomizationContextChecker.startElement(CustomizationContextChecker.java:193)
      at java.xml/org.xml.sax.helpers.XMLFilterImpl.startElement(XMLFilterImpl.java:539)
      at com.sun.tools.xjc.reader.internalizer.DOMForestScanner$LocationResolver.startElement(DOMForestScanner.java:147)
      at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:244)
      at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:281)
      at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:250)
      at com.sun.xml.bind.unmarshaller.DOMScanner.scan(DOMScanner.java:127)
      at com.sun.tools.xjc.reader.internalizer.DOMForestScanner.scan(DOMForestScanner.java:92)
      at com.sun.tools.xjc.reader.internalizer.DOMForestScanner.scan(DOMForestScanner.java:100)
      at com.sun.tools.xjc.reader.internalizer.DOMForestParser.parse(DOMForestParser.java:104)
      at com.sun.tools.xjc.ModelLoader$XMLSchemaParser.parse(ModelLoader.java:251)
      at com.sun.xml.xsom.impl.parser.NGCCRuntimeEx.parseEntity(NGCCRuntimeEx.java:381)
      at com.sun.xml.xsom.impl.parser.ParserContext.parse(ParserContext.java:128)
      at com.sun.xml.xsom.parser.XSOMParser.parse(XSOMParser.java:171)
      at com.sun.xml.xsom.parser.XSOMParser.parse(XSOMParser.java:160)
      at com.sun.tools.xjc.ModelLoader.createXSOM(ModelLoader.java:516)
      at com.sun.tools.xjc.ModelLoader.loadXMLSchema(ModelLoader.java:360)
      at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:162)
      at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:117)
      at org.jvnet.mjiip.v_2_3.XJC23Mojo.loadModel(XJC23Mojo.java:50)
      at org.jvnet.mjiip.v_2_3.XJC23Mojo.doExecute(XJC23Mojo.java:40)
      at org.jvnet.mjiip.v_2_3.XJC23Mojo.doExecute(XJC23Mojo.java:28)
      at org.jvnet.jaxb2.maven2.RawXJC2Mojo.doExecute(RawXJC2Mojo.java:478)
      at org.jvnet.jaxb2.maven2.RawXJC2Mojo.execute(RawXJC2Mojo.java:320)
      at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
      at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
      at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
      at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
      at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
      at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
      at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
      at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
      at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
      at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
      at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
      at org.apache.maven.cli.MavenCli.execute(MavenCli.java:957)
      at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:289)
      at org.apache.maven.cli.MavenCli.main(MavenCli.java:193)
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
      at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.base/java.lang.reflect.Method.invoke(Method.java:568)
      at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
      at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
      at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
      at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)
      at org.codehaus.classworlds.Launcher.main(Launcher.java:47)
  Caused by: java.lang.NoSuchMethodException: sun.misc.Unsafe.defineClass(java.lang.String,[B,int,int,java.lang.ClassLoader,java.security.ProtectionDomain)
      at java.base/java.lang.Class.getMethod(Class.java:2227)
      at com.sun.xml.bind.v2.runtime.reflect.opt.Injector$3.run(Injector.java:201)
      at com.sun.xml.bind.v2.runtime.reflect.opt.Injector$3.run(Injector.java:197)
      at java.base/java.security.AccessController.doPrivileged(AccessController.java:569)
      ... 109 more
  </code></pre>
  <p>And I cannot find any useful tipp on the web. Can anyone help me how to fix this issue?</p>