Uploaded image for project: 'Forge'
  1. Forge
  2. FORGE-1199

Cannot use JAXB inside a plugin

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Critical Critical
    • 2.8.0.Final
    • 1.4.0.Final, 2.7.2.Final
    • Furnace (Container)
    • None

      I need to unmarshal some XML using JAXB.

      If I try to add this dependency:

      <dependency>
      <groupId>com.sun.xml.bind</groupId>
      <artifactId>jaxb-xjc</artifactId>
      <version>2.2.1</version>
      <scope>compile</scope>
      <exclusions>
      <exclusion>
      <groupId>com.sun.xml.bind</groupId>
      <artifactId>jaxb-impl</artifactId>
      </exclusion>
      </exclusions>
      </dependency>

      and then to create a JAXB Context:

      final JAXBContext context = JAXBContext.newInstance(Model.class);

      then I got an exception when launching the plugin:

      javax.xml.bind.JAXBException

      • with linked exception:
        [java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory from [Module "it.xxxxxxx.forge.prova-plugin:1.0.0-SNAPSHOT-c1d512df-2daa-4ebe-ae7a-154e102bb88d" from local module loader @15aaf0b3 (roots: /Applications/sviluppo/jboss/forge-distribution-1.4.0.Final/modules,/Users/ictlm1/.forge/plugins,/Users/ictlm1/Documents/progetti/forge)]]
        at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:187)
        at javax.xml.bind.ContextFinder.find(ContextFinder.java:376)
        at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:574)
        at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:522)
        at it.xxx.forge.parser.Parser.parse(Parser.java:17)
        at it.xxx.forge.forge.CreateEntitiesPlugin.parse(CreateEntitiesPlugin.java:19)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.jboss.forge.shell.command.Execution.perform(Execution.java:160)
        ...
        ...
        Caused by: java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory from [Module "it.esselunga.forge.prova-plugin:1.0.0-SNAPSHOT-c1d512df-2daa-4ebe-ae7a-154e102bb88d" from local module loader @15aaf0b3 (roots: /Applications/sviluppo/jboss/forge-distribution-1.4.0.Final/modules,/Users/ictlm1/.forge/plugins,/Users/ictlm1/Documents/progetti/forge)]
        at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
        at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
        at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
        at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
        at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
        at javax.xml.bind.ContextFinder.safeLoadClass(ContextFinder.java:481)
        at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:185)
        ... 41 more

      ContextFactory is part of rt.jar with is bundled with the JDK, how can I tell the ModuleClassLoader to let me load it ??

              rhn-support-ggastald George Gastaldi
              luca.masini_jira Luca Masini (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: