0

I have a spring based web application in which I am trying to consume a SOAP service. I am using jaxb2-maven-plugin(org.codehaus.mojo) for that. However I see an empty jaxb2 folder which is crated under target and I dont see any java classes in it. I have the wsdl placed correctly under the resources folder itself.

Below is the plugin config created in pom.xml

    <build>
        <finalName>${project.artifactId}</finalName>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
            </resource>
            <resource>
                <directory>src/main/java/com/xyz/rap/service/impl/wsdl</directory>
                <targetPath>wsdl</targetPath>
            </resource>
            <resource>
                <directory>src/main/config</directory>
                <targetPath>config</targetPath>
            </resource>
        </resources>
        <plugins>
        <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jaxb2-maven-plugin</artifactId>
                <version>1.6</version>
                <executions>
                    <execution>
                        <id>xjc</id>
                        <goals>
                            <goal>xjc</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <!-- Package to store the generated file -->
                    <packageName>com.xxx.gen.retail.abc</packageName>
                    <!-- Treat the input as WSDL -->
                    <wsdl>true</wsdl>
                    <!-- Input is not XML schema -->
                    <xmlschema>false</xmlschema>
                    <!-- The location of the WSDL file -->
                    <schemaDirectory>${project.basedir}/src/main/resources</schemaDirectory>
                    <!-- The WSDL file that you saved earlier -->
                    <schemaFiles>gene.wsdl</schemaFiles>
                    <!-- Don't clear output directory on each run -->
                    <clearOutputDir>false</clearOutputDir>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <!-- or whatever version you use -->
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

Below is the log when I run "maven install"

  [INFO] Building rap-web Maven Webapp 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
**[INFO] --- jaxb2-maven-plugin:1.6:xjc (xjc) @ rap-web ---
[INFO] Generating source...
[WARNING] No encoding specified; default platform encoding will be used for generated sources.
[INFO] parsing a schema...
[INFO] compiling a schema...
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ rap-web ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 15 resources
[INFO] Copying 3 resources to wsdl
[INFO] Copying 1 resource to config
[INFO] 
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ rap-web ---
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 50 source files to C:\Users\xx67047\DSA-GIT-Projects\10.22.17-dsa-rap-services\rap-web\target\classes**
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ rap-web ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Users\xx67047\DSA-GIT-Projects\10.22.17-dsa-rap-services\rap-web\src\test\resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ rap-web ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ rap-web ---

It says Parsing and compiling the schema in logs but I dont see any java classes getting created in the logs and I see an empty jaxb2 folder and an other empty generated-sources folder getting created. Please refer below image for that:

enter image description here

lexicore
  • 42,748
  • 17
  • 132
  • 221
RRN
  • 61
  • 1
  • 5
  • 13

2 Answers2

0

jaxb2-maven-plugin will create classes by default into target/generated-sources/jaxb. if you are stil not getting classes into target folder then If you are using Eclipse, you can add this folder into your project build path: right-clicking on project and selecting "Build Path > Use Source Folder.

then you need to run mvn clean install it will clean or delete the target folder and regenerate everything.

Anshul Sharma
  • 3,432
  • 1
  • 12
  • 17
  • I tried but it didn't create any jaxb folder inside target/generated-sources. I doubt if the problem is with WSDL itself. However I am able to generate the stubs using wsimport but not with jaxb2-maven-plugin. – RRN Aug 19 '17 at 20:48
0

Try the version 2.2 of the codehaus. Keep in mind that you will need to change your xml a bit since there is a difference between 1.x and 2.x.

Having said that I would like to tell you that I'm having a similar issue. But it could be caused by something else. I'm using IntelliJ and it's generating empty jaxb folder under the /target/generated-sources/.

<plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jaxb2-maven-plugin</artifactId>
                <version>2.2</version>
                <executions>
                    <execution>
                        <id>xjc</id>
                        <goals>
                            <goal>xjc</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <sources>
                        <source>/src/main/resources/xsd/</source>
                    </sources>
                    <outputDirectory>${project.basedir}/target/generated-sources/jaxb</outputDirectory>
                    <clearOutputDir>false</clearOutputDir>
                </configuration>
</plugin>
Saurin
  • 81
  • 1
  • 3
  • 13