jfrog / build-info

Artifactory's open integration layer for CI build servers
https://www.buildinfo.org
Apache License 2.0
147 stars 157 forks source link

Maven plugin StackOverflowError in multimodule projects with extensions #72

Open slawekjaranowski opened 8 years ago

slawekjaranowski commented 8 years ago

In maven project with many modules and if one of them we use plugin as extension during "deploy" we got StackOverflowError.

Build generate many logs and don't stop.

You can test example project: https://github.com/PayU-Tech/artifactory-test

Fragment of log:

Caused by: java.lang.RuntimeException: org.jfrog.build.extractor.maven.BuildInfoRecorder.sessionStarted() listener has failed:
        ... 1024 more
Caused by: java.lang.StackOverflowError
        at java.io.ExpiringCache.entryFor(ExpiringCache.java:103)
        at java.io.ExpiringCache.get(ExpiringCache.java:78)
        at java.io.WinNTFileSystem.canonicalize(WinNTFileSystem.java:406)
        at java.io.File.getCanonicalPath(File.java:618)
        at java.io.FilePermission$1.run(FilePermission.java:215)
        at java.io.FilePermission$1.run(FilePermission.java:203)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.io.FilePermission.init(FilePermission.java:203)
        at java.io.FilePermission.<init>(FilePermission.java:277)
        at sun.net.www.protocol.file.FileURLConnection.getPermission(FileURLConnection.java:228)
        at sun.net.www.protocol.jar.JarFileFactory.getPermission(JarFileFactory.java:166)
        at sun.net.www.protocol.jar.JarFileFactory.getCachedJarFile(JarFileFactory.java:136)
        at sun.net.www.protocol.jar.JarFileFactory.get(JarFileFactory.java:91)
        at sun.net.www.protocol.jar.JarURLConnection.connect(JarURLConnection.java:122)
        at sun.net.www.protocol.jar.JarURLConnection.getInputStream(JarURLConnection.java:150)
        at java.net.URLClassLoader.getResourceAsStream(URLClassLoader.java:238)
        at org.jfrog.build.extractor.maven.BuildInfoModelPropertyResolver.getMavenVersion(BuildInfoModelPropertyResolver.java:181)
        at org.jfrog.build.extractor.maven.BuildInfoModelPropertyResolver.resolveProperties(BuildInfoModelPropertyResolver.java:54)
        at org.jfrog.build.extractor.maven.BuildInfoRecorder.sessionStarted(BuildInfoRecorder.java:129)
        ... 1005 more
eyalbe4 commented 8 years ago

Hi @slawekjaranowski , There are 2 configuration issues in the plugin DSL configured in your pom.xml. Fixing them solves the issue. This is the current configuration:

    <build>
        <plugins>
            <plugin>
                <groupId>org.jfrog.buildinfo</groupId>
                <artifactId>artifactory-maven-plugin</artifactId>
                <version>2.4.0</version>
                <executions>
                    <execution>
                        <id>build-info</id>
                        <goals>
                            <goal>publish</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <publisher>
                        <contextUrl>http://localhost/</contextUrl>
                        <repoKey>release-local</repoKey>
                        <snapshotRepoKey>snapshot-local</snapshotRepoKey>
                        <username>deployer</username>
                        <password>deployerpas</password>
                    </publisher>
                </configuration>
            </plugin>
        </plugins>
    </build>

You'll need to add the inherited tag to the DSL

<inherited>false</inherited>

Also, the configuration tag should be inside the execution tag. After fixing these issues, your plugin configuration should look like this:

<build>
    <plugins>
        <plugin>
            <groupId>org.jfrog.buildinfo</groupId>
            <artifactId>artifactory-maven-plugin</artifactId>
            <version>2.4.0</version>
            <inherited>false</inherited>
            <executions>
                <execution>
                    <id>build-info</id>
                    <goals>
                        <goal>publish</goal>
                    </goals>
                    <configuration>
                        <publisher>
                            <contextUrl>http://localhost:8080/artifactory</contextUrl>
                            <repoKey>libs-release-local</repoKey>
                            <snapshotRepoKey>libs-snapshot-local</snapshotRepoKey>
                            <username>admin</username>
                            <password>password</password>
                        </publisher>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

