Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

apache cxf wsdl2java Failed to generate types->Access is denied

I'm struggling to fix this issue since 2013... I'm using Windows 7.

[ERROR] Failed to execute goal org.apache.cxf:cxf-codegen-plugin:3.1.2:wsdl2java (generate-sources) on project service-data-model-provider: Execution generate-sources of goal org.apache.cxf:cxf-codegen-plugin:3.1.2:wsdl2java failed: Failed to generate types. a:\Misc\WsMock\service-data-model-provider\src\main\java\schema\eo\common\system\messageheader\v1\MessageContextType.java (Access is denied) -> [Help 1]

Its completely random and happens for me on all cxf versions and different java versions. At the moment I'm on jdk 1.8.45 and cxf 3.1.2

The issue can be resolved by setting always

But then the build is always successful even is some errors will happen which are shown as [Warning] in the log.. So I can't use anything like that.

Here's my cfg

<plugin>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-codegen-plugin</artifactId>
    <version>${cxf.version}</version>
    <executions>
        <execution>
            <id>generate-sources</id>
            <phase>generate-sources</phase>
            <configuration>
                <sourceRoot>${basedir}/src/main/java</sourceRoot>
                <defaultOptions>
                    <extraargs>
                        <extraarg>-validate</extraarg>
                        <extraarg>-exsh</extraarg>
                        <extraarg>true</extraarg>
                    </extraargs>
                </defaultOptions>
                <wsdlRoot>..\..\..</wsdlRoot>
                <includes>
                    <include>mds/apps/services/**/*.wsdl</include>
                </includes>
            </configuration>
            <goals>
                <goal>wsdl2java</goal>
            </goals>
        </execution>
    </executions>
</plugin>

Another thing that helps but its not resolving the issue completely is to disable the WriteToCache setting in the WindowsHardDrive driver.

That indicates that the system is too slow and CXF\Java is trying to use the file before its completely written to the disk. Using an SSD the issue is happening only occasionally.

Our data model is huge (lots of XSD's) and the hard drives are encrypted so that's why everything is so slow.

Any ideas how to tune java to handle this? Or maybe its a CXF problem?

Full Stack Trace

[ERROR] Failed to execute goal org.apache.cxf:cxf-codegen-plugin:3.1.2:wsdl2java (generate-sources) on project service-data-model-provider: Execution generate-sources of goal org.apache.cxf:cxf-codegen-plugin:3.1.2:wsdl2java failed: Fai led to generate types. a:\Misc\WsMock\service-data-model-provider\src\main\java\co\schema\common\fault\creati onfault\v1\ObjectFactory.java (Access is denied) -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.cxf:cxf-codegen-plugin:3.1.2:w sdl2java (generate-sources) on project service-data-model-provider: Execution generate-sources of goal org.apache.cx f:cxf-codegen-plugin:3.1.2:wsdl2java failed: Failed to generate types. at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:224) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder. java:51) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286) at org.apache.maven.cli.MavenCli.main(MavenCli.java:197) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) Caused by: org.apache.maven.plugin.PluginExecutionException: Execution generate-sources of goal org.apache.cxf:cxf-codeg en-plugin:3.1.2:wsdl2java failed: Failed to generate types. at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:145) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) ... 20 more Caused by: org.apache.cxf.tools.common.ToolException: Failed to generate types. at org.apache.cxf.tools.wsdlto.databinding.jaxb.JAXBDataBinding.generate(JAXBDataBinding.java:839) at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.generateTypes(WSDLToJavaContainer.java:730) at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.processWsdl(WSDLToJavaContainer.java:270) at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:164) at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:415) at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:103) at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:113) at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:86) at org.apache.cxf.maven_plugin.wsdl2java.WSDL2JavaMojo.generate(WSDL2JavaMojo.java:415) at org.apache.cxf.maven_plugin.AbstractCodegenMoho.execute(AbstractCodegenMoho.java:260) at org.apache.cxf.maven_plugin.wsdl2java.WSDL2JavaMojo.execute(WSDL2JavaMojo.java:512) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134) ... 21 more Caused by: java.io.FileNotFoundException: a:\Misc\WsMock\service-data-model-provider\src\main\java\uk\co\schema\ common\fault\creationfault\v1\ObjectFactory.java (Access is denied) at java.io.FileOutputStream.open0(Native Method) at java.io.FileOutputStream.open(FileOutputStream.java:270) at java.io.FileOutputStream.(FileOutputStream.java:213) at java.io.FileOutputStream.(FileOutputStream.java:162) at org.sonatype.plexus.build.incremental.DefaultBuildContext.newFileOutputStream(DefaultBuildContext.java:54) at org.apache.cxf.maven_plugin.wsdl2java.WSDL2JavaMojo$1.createOutputStream(WSDL2JavaMojo.java:411) at org.apache.cxf.tools.wsdlto.databinding.jaxb.TypesCodeWriter.openBinary(TypesCodeWriter.java:72) at com.sun.codemodel.CodeWriter.openSource(CodeWriter.java:100) at com.sun.codemodel.JPackage.createJavaSourceFileWriter(JPackage.java:490) at com.sun.codemodel.JPackage.build(JPackage.java:441) at com.sun.codemodel.JCodeModel.build(JCodeModel.java:311) at com.sun.codemodel.JCodeModel.build(JCodeModel.java:301) at org.apache.cxf.tools.wsdlto.databinding.jaxb.JAXBDataBinding.generate(JAXBDataBinding.java:827) ... 32 more [ERROR] [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException

Cheers Prem

like image 202
Prem Avatar asked Sep 04 '15 12:09

Prem


1 Answers

(Moving @Prem's comment to this answer and adding more details)

Adding <fork>always</fork> fixes the issue.

Sample configurations:

     <plugin>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-codegen-plugin</artifactId>
        <version>${cxf.version}</version>
        <executions>
          <execution>
            <id>generate-source</id>
            <phase>generate-sources</phase>
            <configuration>
              <fork>always</fork>
            </configuration>
...
<!-- Rest of the configuration -->

Docs - maven-cxf-codegen - other config

like image 138
Smile Avatar answered Oct 26 '22 16:10

Smile