xolstice / protobuf-maven-plugin

Maven Plugin that executes the Protocol Buffers (protoc) compiler
https://www.xolstice.org/protobuf-maven-plugin/
Other
232 stars 76 forks source link

Protobuf-maven-plugin error #21

Closed gaurav9822 closed 6 years ago

gaurav9822 commented 7 years ago

Hi,

I am getting following error in Protobuf-maven-plugin:

[ERROR]Failed to execute goal org.xolstice.maven.plugins:protobuf-maven-plugin:0.5.0:compile-custom(default) on project : Unable to copy the file to D:\codebase\api\target\protoc-plugins: D:\codebase\api\target\protoc-plugins\protoc-3.0.2-windows-x86_64.exe (The process cannot access the file because it is being used by another process)

What I've tried:-

I tried using toolchain but no help. Also,disabled antivirus if its accessing it. But still no luck. Please help me with this issue.

Thanks,

Gaurav

sergei-ivanov commented 7 years ago

Hi,

It looks like the plugin is trying to copy the file onto itself, which is weird. Can you please provide more information as described here: https://www.xolstice.org/protobuf-maven-plugin/contributions.html#Reporting_bugs If it is a public project, please provide a link to it, othewise please upload a sanitised version of the POM as a gist.

Thanks

gaurav9822 commented 7 years ago

Hi Sergei,

1)Output of mvn --version

Apache maven 3.2.5 Maven home: C:\gaurav\apache-maven-3.2.5-binary java version:1.8.0_25, vendor:Oracle corporation java home: C:\program files\java\jdk1.8.0_25\jre default local:en_GB, platform encoding:Cp1252 OS name:"windows 7", version:"6.1", arch:"amd64", family:"dos"

2)Whether you are running Maven inside an IDE, and in that case, which IDE

I am using intellij IDEA 2016 as well as command prompt and it gives same error on both.

3)It's not a public project but I can share plugin configuration with you.

Following are the protoc related things from my root pom.xml

io.grpc grpc-protobuf ${grpc.version} org.xolstice.maven.plugins protobuf-maven-plugin 0.5.0 true compile compile-custom com.google.protobuf:protoc:3.0.2:exe:${os.detected.classifier} grpc-java io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier} *Following things are from my other module's pom.xml* io.grpc grpc-protobuf provided org.xolstice.maven.plugins protobuf-maven-plugin Thanks, Regards, Gaurav On Wed, Dec 7, 2016 at 8:13 PM, Sergei Ivanov wrote: > Hi, > > It looks like the plugin is trying to copy the file onto itself, which is > weird. > Can you please provide more information as described here: > https://www.xolstice.org/protobuf-maven-plugin/contributions > .html#Reporting_bugs > If it is a public project, please provide a link to it, othewise please > upload a sanitised version of the POM as a gist. > > Thanks > > — > You are receiving this because you authored the thread. > Reply to this email directly, view it on GitHub > , > or mute the thread > > . >
sergei-ivanov commented 7 years ago

Does the plugin section in your root POM reside inside plugins or pluginManagement? Can you try placing the two goals into two separate executions? And you'll probably need to set clearOutputDirectory property to false in the configuration section.

gaurav9822 commented 7 years ago

Hi Sergei,

1)plugin section in my root pom reside like

....

2)I'll check if that works in two different executions.

3)I'll do this modification and check again and revert.

Regards,

Gaurav

On Wed, Dec 7, 2016 at 10:04 PM, Sergei Ivanov notifications@github.com wrote:

Does the plugin section in your root POM reside inside plugins or pluginManagement? Can you try placing the two goals into two separate executions? And you'll probably need to set clearOutputDirectory property to false in the configuration section.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/xolstice/protobuf-maven-plugin/issues/21#issuecomment-265497278, or mute the thread https://github.com/notifications/unsubscribe-auth/AE9poMqeyEli4rYSSHCBsTtPCmmmSFNbks5rFuAagaJpZM4LGpok .

gaurav9822 commented 7 years ago

Hi sergei,

I resolved above issue to protoc toolchain in maven.

