Question

I wanna generated java classes from xsd files bt soome how whenever i run the code it shows the error

No Schema has been found... here is the code... Kindly help...

<plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.5.1</version>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jaxb2-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>xjc</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>

                    <schemaDirectory>src/main/resources/xsd</schemaDirectory> 
                    <includeSchema>**/*.xsd</includeSchema>
                    <!-- <generatepackage>org.onesync.esb.datasync.model</generatepackage> -->
                    <!-- The package in which the source files will be generated. -->
                    <packageName>org.onesync.esb.datasync.model</packageName>
                    <!-- The working directory to create the generated java source files. -->
                    <outputDirectory>src/main/java/org/onesync/esb/datasync/model</outputDirectory>

                </configuration>
            </plugin>
        </plugins>
Was it helpful?

Solution

I don't think <includeSchema>**/*.xsd</includeSchema> is valid syntax for jaxb2-maven-plugin:xjc Try omitting that parameter.

If you don't specify schemaFiles it should use all XSD files in the schemaDirectory.

"schemaFiles -- List of files to use for schemas, comma delimited. If none, then all xsd files are used in the schemaDirectory. This parameter also accepts Ant-style file patterns." (see jaxb2-maven-plugin documentation)

BTW, it is usually a good idea to use maven's configuration parameters to refer to a directory. For example, change <schemaDirectory>src/main/resources/xsd</schemaDirectory> to <schemaDirectory>${project.basedir}/src/main/resources/xsd</schemaDirectory>.

Finally, you might also want to refer to this similar SO post.

OTHER TIPS

I am also using maven configuration and spent almost to compile the project stuff. Later on i came to know that it looking for the schema file i.e. schema.xsd.

If you are using the MAVEN configuration then by default you can put the schema file under the resources directory.

But if you want to specify your path for finding the schema file then you can use the includeSchema tag of schemaDescription in plugin configuration.

                                OR

You can use the effictive pom to search for specific tag also.

Command for effective pom in maven: mvn help:effective-pom

Thanks

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top