4

hi i'm trying to follow this example https://spring.io/guides/gs/consuming-web-service/ and i get the following error in my pom.xml file

this is my pom.xml file, the new part that i added is the part after the comment <-- WEB SERVICES -->

this is the part where is the problem :

<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://wsf.cdyne.com/WeatherWS/Weather.asmx?wsdl</url>
                        </schema>
                    </schemas>
                </configuration>
            </plugin>

and here is the entire pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.pruebaWsCompany</groupId>
    <artifactId>app</artifactId>
    <name>PruebaWSproy</name>
    <packaging>war</packaging>
    <version>1.0.0-BUILD-SNAPSHOT</version>
    <properties>
        <java-version>1.6</java-version>
        <org.springframework-version>3.1.1.RELEASE</org.springframework-version>
        <org.aspectj-version>1.6.10</org.aspectj-version>
        <org.slf4j-version>1.6.6</org.slf4j-version>
    </properties>
    <dependencies>
        <!-- Spring -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${org.springframework-version}</version>
            <exclusions>
                <!-- Exclude Commons Logging in favor of SLF4j -->
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                 </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${org.springframework-version}</version>
        </dependency>

        <!-- AspectJ -->
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjrt</artifactId>
            <version>${org.aspectj-version}</version>
        </dependency>   

        <!-- Logging -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${org.slf4j-version}</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl-over-slf4j</artifactId>
            <version>${org.slf4j-version}</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>${org.slf4j-version}</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.15</version>
            <exclusions>
                <exclusion>
                    <groupId>javax.mail</groupId>
                    <artifactId>mail</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>javax.jms</groupId>
                    <artifactId>jms</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.sun.jdmk</groupId>
                    <artifactId>jmxtools</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.sun.jmx</groupId>
                    <artifactId>jmxri</artifactId>
                </exclusion>
            </exclusions>
            <scope>runtime</scope>
        </dependency>

        <!-- @Inject -->
        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <version>1</version>
        </dependency>

        <!-- Servlet -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
            <version>2.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>




        <!-- Test -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.7</version>
            <scope>test</scope>
        </dependency>        
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-eclipse-plugin</artifactId>
                <version>2.9</version>
                <configuration>
                    <additionalProjectnatures>
                        <projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
                    </additionalProjectnatures>
                    <additionalBuildcommands>
                        <buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand>
                    </additionalBuildcommands>
                    <downloadSources>true</downloadSources>
                    <downloadJavadocs>true</downloadJavadocs>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.5.1</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                    <compilerArgument>-Xlint:all</compilerArgument>
                    <showWarnings>true</showWarnings>
                    <showDeprecation>true</showDeprecation>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.2.1</version>
                <configuration>
                    <mainClass>org.test.int1.Main</mainClass>
                </configuration>
            </plugin>

            <!--WEB SERVICES -->
            <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://wsf.cdyne.com/WeatherWS/Weather.asmx?wsdl</url>
                        </schema>
                    </schemas>
                </configuration>
            </plugin>

        </plugins>
    </build>
</project>

and this is the error that i get i try using maven update in my spring-tools suite IDE but still i get the same error

this is the error

Description Resource    Path    Location    Type
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
strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
urls[0] = file:/d:/Users/myUser/.m2/repository/org/jvnet/jaxb2/maven2/maven-jaxb2-plugin/0.12.3/maven-jaxb2-plugin-0.12.3.jar
urls[1] = file:/d:/Users/myUser/.m2/repository/org/jvnet/jaxb2/maven2/maven-jaxb2-plugin-core/0.12.3/maven-jaxb2-plugin-core-0.12.3.jar
urls[2] = file:/d:/Users/myUser/.m2/repository/org/slf4j/slf4j-api/1.7.7/slf4j-api-1.7.7.jar
urls[3] = file:/d:/Users/myUser/.m2/repository/org/apache/commons/commons-lang3/3.2.1/commons-lang3-3.2.1.jar
urls[4] = file:/d:/Users/myUser/.m2/repository/com/sun/org/apache/xml/internal/resolver/20050927/resolver-20050927.jar
urls[5] = file:/d:/Users/myUser/.m2/repository/junit/junit/4.8.1/junit-4.8.1.jar
urls[6] = file:/d:/Users/myUser/.m2/repository/org/codehaus/plexus/plexus-utils/1.5.15/plexus-utils-1.5.15.jar
urls[7] = file:/d:/Users/myUser/.m2/repository/org/jvnet/jaxb2/maven2/maven-jaxb22-plugin/0.12.3/maven-jaxb22-plugin-0.12.3.jar
urls[8] = file:/d:/Users/myUser/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.2.11/jaxb-runtime-2.2.11.jar
urls[9] = file:/d:/Users/myUser/.m2/repository/org/glassfish/jaxb/jaxb-xjc/2.2.11/jaxb-xjc-2.2.11.jar
urls[10] = file:/d:/Users/myUser/.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)   pom.xml /PruebaWSproy   line 165    Maven Build Problem

+++EDIT

i used this tag at the start of my plugins tag and this tag at the end and i no longer have this problem Execution default of goal org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.12.3:generate failed:

here is how i edited it

<build>
    <pluginManagement>
    <plugins>
        <plugin>
            <artifactId>maven-eclipse-plugin</artifactId>
            <version>2.9</version>
            <configuration>
                <additionalProjectnatures>
                    <projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
                </additionalProjectnatures>
                <additionalBuildcommands>
                    <buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand>
                </additionalBuildcommands>
                <downloadSources>true</downloadSources>
                <downloadJavadocs>true</downloadJavadocs>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.5.1</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
                <compilerArgument>-Xlint:all</compilerArgument>
                <showWarnings>true</showWarnings>
                <showDeprecation>true</showDeprecation>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>1.2.1</version>
            <configuration>
                <mainClass>org.test.int1.Main</mainClass>
            </configuration>
        </plugin>

        <!--WEB SERVICES -->

        <plugin>
            <groupId>org.jvnet.jaxb2.maven2</groupId>
            <artifactId>maven-jaxb2-plugin</artifactId>
            <version>${project.version}</version>
            <executions>
                <execution>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <schemaLanguage>WSDL</schemaLanguage>
                <generatePackage>hello.wsdl</generatePackage>
                <forceRegenerate>true</forceRegenerate>
                <schemas>
                    <schema>
                        <url>http://wsf.cdyne.com/WeatherWS/Weather.asmx?wsdl</url>
                    </schema>
                </schemas>
            </configuration>
        </plugin>
    </plugins>
</pluginManagement>

but after i update my maven there are no new packages or classes, this should bring me new classess and packages right?

++++EDIT 2

i try putting this tags but stille no class are generated

<plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jaxws-maven-plugin</artifactId>
                <version>1.12</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>wsimport</goal>
                        </goals>
                        <configuration>
                        <schemaLanguage>WSDL</schemaLanguage>
                        <generateDirectory>D:/Users/myUser/Documents/workspace-sts-3.6.0.RELEASE/ProjectTryWSDL/src/gensrc</generateDirectory>
                        <generatePackage>com.wsdl.src</generatePackage>
                        <schemas>
                            <schema>
                                <url>http://wsf.cdyne.com/WeatherWS/Weather.asmx?wsdl</url>
                            </schema>
                        </schemas>              
                        </configuration>
                    </execution>
                </executions>
            </plugin> 

i think that my folder have permissions to create folders by external apps, or do i need to create that folder by mysefl?

+++++ EDIT 3

i added this route in the generate tag

<plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jaxws-maven-plugin</artifactId>
                <version>1.12</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>wsimport</goal>
                        </goals>
                        <configuration>
                        <schemaLanguage>WSDL</schemaLanguage>
                        <generateDirectory>${project.build.sourceDirectory}/gensrc</generateDirectory>
                        <generatePackage>com.wsdl.src</generatePackage>
                        <schemas>
                            <schema>
                                <url>http://wsf.cdyne.com/WeatherWS/Weather.asmx?wsdl</url>
                            </schema>
                        </schemas>              
                        </configuration>
                    </execution>
                </executions>
            </plugin> 

and this is my properties tags

<properties>
    <java-version>1.6</java-version>
    <org.springframework-version>3.1.1.RELEASE</org.springframework-version>
    <org.aspectj-version>1.6.10</org.aspectj-version>
    <org.slf4j-version>1.6.6</org.slf4j-version>
    <project.version>0.12.3</project.version>
