Vscode-java: jaxws-maven-plugin not picked up for generating sources

Created on 15 Jun 2018  路  10Comments  路  Source: redhat-developer/vscode-java

We have a project which generates java classes from a .wsdl file. Our jenkins server successfully compiles the project from scratch but our Eclipse IDE configuration requires extra maven lifecycle mapping plugin com.coderplus.m2e.jaxws.

VS Code seems not to be picking up the plugin to generate the wsimport sources.

Environment
  • Operating System: Windows
  • JDK version: JDK 8
  • Visual Studio Code version: 1.24.1
  • Java extension version: 0.26
Steps To Reproduce
  1. Open maven project with jaxws-maven-plugin configured
  2. Wait until java language server finishes
  3. Expect target/generated-sources/ folder
Current Result

${project.build.directory}/generated-sources/wsimport is not created

Expected Result

wsimport sources are generated

Additional Informations
<plugin>
  <groupId>org.jvnet.jax-ws-commons</groupId>
  <artifactId>jaxws-maven-plugin</artifactId>
  <version>2.3</version>
  <executions>
    <execution>
      <id>wsimport-external-services</id>
        <goals>
          <goal>wsimport</goal>
        </goals>
    </execution>
  </executions>
  <configuration>
    <wsdlDirectory>src/main/resources/com/a/b/c/soap</wsdlDirectory>
      <wsdlFiles>
        <wsdlFile>External_Service.wsdl</wsdlFile>
      </wsdlFiles>
      <implDestDir>${project.build.directory}/generated-sources/wsimport</implDestDir>
      <packageName>com.a.b.c.soap</packageName>
      <xjcArgs>
        <xjcArg>-mark-generated</xjcArg>
      </xjcArgs>
      <keep>true</keep>
      <genJWS>false</genJWS>

      <!-- Needed when JDK_Version >= 8 -->
      <vmArgs>
        <vmArg>-Djavax.xml.accessExternalSchema=all</vmArg>
      </vmArgs>
  </configuration>
</plugin>
Maven bug codegen

Most helpful comment

Ok so, m2e, the underlying Maven integration project, doesn't know if the jaxws maven plugin is safe to run during the workspace build. The problem is visible when running in Eclipse, where you might be able to install an m2e-jaxws plugin, but is somewhat hidden in jdt.ls/vscode-java.

Anyways, one way to workaround this issue is to let m2e run the plugin during its project configuration phase.
One way to do that is to add a processing instruction in the pom.xml like <?m2e execute onConfiguration?> in :

<plugin>
                <groupId>org.jvnet.jax-ws-commons</groupId>
                <artifactId>jaxws-maven-plugin</artifactId>
                <version>2.3</version>
                <executions>
                    <execution>
                        <?m2e execute onConfiguration?>
                        <goals>
                            <goal>wsimport</goal>
                        </goals>

You then need to let vscode update the project configuration:
screen shot 2018-10-11 at 3 40 03 pm

Or you can execute the "Update project configuration" command manually:
screen shot 2018-10-11 at 3 41 53 pm

All 10 comments

Can you please provide a sample project?

I have the same problem as @kanchev : Even though the maven plugin jaxws-maven-plugin is defined in pom.xml; after VSCode starts up, the java language server does not generate files into target/generated-sources/ nor target/classes/.

I have to run $ mvn package manually to make the maven plugin jaxws-maven-plugin generate files into target/generated-sources/.

After running $ mvn package, the language server also does not recognize imports from target/generated-sources/ because it keep regenerating target/classes/ folder and deleting all the class files created by $ mvn package from target/generated-sources/ .

@khe817 I have the same problem. It does not recognize imports from target/generated-sources/. This is the only thing keeping me from using vs-code instead of IntelliJ for my Spring Boot projects.

guys please attach a fully functioning sample project reproducing the issue, it'll help us investigate the problem.

guys please attach a fully functioning sample project reproducing the issue, it'll help us investigate the problem.

@fbricon Feel free to git clone this sample maven project:
https://[email protected]/GabrielBB03/jaxws-import-bug.git

When i open a Java class under target/generated-sources, like this one from the project above:

image

It says the class is not in the classpath:

image

It must be the reason why the import is not being recognized:

image

Ok so, m2e, the underlying Maven integration project, doesn't know if the jaxws maven plugin is safe to run during the workspace build. The problem is visible when running in Eclipse, where you might be able to install an m2e-jaxws plugin, but is somewhat hidden in jdt.ls/vscode-java.

Anyways, one way to workaround this issue is to let m2e run the plugin during its project configuration phase.
One way to do that is to add a processing instruction in the pom.xml like <?m2e execute onConfiguration?> in :

<plugin>
                <groupId>org.jvnet.jax-ws-commons</groupId>
                <artifactId>jaxws-maven-plugin</artifactId>
                <version>2.3</version>
                <executions>
                    <execution>
                        <?m2e execute onConfiguration?>
                        <goals>
                            <goal>wsimport</goal>
                        </goals>

You then need to let vscode update the project configuration:
screen shot 2018-10-11 at 3 40 03 pm

Or you can execute the "Update project configuration" command manually:
screen shot 2018-10-11 at 3 41 53 pm

@fbricon WORKS LIKE A CHARM! Back to VS Code /o/ I should have reported this months ago. By the way if this has to be done for any plugin that generate sources, maybe this should be in the troubleshooting wiki

Be aware, this solution, forcing the execution of jaxws-maven-plugin, is not risk free. There's no guarantee it'll work in 100% of the situations or might lead to some memory leaks.

@fbricon I see. For me it works 100% of the time i open VSCode, for a co-worker it never works using same project

We have been running into this issue too. It is a pretty big blocker since all of our projects use OpenApi and generate all the API models and Service interfaces. Is there any ideas why it isn't resolving generated files? (My work around for now is to have my generated files in a separate module and have it build separately. I then pull it in as a dependency from .m2 in the service module).

It would be awesome to fix this bug tho...

Was this page helpful?
0 / 5 - 0 ratings