I know this question has been asked over and over again, and its always an Eclipse Maven JIXB problem. I don't think it has ever been resolved.
When I try to test my code I get the following error
Unable to access binding information for class com.generated.xml.addbooking.Request
Make sure the binding has been compiled
java.lang.NoSuchFieldException: JiBX_bindingList
at java.lang.Class.getDeclaredField(Class.java:1882)
at org.jibx.runtime.BindingDirectory.getBindingList(BindingDirectory.java:68)
Now I have generated the POJOs and have generated a binding.xml file using the following POM.
<plugin>
<groupId>org.jibx</groupId>
<artifactId>jibx-maven-plugin</artifactId>
<version>1.2.5</version>
<executions>
<execution>
<id>schemata-a</id>
<goals>
<goal>schema-codegen</goal>
</goals>
<configuration>
<schemaLocation>src/main/resources/schemas</schemaLocation>
<includeSchemas>
<includeSchema>AddBookingRequest.xsd</includeSchema>
</includeSchemas>
<schemaBindingDirectory>src/main/java</schemaBindingDirectory>
<includeSchemaBindings>
<includeSchemaBindings>binding.xml</includeSchemaBindings>
</includeSchemaBindings>
<options>
<package>com.generated.xml.addbooking</package>
</options>
</configuration>
</execution>
<execution>
<id>schemata-b</id>
<goals>
<goal>schema-codegen</goal>
</goals>
<configuration>
<schemaLocation>src/main/resources/schemas</schemaLocation>
<includeSchemas>
<includeSchema>SearchHotelPriceRequest.xsd</includeSchema>
</includeSchemas>
<schemaBindingDirectory>src/main/java</schemaBindingDirectory>
<includeSchemaBindings>
<includeSchemaBindings>binding.xml</includeSchemaBindings>
</includeSchemaBindings>
<options>
<package>com.generated.xml.searchhotel</package>
</options>
</configuration>
</execution>
<execution>
<id>compile-binding</id>
<goals>
<goal>bind</goal>
</goals>
<configuration>
<schemaBindingDirectory>src/main/java</schemaBindingDirectory>
<includes>
<include>binding.xml</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
As you can see the POJOs are generated, the binding.xml is generated but the bind is not being run for some reason?
Need to add another plug in that points to 1.5 or above for some reason maven 2 plugins are compiling against 1.3. Was causing the binding problem which uses generics.
I added the following to my plugin
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<compilerArgument></compilerArgument>
</configuration>
</plugin>
Related
I'm using Intellij's ui-designer in my Maven project and I understand from this question that I need to use ideauidesigner-maven-plugin to create a jar out of my code.
So I add this to my pom.xml:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>ideauidesigner-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>javac2</goal>
</goals>
</execution>
</executions>
<configuration>
<fork>true</fork>
<debug>true</debug>
<failOnError>true</failOnError>
</configuration>
</plugin>
And now when I'm trying to create the jar with "mvn clean package",
I'm getting the following error "Index 20838 out of bounds for length 6699".
here is the error with the call stack:
So I'm creating a maven plugin using the maven-plugin-plugin. The HelpMojo in maven-plugin-plugin generates a java source file.
Unfortunately, PMD is picking this up and complaining about it. Is there a way to have PMD ignore just a single source file? Thanks!
Maven PMD Configuration:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<executions>
<execution>
<id>pmd-verify</id>
<goals>
<goal>check</goal>
<goal>cpd-check</goal>
</goals>
<configuration>
<printFailingErrors>true</printFailingErrors>
</configuration>
</execution>
</executions>
</plugin>
Generated sources usually end up (with maven) in a subdirectory in target/generated-sources, for the maven-plugin-plugin it's target/generated-sources/plugin.
You can exclude these complete directories with excludeRoots, e.g.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<executions>
<execution>
<id>pmd-verify</id>
<goals>
<goal>check</goal>
<goal>cpd-check</goal>
</goals>
<configuration>
<printFailingErrors>true</printFailingErrors>
<excludeRoots>
<excludeRoot>target/generated-sources/plugin</excludeRoot>
</excludeRoots>
</configuration>
</execution>
</executions>
</plugin>
There is also a file based exclude option.
I have a JSON File and I want to convert it to POJO, for this I am using the plugin of org.jsonschema2pojo in maven. I am not able to generate the resultant pojo.Here's the snippet from pom.xml
<build>
<plugins>
<plugin>
<groupId>org.jsonschema2pojo</groupId>
<artifactId>jsonschema2pojo-maven-plugin</artifactId>
<version>0.4.23</version>
<configuration>
<sourceDirectory>${basedir}/src/main/resources/schema</sourceDirectory>
<targetPackage>${basedir}/src/main/resources/result</targetPackage>
</configuration>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
I am using the generate sources goal in maven. My expectation is that it should give me pojo files at ${basedir}/src/main/resources/result location. However I am getting so. Please help me out.
Thanks,
Rajit
You want to use <outputDirectory> instead of <targetPackage>. More details here:
http://joelittlejohn.github.io/jsonschema2pojo/site/0.4.23/generate-mojo.html#outputDirectory
http://joelittlejohn.github.io/jsonschema2pojo/site/0.4.23/generate-mojo.html#targetPackage
Target package is the Java package you want your types to use, e.g. com.youcompany.model.
Also, typically you want the generated output to go into the target directory, not src. Derived files usually go there since anything inside target is usually omitted from source control. You don't need to specify outputDirectory if you don't want to, by default the generated output will go into /target/java-gen.
Below code works for me.
<plugin>
<groupId>org.jsonschema2pojo</groupId>
<artifactId>jsonschema2pojo-maven-plugin</artifactId>
<executions>
<execution>
<id>1</id>
<configuration>
<annotationStyle>jackson2</annotationStyle>
<includeAdditionalProperties>false</includeAdditionalProperties>
<sourcePaths>
<sourcePath>${project.basedir}/src/main/resource/jsd/your_schema.json</sourcePath>
</sourcePaths>
<targetPackage>your target package</targetPackage>
</configuration>
<goals>
<goal>generate</goal>
</goals>
</execution>
<execution>
<id>2</id>
<configuration>
<annotationStyle>jackson2</annotationStyle>
<includeAdditionalProperties>false</includeAdditionalProperties>
<sourcePaths>
<sourcePath>${project.basedir}/src/main/resource/jsd/your_schema2.json</sourcePath>
</sourcePaths>
<targetPackage>your target package</targetPackage>
</configuration>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
Use both targetPackage and outputDirectory.
<plugin>
<groupId>org.jsonschema2pojo</groupId>
<artifactId>jsonschema2pojo-maven-plugin</artifactId>
<version>1.0.2</version>
<configuration>
<sourceDirectory>${basedir}/src/main/resources/schema</sourceDirectory>
<outputDirectory>src/main/java</outputDirectory>
<targetPackage>com.your.package</targetPackage>
</configuration>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
I've code which generates classes and these are referenced in main package
I'm using jaxb2 plugin and running on commandline. my code creates generate-sources ,but compile fails saying symbol can't find.
can somebody help me what's going wrong. here is my plugin in pom.xml
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<schemaIncludes>
<schemaInclude>*-1.0.xsd</schemaInclude>
</schemaIncludes>
<bindingIncludes>
<bindingInclude>*bindings-1.0.xjb</bindingInclude>
</bindingIncludes>
</configuration>
</plugin>
</plugins>
I have a set of integration tests which I need to run in specific order. So i created a BlahSuite.java inside the same package, and specified the order of classes there. And annotation as following
#RunWith(Suite.class)
#Suite.SuiteClasses({
And I added the plugin into pom as following
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.9</version>
<configuration>
<includes>
<include>**/*Suite.java</include>
</includes>
</configuration>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
<execution>
<id>verify</id>
<goals>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
But still the tests are fired in different orders, feels like the Suite class is fully ignored. Any idea how to fix this ?
I found the answer at Stackoverflow question Run Junit Suite using Maven Command
So what my final setup is I just removed failsafe plugin and added following,
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>**/*Suite.class</include>
</includes>
</configuration>
</plugin>