4

I am trying the sample JAXB Maven project with jvnet maven-jaxb2-plugin from GitHub https://github.com/highsource/maven-jaxb2-plugin/releases. I am using the latest version 0.13.0 and downloaded maven-jaxb2-plugin-sample-jaxbplugins-0.13.0-maven-src.zip

I am successful in running the mvn clean install via command line. But when I import it into Eclipse Luna, I got an error message like this:

Execution default of goal org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.13.0:generate failed: A required class was missing while executing org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.13.0:generate: com/sun/xml/bind/api/ErrorListener

It is interesting that I can still use the Maven tool to run as Maven install and get the generated classes. But the error message is there annoying me. Is that some Eclipse bug or what? Please help.

This is the core part of the pom.xml

<dependencies>
    <dependency>
        <groupId>org.glassfish.jaxb</groupId>
        <artifactId>jaxb-runtime</artifactId>
        <version>2.2.11</version>
    </dependency>
    <dependency>
        <groupId>org.jvnet.jaxb2_commons</groupId>
        <artifactId>jaxb2-basics-runtime</artifactId>
        <version>0.9.0</version>
    </dependency>
</dependencies>
<build>
    <defaultGoal>install</defaultGoal>
    <plugins>
    <plugin>
        <groupId>org.jvnet.jaxb2.maven2</groupId>
        <artifactId>maven-jaxb2-plugin</artifactId>
        <version>0.13.0</version>
        <executions>
            <execution>
                <goals>
                    <goal>generate</goal>
                </goals>
                <configuration>
                    <args>
                    <arg>-XtoString</arg>
                    <arg>-Xequals</arg>
                    <arg>-XhashCode</arg>
                    <arg>-Xcopyable</arg>
                    </args>
                    <plugins>
                    <plugin>
                    <groupId>org.jvnet.jaxb2_commons</groupId>
                    <artifactId>jaxb2-basics</artifactId>
                    <version>0.9.0</version>
                    </plugin>
                    </plugins>
                </configuration>
            </execution>
        </executions>
    </plugin>
    </plugins>
</build>
lexicore
  • 42,748
  • 17
  • 132
  • 221
dunfa
  • 509
  • 1
  • 10
  • 19

3 Answers3

5

I was able to get rid of those "Problems" by adding the following line into my eclipse ini like described in:

http://diggingthroughcode.blogspot.de/2016/05/trouble-with-maven-jaxb2-plugin-and.html

-vm
C:\Program Files\Java\jdk1.8.0_92\bin\javaw.exe

after pressing Alt+F5 (Update Project) everything was ok.

my setup java: 1.8.0_92 / eclipse: Luna SR2 (4.4.2) = STS 3.7.0

Del Pedro
  • 1,216
  • 12
  • 32
2

Please do a Run as > Maven build... > Goals: clean generate-resources > Debug Output > Run and post the full log (pastebin or whatever).

I suspect you have some outdated JDK but it's hard to tell. I can't reproduce this with Ecliplse Luna 4.4.0 and Java 1.7.0_51.

Disclaimer: I'm the author of the maven-jaxb2-plugin.

lexicore
  • 42,748
  • 17
  • 132
  • 221
  • Thank you. I am actually using Ecliplse Luna 4.4.1 and Java 1.8.0_40 And here is the link of pastebin http://pastebin.com/4ky2GJs7 – dunfa Dec 04 '15 at 21:50
  • @ lexicore The message appears in the Problems view of Eclipse. I can delete it but it shows again after a Maven project update. I just try this project in another system with Eclipse Kepler and Java 1.6.0_45 and everything is fine. Should I blame the combination of Luna and Java 1.8 ?? – dunfa Dec 04 '15 at 22:14
  • @dunfa Try to single out Eclipse vs. Java version first. – lexicore Dec 05 '15 at 10:12
  • I can reproduce this error 100% using IBM JVM (J9) v1.6... Do you depend on private api's? – spi Dec 23 '16 at 14:42
  • @spi Make sure Eclispe uses JDK using the `-vm ...` trick from the other answer. No, the plugin does not depend on "private" APIs. – lexicore Dec 23 '16 at 16:50
  • Hello @lexicore, I am trying to load some dependency from our local repository. But still while executing generate-sources -X, it's giving an error `xyz-platform-java:jar:6.1.1 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced` – Sagar Gangwal Mar 09 '23 at 09:55
1

I had this issue on the CLI after installing JDK 9; setting JAVA_HOME to JDK 8 before running mvn clean jaxb2:generate worked in that case:

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/
dave
  • 1,314
  • 1
  • 11
  • 18