</properties>
stackUser2000
  • 1,615
  • 11
  • 32
  • 55
  • possible duplicate of [Maven trouble when trying to generate from WSDL file](http://stackoverflow.com/questions/28501463/maven-trouble-when-trying-to-generate-from-wsdl-file) – Tunaki Feb 25 '15 at 20:11
  • @Tunaki that question dont have solution but is marked as it have a solution – stackUser2000 Feb 25 '15 at 20:19
  • The author of the plugin stated that this might be a bug. Have you tried to reduce your pom to a minimal example ? – Tunaki Feb 25 '15 at 20:37
  • i edited my question.. i put the pluginmanagement tag to wrap my plugin tags and i no longer have the error, but nothing happends after i update my maven there ano new classes in my project or packages – stackUser2000 Feb 25 '15 at 20:53
  • It is extremely annoying that a so called "beginners getting started guide" from the Spring.io jokers doesn't work properly with arcane farting about with the guts of the pom.xml file! – Geeb Aug 12 '15 at 13:44

2 Answers2

6

Previously I have this issue because of the plugin version (I try to use 0.12.3)

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/xml/bind/api/ ErrorListener

I don't know if the cause is the same or not but I fixed it by changing the version. Try this one:

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>1.2.1</version>
            <configuration>
                <mainClass>org.test.int1.Main</mainClass>
            </configuration>
        </plugin>
         <plugin>
            <groupId>org.jvnet.jaxb2.maven2</groupId>
            <artifactId>maven-jaxb2-plugin</artifactId>
            <version>0.12.1</version>
            <executions>
                <execution>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <schemaLanguage>WSDL</schemaLanguage>
                <generatePackage>soap.servicereq1</generatePackage>
                <schemas>
                    <schema>    
                    <url>http://xxx/Services/ProxyService/ServiceRequest?wsdl</url>
                    </schema>
                </schemas>
            </configuration>
        </plugin>

Hope it works

Irene Felita
  • 61
  • 1
  • 1
  • 1
    Yes - simply by changing 0.12.3 to 0.12.1 the pom.xml became valid and I could generate the sources – Geeb Aug 12 '15 at 13:40
  • changing to version 0.12.1 generates required classes and to run the client you need to set -Dhttp.proxyHost=proxy_host -Dhttp.proxyPort=proxy_port as spring boot run argument – mnhmilu Apr 18 '17 at 09:52
3

You need to change your configuration like below to generate sources.

generateDirectory is the actual directory where the source files are created.

generatePackage is the package name for the source files you generate from WSDL, so you should find these package sub-folders inside generateDirectory

      <configuration>
               <schemaLanguage>WSDL</schemaLanguage>
               <generateDirectory>${project.build.sourceDirectory}/gensrc
                      </generateDirectory>
               <generatePackage>com.wsdl.src</generatePackage>
                <schemas>
                    <schema>
                        <url>http://wsf.cdyne.com/WeatherWS/Weather.asmx?wsdl</url>
                    </schema>
                </schemas>
       </configuration>

You can use mvn jaxb2:generate to generate source files inside your project/src/gensrc directory. For more details on possible configurations, have a look at this cheat sheet :)

Arkantos
  • 6,530
  • 2
  • 16
  • 36
  • here is the path of my eclipse project controller home class `D:\Users\myUser\Documents\workspace-sts-3.6.0.RELEASE\ProjetTryWSDL\src\main\java\com\myCompany\app` I try putting this path in the tag `D:/Users/myUser/Documents/workspace-sts-3.6.0.RELEASE/ProjetTryWSDL/src/main/java/gensrc` i put that in the tag but still no class or packages are generated i Edited my question with my pom XML after your comment @Arkantos do i need to create this folder by myself where eclipse save my projects or is suppose to be created by maven after putting the generate tag – stackUser2000 Feb 26 '15 at 18:51
  • No you don't have to specify the path in `generateDirectory`, use the configuration as is mentioned in my answer as I'm referring to src directory using implicit maven variables. Once changes to pom are done, try `mvn clean install` from the directory containing pom.xml, that should generate the sources :-) – Arkantos Feb 26 '15 at 18:55
  • One more thing is you should be connected to internet as you're the specifying the src of your WSDL as URL. I assume you're already connected :-) – Arkantos Feb 26 '15 at 18:57
  • i put the same generate tag as you told me bu still :( no class are genereted i try using mvn clean install but it failed since i dont have a tools.jar in some folder, but i dont think that is the problem since i can add depencies without having to do a mvn clean install, i just use the maven update function in eclipse, i edited my question again so you can see is my i miss something, i dont know how is it going to work since i dont have `${project.build.sourceDirectory}` in my properties tag – stackUser2000 Feb 26 '15 at 19:13
  • i fix my maven problem now i can execute the mvn command with a BUILD SUCCESS answer but still there are no classes are generated or packages or anything – stackUser2000 Feb 26 '15 at 20:04
  • Do you have an actual jdk installed not just the jre on your system ? – Arkantos Feb 27 '15 at 02:28
  • yes i have the jdk installed i believe is the 7, i also have my JAVA_HOME variable pointing to the jdk path – stackUser2000 Feb 27 '15 at 04:59
  • @stackUser2000 How did u fix it? can you post answer? – JayC Jan 19 '17 at 00:18