Maven trouble when trying to generate from WSDL file
Asked Answered
R

9

22

Im trying to generate sources from a wsdl file, but I keep running into an error on my pom.xml that I believe might be my issue? Below is the error that I get from my pom, and my pom file. Also I cannot build the project with "mvn clean install". I just seem to get an error with no real cause.

The error at the generates tag:

Execution default of goal org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.12.3:generate failed: A required class was missing while executing org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.12.3:generate: com/sun/codemodel/CodeWriter
-----------------------------------------------------
realm =    plugin>org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.12.3-715230752
strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
urls[0] = file:/C:/Users/Windows/.m2/repository/org/jvnet/jaxb2/maven2/maven-jaxb2-plugin/0.12.3/maven-jaxb2-plugin-0.12.3.jar
urls[1] = file:/C:/Users/Windows/.m2/repository/org/jvnet/jaxb2/maven2/maven-jaxb2-plugin-core/0.12.3/maven-jaxb2-plugin-core-0.12.3.jar
urls[2] = file:/C:/Users/Windows/.m2/repository/org/slf4j/slf4j-api/1.7.7/slf4j-api-1.7.7.jar
urls[3] = file:/C:/Users/Windows/.m2/repository/org/apache/commons/commons-lang3/3.2.1/commons-lang3-3.2.1.jar
urls[4] = file:/C:/Users/Windows/.m2/repository/com/sun/org/apache/xml/internal/resolver/20050927/resolver-20050927.jar
urls[5] = file:/C:/Users/Windows/.m2/repository/junit/junit/4.8.1/junit-4.8.1.jar
urls[6] = file:/C:/Users/Windows/.m2/repository/org/codehaus/plexus/plexus-utils/1.5.15/plexus-utils-1.5.15.jar
urls[7] = file:/C:/Users/Windows/.m2/repository/org/jvnet/jaxb2/maven2/maven-jaxb22-plugin/0.12.3/maven-jaxb22-plugin-0.12.3.jar
urls[8] = file:/C:/Users/Windows/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.2.11/jaxb-runtime-2.2.11.jar
urls[9] = file:/C:/Users/Windows/.m2/repository/org/glassfish/jaxb/jaxb-xjc/2.2.11/jaxb-xjc-2.2.11.jar
urls[10] = file:/C:/Users/Windows/.m2/repository/org/apache/maven/plugin-tools/maven-plugin-annotations/3.2/maven-plugin-annotations-3.2.jar
Number of foreign imports: 5
import: Entry[import org.sonatype.plexus.build.incremental from realm ClassRealm[plexus.core, parent: null]]
import: Entry[import org.codehaus.plexus.util.Scanner from realm ClassRealm[plexus.core, parent: null]]
import: Entry[import org.codehaus.plexus.util.DirectoryScanner from realm ClassRealm[plexus.core, parent: null]]
import: Entry[import org.codehaus.plexus.util.AbstractScanner from realm ClassRealm[plexus.core, parent: null]]
import: Entry[import  from realm ClassRealm[maven.api, parent: null]]

-----------------------------------------------------
 (org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.12.3:generate:default:generate-sources)

my pom.xml file :

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.ws</groupId>
        <artifactId>spring-ws-core</artifactId>
    </dependency>
    <dependency>
        <groupId>com.bigthunk</groupId>
        <artifactId>BigThunkCore</artifactId>
        <version>0.0.7-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>com.bigthunk</groupId>
        <artifactId>BigThunkWeb</artifactId>
        <version>0.0.4-SNAPSHOT</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
        <!-- tag::wsdl[] -->
        <plugin>
            <groupId>org.jvnet.jaxb2.maven2</groupId>
            <artifactId>maven-jaxb2-plugin</artifactId>
            <executions>
                <execution>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <schemaLanguage>WSDL</schemaLanguage>
                <generatePackage>hello.wsdl</generatePackage>
                <forceRegenerate>true</forceRegenerate>
                <schemas>
                    <schema>
                        <url>http://172.19.137.21:8280/services/umarketsc?wsdl</url>
                    </schema>
                </schemas>
            </configuration>
        </plugin>
        <!-- end::wsdl[] -->
    </plugins>
</build>

<repositories>
    <repository>
        <id>project.local</id>
        <name>project</name>
        <url>file:${project.basedir}/repo</url>
    </repository>
    <repository>
        <id>spring-releases</id>
        <name>Spring Releases</name>
        <url>https://repo.spring.io/libs-release</url>
    </repository>