But now its throwing an error:-

"package XmlServiceGrpc does not exist."

Regards,

Gaurav

On Thu, Dec 8, 2016 at 11:33 AM, gaurav deshpande gaurav9822@gmail.com wrote:

Hi Sergei,

1)plugin section in my root pom reside like ....

2)I'll check if that works in two different executions.

3)I'll do this modification and check again and revert.

Regards,

Gaurav

On Wed, Dec 7, 2016 at 10:04 PM, Sergei Ivanov notifications@github.com wrote:

Does the plugin section in your root POM reside inside plugins or pluginManagement? Can you try placing the two goals into two separate executions? And you'll probably need to set clearOutputDirectory property to false in the configuration section.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/xolstice/protobuf-maven-plugin/issues/21#issuecomment-265497278, or mute the thread https://github.com/notifications/unsubscribe-auth/AE9poMqeyEli4rYSSHCBsTtPCmmmSFNbks5rFuAagaJpZM4LGpok .

sergei-ivanov commented 7 years ago

Hello Gaurav,

Is it an error that is produced by protoc or by javac ? It is difficult to tell, because you are not providing enough context. Either way, most likely you have an incorrect import statement (without a package name) somewhere in your code.

Sergei

gaurav9822 commented 7 years ago

Hi Sergei,

I resolved the error of compilation problem by including compile-custom goal in the root pom.xml

Ignore it,now the new error is popping by protoc is:-

[ERROR]Failed to execute goal org.xolstice.maven.plugins:protobuf-maven-plugin:0.5.0:compile-custom(default) on project : Unable to copy the file to D:\codebase\api\target\protoc-plugins: D:\codebase\api\target\protoc-plugins\protoc-gen-grpc-java-1.0.2-windows-x86_64.exe (The process cannot access the file because it is being used by another process)

sergei-ivanov commented 7 years ago

Can you please upload a small sample project that exhibits this behaviour to GitHub? Without a reproducible example I will struggle to help you. You will need to provide more context to your error report, the above does not allow to even try to guess the root cause. The complete log file would be helpful, not just the error line. Please use gists to upload larger/longer file fragments and post references here, instead of posting inline.

taoyouxian commented 6 years ago

I have also meet this problem, and my OS is Windows(the project in ubuntu is okay). What is more? You can use protobuf Plugins in Maven where "View->Tool Windows->Maven Projects in IDEA IntelliJ" to compile, the fault will not appear.

Archimechanical commented 6 years ago

Same problem when forking spring-boot-maven-plugin (windows):

<plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <fork>true</fork>
                <arguments>
                    <argument>-Dfile.encoding=UTF8</argument>
                </arguments>
                <jvmArguments>-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8002
                    -Dfile.encoding=UTF8</jvmArguments>
            </configuration>
</plugin>

Setting fork to false working well.

sergei-ivanov commented 6 years ago

@gaurav9822 has it been fixed by #30 or #34 in the latest version? I'd like to have some feedback.

Sewq commented 6 years ago

I've got the same issue. Whats more - i cannot even copy the file from 'compile-custom' goal (protoc-gen-grpc-java-1.5.0-windows-x86_64) to my target/protoc-plugins/ folder by hand. Somehow i can do it when i change the name from "protoc-gen-grpc-java-1.5.0-windows-x86_64" to anything else. Im not sure if this file is blocked by windows or any anti-virus. When i've changed the plugin to add another folder in protoc-plugin directory, and copy the .exe there, it works, but then i've got 'access denied' when trying to execute "--grpc-java_out: protoc-gen-grpc-java".

Weird stuff

sergei-ivanov commented 6 years ago

@Sewq It's difficult to get to the root cause of this problem, especially that I cannot reproduce it myself. In my experience, some antivirus tools may employ very aggressive file locking, and there is no way around that unless you exclude both local maven repository and your project from virus scanning. Also, you may try using Process Explorer to locate the process that holds a lock on the file. If you are saying that you cannot even move the file manually, then some process must be holding on to it. If you can detect which process it is, it will help us all to understand the problem better.