I have the following configuration for jaxb2-maven-plugin version 2.4
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<sourceType>wsdl</sourceType>
<sources>
<source>src/main/resources/wsdl/osg_data_sync_service_1_0.wsdl</source>
<source>src/main/resources/wsdl/parlayx_sms_notification_service_2_2.wsdl</source>
</sources>
<outputDirectory>${project.basedir}/src/main/generated</outputDirectory>
<clearOutputDir>false</clearOutputDir>
</configuration>
</plugin>
But when i run mvn jaxb2:xjc, no classes are generated.
What could I be overlooking?
I have pasted one of the wsdl here
EDIT
As it was mentioned that this might be a possible duplicate, I downgraded the plugin to version 1.6 and changed configuration to the following and still no classes generated.
<configuration>
<wsdl>true</wsdl>
<xmlschema>false</xmlschema
<schemaFiles>osg_data_sync_interface_1_0.wsdl,parlayx_sms_notification_interface_2_2.wsdl</schemaFiles>
<schemaDirectory>src/main/resources/wsdl</schemaDirectory>
<outputDirectory>${project.basedir}/src/main/generated</outputDirectory>
</configuration>
Full pom here as site was complaining too much code
It finally works with version 1.6 after cleaning. Why does version 2.4 not work?
Finally got version 2.4 to work. I don't know exactly what the issue was but I was able to generate the classes by running mvn generate-sources instead of mvn jaxb2:xjc as suggested in the comments. I also had to run mvn clean first
Related
Hey I am writing this since I spent some time trying to configure Jackson's ObjectMapper to work without #JsonCreator and #JsonProperty annotations on my DTOs. The result I wanted to achieve is to be able to run Spock's tests (groovy) in both intellij and in console with maven.
Since this issue is resolved: https://youtrack.jetbrains.com/issue/IDEA-125737 intellij automatically picks up below maven configuration:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerArgument>-parameters</compilerArgument>
<testCompilerArgument>-parameters</testCompilerArgument>
</configuration>
</plugin>
Also if you want to use Spock for testing in groovy you need following plugin configuration:
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>${gmavenplus-plugin.version}</version>
<configuration>
<parameters>true</parameters>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>compileTests</goal>
</goals>
</execution>
</executions>
</plugin>
plus additional information:
At the moment I was writing this there was only one version of groovy compiler that worked for me: 2.5.0-alpha-1
maven-compiler-plugin version I used was 3.7.0. Version 3.1 did not work at all. I did not try others.
I hope this saves someone some time :)
I'm tring to import data from remote wsdl. I have written in maven simple code as below
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<executions>
<execution>
<id>generate-stubs1</id>
<phase>process-classes</phase>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<wsdlUrls>
<wsdlUrl>http://www.webservicex.com/globalweather.asmx?wsdl</wsdlUrl>
</wsdlUrls>
<packageName>com.sth.remote</packageName>
</configuration>
</execution>
</executions>
</plugin>
And what is strange in behaviour of this script is that it works only the first time. After, for instance "clean install", java code from wsdl is not generated again. And in debug mode I'm getting this output:
[DEBUG] -- end configuration --
[DEBUG] The wsdl Directory is Q:\workspace\xxx\src\wsdl
[INFO] No WSDLs are found to process, Specify at least one of the following parameters: wsdlFiles, wsdlDirectory or wsdlUrls.
How to resolve this problem ?
UPDATE:
I have noticed that this task works in Eclipse background when I delete target directory and then refresh eclipse project so that eclipse would compile code and run this task but via direct invoking mvn jaxws:wsimport not.
UPDATE 2:
What else, it sems that script running via mvn jaxws:wsimport omit my configuration because if I change for instance staleFile
<staleFile>Q:\workspace\xxx\target\jaxws\stale2</staleFile>
I still have in info in debug that default path to staleFile is in use:
<staleFile default-value="${project.build.directory}/jaxws/stale"/>
...
[DEBUG] (f) staleFile = Q:\workspace\visasin-gwt\target\jaxws\stale
Does someone have some idea what is going on ? #dienerd solution not working for me
i removed your
<id>generatestubs-1</id>
and this ran perfectly. i did a super simple pom w/ just a maven compiler & java.version 1.8. i'm not sure what you are doing but i'd take it back down to simple & add stuff in:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<wsdlUrls>
<wsdlUrl>http://www.webservicex.com/globalweather.asmx?wsdl</wsdlUrl>
</wsdlUrls>
<packageName>com.sth.remote</packageName>
</configuration>
</execution>
</executions>
</plugin>
I use the codehaus jaxb-maven-plugin to create java classes from xml schemas:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<id>xjc</id>
<phase>generate-sources</phase>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<sources>
<source>src/my.xsd</source>
</sources>
<packageName>mypackage</packageName>
</configuration>
</execution>
</executions>
</plugin>
The classes are generated as expected to target/generated-sources/jaxb, but this path is not added to the classpath.
So, if I use some of generated classes in other (not generated) classes, maven cannot found it during the compile process.
Any ideas? TIA!
It is a bug in the jaxb2-maven-plugin:
https://github.com/mojohaus/jaxb2-maven-plugin/issues/44
I am running MacOS El Capitain, with version 2.2 of the plugin, if you run "mvn clean compile", the sourcepath is generated correctly.
If you subsequently run "mvn compile", then the source path does not include the path to the generated files.
Correct: during first invocation
-sourcepath /Users/nastacio/rsawga-rtc/workspace_trunk/ml-common/src/main/java:/Users/nastacio/rsawga-rtc/workspace_trunk/ml-common/target/generated-sources/jaxb:
Missing jaxb path:
-sourcepath /Users/nastacio/rsawga-rtc/workspace_trunk/ml-common/src/main/java: -s /Users/nastacio/rsawga-rtc/workspace_trunk/ml-common/target/generated-sources/annotations
I have a maven plugin (jaxb2) and I need to supply a jvm arg to it. I don't think there is a tag to add jvm args in the pom for it.
I know I can pass in jvm args on the command line eg: mvn clean install -Djavax.xml.accessExternalSchema=all
Is it possible to set this jvm arg in the pom so that I don't have to type it into the command line every time?
(As aside - this jvm arg is required in order for it to work with JAVA-8. It works fine with JAVA-7)
This is relevant to the new XML security properties in JAXB 1.5, introduced in Java 8. This is why your builds now fail on Java 8 but work with Java 7.
If you're using my maven-jaxb2-plugin, please upgrade to the version 0.9.0 or later (current is 0.10.0). It has now a accessExternalSchema switch (default is all).
This sets precisely javax.xml.accessExternalSchema=all.
Please see the documentation.
I came across this issue while working with jaxb2-maven-plugin. I found a related jira issue for maven-jabx2-plugin - https://java.net/projects/maven-jaxb2-plugin/lists/issues/archive/2014-03/message/0
According to this issue Stephan202 suggested using properties-maven-plugin which worked like charm. Here is a sample code from his post -
<plugin>
<!-- We use this plugin to ensure that our usage of the
maven-jaxb2-plugin is JDK 8 compatible in absence of a fix
for https://java.net/jira/browse/MAVEN_JAXB2_PLUGIN-80. -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
<executions>
<execution>
<id>set-additional-system-properties</id>
<goals>
<goal>set-system-properties</goal>
</goals>
</execution>
</executions>
<configuration>
<properties>
<property>
<name>javax.xml.accessExternalSchema</name>
<value>file,http</value>
</property>
</properties>
</configuration>
</plugin>
Re; the post - "I needed a solution that doesn't use alpha versions as that is my companies rules. –"
Changing the version to 1.0 & the value to 'all' got it working for me:
<plugin>
<!-- We use this plugin to ensure that our usage of the
maven-jaxb2-plugin is JDK 8 compatible in absence of a fix
for https://java.net/jira/browse/MAVEN_JAXB2_PLUGIN-80. -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<!--
<version>1.0-alpha-2</version> -->
<version>1.0.0</version>
<executions>
<execution>
<id>set-additional-system-properties</id>
<goals>
<goal>set-system-properties</goal>
</goals>
</execution>
</executions>
<configuration>
<properties>
<property>
<name>javax.xml.accessExternalSchema</name>
<value>all</value>
</property>
</properties>
</configuration>
</plugin>
It has worked for me :
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<executions>
<execution>
<phase>process-sources</phase>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<vmArgs>
<arg>-Djavax.xml.accessExternalSchema=all</arg>
</vmArgs>
<keep>true</keep>
<verbose>true</verbose>
<wsdlDirectory>${project.build.directory}/wsdl</wsdlDirectory>
<wsdlFiles>
<wsdlFile>ServiceWsService.wsdl</wsdlFile>
</wsdlFiles>
<bindingFiles>
<bindingFile>custom-binding.xml</bindingFile>
<bindingFile>custom-binding2.xml</bindingFile>
</bindingFiles>
</configuration>
</execution>
</executions>
</plugin>
Take a look at the Maven Compiler Plugin. Specifically you should be able to use the <compilerArgument> element to pass settings to the compiler.
See http://maven.apache.org/plugins/maven-compiler-plugin/examples/pass-compiler-arguments.html for examples.
If you are trying to change the behavior of the JVM that is running Maven itself, add options to MAVEN_OPTS in the environment before launching mvn.
For maven-jaxb2-plugin version 2.5.0 trying to generate from DTD and spitting
org.xml.sax.SAXParseException: External parsing is disabled. Cannot
parse URI: ...
it helped adding the following to plugin configuration
<configuration>
...
<externalEntityProcessing>true</externalEntityProcessing>
</configuration>
I have a project with mixed Java and Scala sources, following the instructions on this page, which works when running Maven from the command line.
However, people using IDEs like IDEA and Netbeans have problems resolving Scala classes in Java code (but not the other way around, thanks to the nice plugins available). Is there a way to resolve them?
Note: I can build from the command line just fine; the Scala classes are compiled before the Java classes. I just want the IDE to recognize this as well. I could create a separate module for the Scala classes to resolve this problem, but it seems like overkill to me.
Note: In IDEA, I have "Compile Scala classes first" and that still does not do the trick.
Update: Here are the versions I'm using:
scala-library 2.8.0
maven-scala-plugin 2.12
IDEA 9.0 Ultimate with latest scala plugin from plugin repos
Netbeans 6.9 with scala nightly plugin
Which versions (of Scala, the IDEs, the Scala plugins) are you using?
I had the same issues when I started using Scala 2.7 around 9 months ago. While I haven't tried a mixed project recently, my understanding was that the issues would be resolved in Scala 2.8. It may be worth trying Eclipse 3.5.2 with Scala 2.8 -- my impression is that the Eclipse plugin is keeping up with changes in 2.8 better than the other IDE plugins (but I could be wrong).
I have being trying to figure out how to work with Eclipse Indigo + Scala IDE 2.9, m2eclipse, mix of scala 2.9 + jdk1.7 without luck.
I found out that using maven eclipse plugin (mvn eclipse:eclipse) and importing the project as eclipse project (not maven project) with the below customization cleaned up the error marks.
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<executions>
<execution>
<id>scala-compile-first</id>
<phase>process-resources</phase>
<goals>
<goal>add-source</goal>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>scala-test-compile</id>
<phase>process-test-resources</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>src/main/scala</source>
</sources>
</configuration>
</execution>
<execution>
<id>add-test-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>src/test/scala</source>
</sources>
</configuration>
</execution>
</executions
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.8</version>
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
<projectnatures>
<projectnature>org.scala-ide.sdt.core.scalanature</projectnature>
<projectnature>org.eclipse.jdt.core.javanature</projectnature>
</projectnatures>
<buildcommands>
<buildcommand>org.scala-ide.sdt.core.scalabuilder</buildcommand>
</buildcommands>
<classpathContainers>
<classpathContainer>org.scala-ide.sdt.launching.SCALA_CONTAINER"</classpathContainer>
<classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER</classpathContainer>
</classpathContainers>
<excludes>
<exclude>org.scala-lang:scala-library</exclude>
<exclude>org.scala-lang:scala-compiler</exclude>
</excludes>
<sourceIncludes>
<sourceInclude>**/*.scala</sourceInclude>
<sourceInclude>**/*.java</sourceInclude>
</sourceIncludes>
</configuration>
</plugin>