</repositories>
<pluginRepositories>
    <pluginRepository>
        <id>spring-releases</id>
        <url>https://repo.spring.io/libs-release</url>
    </pluginRepository>
</pluginRepositories>

Rapier answered 13/2, 2015 at 14:9 Comment(4)
Turned out it was an error in the actual wsdl file causing this.Rapier
I'd still be interested to see the WSDL which crashed it.Acting
@Rapier What changes did you make? to fix it?Crabby
Firs of all try, if your URI is up to date and WS is running. To try WSDL put URI into browser address line: 172.19.137.21:8280/services/umarketsc?wsdl. It works or not? If not, check if WS is started. Check URI.Moist
B
41

Enclosing the <plugins> tag inside <pluginManagement> tag (as detailed here: How to solve "Plugin execution not covered by lifecycle configuration" for Spring Data Maven Builds) fixed the issue for me.

Buchmanism answered 11/7, 2015 at 17:7 Comment(2)
Thanks a lot, this has fixed the problem for me. CheersSteinman
This solved my problem. Thank you very much! I was trying to resolve the issue for 3 days now.Amorino
K
10

Change your Java Path jre to your jdk path and it will be fine! In Eclipse you can also change your "Installed JRE" to your jdk.

Hope it will work for you.

Killebrew answered 12/3, 2015 at 8:59 Comment(0)
B
4

In my case, I fixed it by changing the JAXB specification version as instructed in the plugin wiki:

https://github.com/highsource/maven-jaxb2-plugin/wiki/Using-a-Specific-JAXB-Version

Either by using the config option specVersion=2.0 or by using the version-specific plugin: maven-jaxb20-plugin

Buckie answered 8/4, 2015 at 14:51 Comment(0)
J
3

For me this is a environment (java runtime) problem. I could solve similar issue triggered by m2e in my context, by launching eclipse in Windows command prompt : eclipse.exe -vm "C:\Program Files\Java\jdk1.8.0_25\bin\javaw.exe" (ensure it comes before "-vmargs") Then i tried to clean up my eclipse.ini in the same way to launch eclipse from explorer, it does work. When I have look at the eclipse command in Javavisual VM I see through Jvisual vm that eclipse looks that way

eclipse.commands=-os
win32
...
-vm "C:\Program Files\Java\jdk1.8.0_25\bin\javaw.exe"
-vm C:\Program Files\Java\jre1.8.0_25\bin\server\jvm.dll

Last line does not come from my eclipse.ini, but was appended by Eclipse launcher.In the system prooperties: eclipse.vm=C:\Program Files\Java\jre1.8.0_25\bin\server\jvm.dll This looks like "when launched from explorer", Eclipse luna appends parameter from jre found on the PATH which overrides eclipse.ini... There must be some difference in the environment that can account for the different behaviour of the process.

Juicy answered 4/9, 2015 at 13:21 Comment(2)
You sir deserve a medal of highest honors.Substitutive
It seems you must not put vm arg in the same line: https://mcmap.net/q/219135/-how-do-i-set-the-eclipse-ini-vm-option it worked for me!Substitutive
K
1

I had this problem, but I was able to solve it:

  1. I deleted ALL single JRE file (previous and current versions)
  2. Added to "Path" C:\Program Files\Java\jdk1.8.0_91\jre\bin (I work on Win10)
  3. Profit.

Problem was on version 0.12.2 - 0.13.1 and it totally disappeared.

Knighton answered 7/6, 2016 at 17:8 Comment(0)
T
0

Add

<dependency>
    <groupId>com.sun.xml.bind</groupId>
    <artifactId>jaxb-impl</artifactId>
    <version>2.2.11</version>
</dependency>

to your pom, it contains the missing class, with this I fixed it.

Townspeople answered 7/7, 2015 at 15:40 Comment(1)
It turned out in the end that the error was coming from the wsdl file itself, not my pom.xmlRapier
C
0

Personnally, I'm using sdkman to manage my Java versions and I solved the problem by switching from Java 11 to 8 before running the Maven command.

Chondriosome answered 2/12, 2019 at 7:13 Comment(0)
M
0

I had the same issue and setting an environment variable for jdk worked.

e.g. JAVA_HOME=C:\yourfilepath\jdk-11.0.13.8-hotspot

Marquis answered 24/3, 2022 at 21:39 Comment(0)
A
0

I fixed similar problem just by updating maven-jaxb2-plugin to latest version (0.15.3)

Acrobatic answered 26/4 at 10:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.