We recommend using the following references when configuring the plugin:

slawekjaranowski commented 8 years ago

Proposed solution with disabled configuration inheritance is not acceptable for us.

We have many projects which use artifactory, and we have one project called "Super POM" where we have global configuration.

So when we disable configuration inheritance we must copy configuration from one place to many other projects. Of course it will produce many work with maintenance.

Do you have another proposition how to maintain configuration for artifactory in one place for many projects?

eyalbe4 commented 8 years ago

Thanks for sharing this input @slawekjaranowski. We will work on finding a solution for this issue.

odrotbohm commented 8 years ago

I am running into the same limitation. We have a parent POM other projects are supposed to use, which is why we can't disable inheritance. Looking at the code I was assuming that to work but I am also running into the stack overflow.

A quick Google search reveals some blog post outlining how to build a plugin that only runs in the project root.

drautureau-sonarsource commented 8 years ago

I recently ran into this issue as well on this project.

Everything was working as expected until this commit : travis build which consist to upgrade the version a plugin in a sub module

Reverting the commit fixed it : travis build

Going deeper, upgrading the version to the root POM of the project definitively fix it so that I was able to re enable the reverted commit : travis build

Hope this could help to diagnose this issue.

romangurevitch commented 8 years ago

Hi @slawekjaranowski, @drautureau-sonarsource, @olivergierke, We have released a new version (2.6.0) of the Maven Artifactory plugin which includes the fix for this issue. You are welcome to use it.

drautureau-sonarsource commented 8 years ago

thanks @romangurevitch for the notification.

FYI, I just tried it and I am getting this error: [ERROR] Failed to execute goal org.jfrog.buildinfo:artifactory-maven-plugin:2.6.0:publish (build-info) on project sonarqube: Execution build-info of goal org.jfrog.buildinfo:artifactory-maven-plugin:2.6.0:publish failed: Plugin org.jfrog.buildinfo:artifactory-maven-plugin:2.6.0 or one of its dependencies could not be resolved: The following artifacts could not be resolved: org.jfrog.buildinfo:build-info-api:jar:2.6.x-SNAPSHOT, org.jfrog.buildinfo:build-info-extractor-maven3:jar:2.6.x-SNAPSHOT: Could not find artifact org.jfrog.buildinfo:build-info-api:jar:2.6.x-SNAPSHOT -> [Help 1]

romangurevitch commented 8 years ago

Thanks @drautureau-sonarsource, We have fixed the dependencies, you can use it now.

hgomez-sonarsource commented 8 years ago

Did you redeployed same version of artifact on JCenter ? If so, users will have to remove it from their Artifactory/Nexus/Archiva but also from local repositories on build machines/slaves.

drautureau-sonarsource commented 8 years ago

BTW, I confirm that it fixes my use case (after removing the JCenter cache from the Artifactory instance). 2.6.1 would be welcome to avoid any confusion ! Thanks

romangurevitch commented 8 years ago

Thanks @hgomez-sonarsource , @drautureau-sonarsource, Your feedback is very valuable and welcome. We have released new version, 2.6.1.

ajit2121 commented 1 year ago
<executions>
                <execution>
                    <id>build-info</id>
                    <goals>
                        <goal>publish</goal>
                    </goals>
                    <configuration>
                        <publisher>
                            <contextUrl>http://localhost:8080/artifactory</contextUrl>
                            <repoKey>libs-release-local</repoKey>
                            <snapshotRepoKey>libs-snapshot-local</snapshotRepoKey>
                            <username>admin</username>
                            <password>password</password>
                        </publisher>
                    </configuration>
                </execution>
            </executions>

I'm facing the same issue what is the solution?