Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error injecting: org.jvnet.mjiip.v_2.XJC2Mojo java.lang.NoClassDefFoundError: com/sun/xml/bind/api/ErrorListener

I am using maven to convert my WSDL file into Java classes but when I am supplying the following Jar :-org.jvnet.jaxb2.maven2--->maven-jaxb2-plugin version 0.8.3/0.12.3 But I am getting the following error

    [INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building SOAPSpring 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for org.glassfish.jaxb:jaxb-runtime:jar:2.2.11 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for org.glassfish.jaxb:jaxb-xjc:jar:2.2.11 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[INFO] 
[INFO] --- maven-jaxb2-plugin:0.12.3:generate (generate) @ SOAPSpring ---
[WARNING] Error injecting: org.jvnet.mjiip.v_2.XJC2Mojo
java.lang.NoClassDefFoundError: com/sun/xml/bind/api/ErrorListener
    at java.lang.ClassLoader.defineClass1(Native Method)

And my POM file look like ....

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>SOAPSpring</groupId>
<artifactId>SOAPSpring</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>SOAPSpring</name>
<description>SOAPSpring</description>

<properties>
    <jaxb2.plugin.version>0.8.3</jaxb2.plugin.version>
</properties>
<dependencies>
    <dependency>
        <groupId>org.jvnet.jaxb2.maven2</groupId>
        <artifactId>maven-jaxb2-plugin</artifactId>
        <version>${jaxb2.plugin.version}</version>
    </dependency>
    <!-- <dependency>
        <groupId>org.jvnet.jaxb2.maven2</groupId>
        <artifactId>maven-jaxb2-plugin-core</artifactId>
        <version>0.12.3</version>
    </dependency>
    <dependency>
        <groupId>com.sun.xml.ws</groupId>
        <artifactId>jaxws-rt</artifactId>
        <version>2.2.8</version>
    </dependency> -->
</dependencies>
<build>
    <plugins>
        <plugin>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.3</version>
            <configuration>
                <warSourceDirectory>WebContent</warSourceDirectory>
                <failOnMissingWebXml>false</failOnMissingWebXml>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.jvnet.jaxb2.maven2</groupId>
            <artifactId>maven-jaxb2-plugin</artifactId>
            <version>${jaxb2.plugin.version}</version>
            <executions>
                <execution>
                    <id>generate</id>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <packageName>com.exide.pensionWSDL</packageName>
                <wsdl>true</wsdl>
                <xmlschema>false</xmlschema>
                <schemaFiles>pension.wsdl</schemaFiles>
                <schemaDirectory>${project.basedir}/src/main/resources
                </schemaDirectory>
                <outputDirectory>${project.basedir}/src/main/java</outputDirectory>
                <clearOutputDir>true</clearOutputDir>
            </configuration>
        </plugin>
    </plugins>
</build>

like image 934
SaviNuclear Avatar asked Aug 26 '15 05:08

SaviNuclear


3 Answers

I encountered the same error when using a JRE instead of a JDK. I recommnend you to ensure a JDK is used.

Regards,

like image 192
Aurélien Pupier Avatar answered Nov 08 '22 15:11

Aurélien Pupier


I had same error and as per suggested by Aurélien Pupier I did checked my java version but my $JAVA_HOME was empty and 'java -version' command was showing me version Java 11 instead of jdk 1.8. So i searched jdk version 1.8 location and registered it in $JAVA_HOME variable using above link: enter link description here

like image 3
Priyanka Wagh Avatar answered Nov 08 '22 14:11

Priyanka Wagh


It is due an incompatibility, maybe you're using a different JDK than you think.

Change your JDK to 1.8, if you're using Mac:

export JAVA_HOME=`/usr/libexec/java_home -v 1.8` 
like image 1
ZooMMX Avatar answered Nov 08 '22 14:11

ZooMMX