Jenkins cannot build maven and gradle projects - maven

I have configured jenkins on kubernetes cluster as a pod with NFS volume mount. when i try to build code, using maven and gradle , i'm getting these error.
Exception in thread "main" java.io.IOException: No locks available
at sun.nio.ch.FileDispatcherImpl.lock0(Native Method)
at sun.nio.ch.FileDispatcherImpl.lock(FileDispatcherImpl.java:94)
at sun.nio.ch.FileChannelImpl.tryLock(FileChannelImpl.java:1114)
at java.nio.channels.FileChannel.tryLock(FileChannel.java:1155)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:55)
at org.gradle.wrapper.Install.createDist(Install.java:48)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:107)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)

I fixed the issue. I had to update volume claim yaml. accessModes to ReadWriteOnce, previous it was ReadWriteMany.

Related

Exception in thread "main" java.nio.file.DirectoryNotEmptyException in Azure DevOps Gradle Task

I am building a Java Liferay application in Azure pipeline using Gradle Task.
The application has multiple modules. Occasionally I am getting the below error. Please anyone let me know how to solve this issue.
Task :modules:MyModule2:buildCSS FAILED
Using native Sass compiler
There are no files to compile
Exception in thread "main" java.nio.file.DirectoryNotEmptyException: C:\Windows\SERVIC~1\NETWOR~1\AppData\Local\Temp\portalCssImportPath6020035476982997428\com.liferay.frontend.css.common-5.0.8.jar\bourbon\functions
at sun.nio.fs.WindowsFileSystemProvider.implDelete(WindowsFileSystemProvider.java:266)
at sun.nio.fs.AbstractFileSystemProvider.delete(AbstractFileSystemProvider.java:103) at java.nio.file.Files.delete(Files.java:1126)
at com.liferay.css.builder.internal.util.FileUtil$1.postVisitDirectory(FileUtil.java:56)
at com.liferay.css.builder.internal.util.FileUtil$1.postVisitDirectory(FileUtil.java:49)
at java.nio.file.Files.walkFileTree(Files.java:2688)
at java.nio.file.Files.walkFileTree(Files.java:2742)
at com.liferay.css.builder.internal.util.FileUtil.deltree(FileUtil.java:47) at com.liferay.css.builder.CSSBuilder.close(CSSBuilder.java:137)
at com.liferay.css.builder.CSSBuilder.main(CSSBuilder.java:81)

Gradle build failing after update

Getting exception while gradle/gradlew build. Build without test cases is successful. This happening when I updated the gradle to 6.0.1
Works fine for gradle 5.6/6.2 version.
Could not write standard input to Gradle Test Executor 2.
java.io.IOException: The pipe is being closed
at java.base/java.io.FileOutputStream.writeBytes(Native Method)
at java.base/java.io.FileOutputStream.write(FileOutputStream.java:348)
at java.base/java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:81)
at java.base/java.io.BufferedOutputStream.flush(BufferedOutputStream.java:142)
at org.gradle.process.internal.streams.ExecOutputHandleRunner.forwardContent(ExecOutputHandleRunner.java:68)
at org.gradle.process.internal.streams.ExecOutputHandleRunner.run(ExecOutputHandleRunner.java:53)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
at java.base/java.lang.Thread.run(Thread.java:835)
Error: Could not find or load main class worker.org.gradle.process.internal.worker.GradleWorkerMain
Caused by: java.lang.ClassNotFoundException: worker.org.gradle.process.internal.worker.GradleWorkerMain
FAILURE: Build failed with an exception.
I just had this happen, and found that stopping the gradle daemon resolved it for me:
gradle --stop
or
./gradlew --stop
depending on your setup (the daemon is relaunched when you attempt to build again).
I encountered this error and the one method I found was dump the whole $HOME/.gradle cache and then rebuild the project.
Starting/Stopping IntellijIDEA and/or rebuilding did not help.
You know you have jumped the complexity shark somewhere when running lowly test cases starts to fail for obscure reasons.
Granted, this happened after a machine crash. But still..
If its a windows system, then try deleting the .gradle folder from the user directory and try to build the gradle. This should solve the issue

OutOfMemoryError by using gradle

I am new to Gradle. I am using 5.4.1 version. When I am trying build the application I am facing below issue -
java.lang.IllegalStateException
Caused by: org.springframework.context.ApplicationContextException
Caused by: java.lang.OutOfMemoryError
I have added gradle.properties file in my project root directory where build.gradle is present with below property but still facing issue.
org.gradle.jvmargs=-Xmx512m
I am not sure where to add gradle.properties file. I have also refere this https://gradle.org/docs/current/userguide/build_environment.html document but not sure why gradle.properties files not read by the application.
I am trying to connect remote kafka server from my application and error is
Caused by: org.springframework.context.ApplicationContextException: Failed to start bean 'org.springframework.kafka.config.internalKafkaListenerEndpointRegistry'; nested exception is java.lang.OutOfMemoryError: Java heap space
The default max heap size of jvm is 512m according to the Gradle doc. Can you try increasing it and setting it like :
org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m
Or you can try setting it in global in environment variables GRADLE_OPTS
From doc:
The org.gradle.jvmargs Gradle property controls the VM running the
build. It defaults to -Xmx512m "-XX:MaxMetaspaceSize=256m"

Jenkins Pathignore Plugin installation failing

I have Jenkins installed on a Windows Server.
I am trying to add the plugin Pathignore Plugin which has a dependency on Ruby-runtime.
When I tried to add Ruby-runtime plugin, I've got the following error:
Caused by: java.nio.file.FileSystemException: C:\Program Files (x86)\Jenkins\plugins\ruby-runtime\WEB-INF\lib\classes.jar: The process cannot access the file because it is being used by another process.
It appears to be caused by a long file name bug, I had to relocate our Jenkins install to the root of the drive, it then "just works"
Stop the Jenkins Service
Move the Jenkins folder to the drive root (i.e. C:\Program Files (x86)\Jenkins to C:\Jenkins
Edit the location of the service in the system registry
Restart Jenkins
see bug report here for more information

Jenkins fails during parsing poms

I have problems with one job on my Jenkins server.
It fails during pom parse with this message:
Parsing POMs
Modules changed, recalculating dependency graph
[workspace] $ java -Xmx512m -XX:MaxPermSize=256m -Djava.awt.headless=true -cp /opt/edb/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-agent-1.2.jar:/opt/apache/maven3/boot/plexus-classworlds-2.4.jar org.jvnet.hudson.maven3.agent.Maven3Main /opt/apache/maven3 /var/lib/tomcat6/webapps/jenkins/WEB-INF/lib/remoting-2.17.jar /opt/edb/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-1.2.jar 55430
<===[JENKINS REMOTING CAPACITY]===>channel started
ERROR: Failed to parse POMs
java.io.IOException: Remote call on Channel to Maven [java, -Xmx512m, -XX:MaxPermSize=256m, -Djava.awt.headless=true, -cp, /opt/edb/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-agent-1.2.jar:/opt/apache/maven3/boot/plexus-classworlds-2.4.jar, org.jvnet.hudson.maven3.agent.Maven3Main, /opt/apache/maven3, /var/lib/tomcat6/webapps/jenkins/WEB-INF/lib/remoting-2.17.jar, /opt/edb/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-1.2.jar, 55430] failed
at hudson.remoting.Channel.call(Channel.java:673)
at hudson.maven.ProcessCache$MavenProcess.<init>(ProcessCache.java:112)
at hudson.maven.ProcessCache.get(ProcessCache.java:231)
at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.doRun(MavenModuleSetBuild.java:704)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:586)
at hudson.model.Run.execute(Run.java:1516)
at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:477)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:236)
Caused by: java.lang.Error: Failed to deserialize the Callable object.
Caused by: java.lang.IndexOutOfBoundsException: Index: 1997078527, Size: 0
I have tried creating a new build, no luck
Building locally works fine
All other similar jobs work fine
I'm running letest jenkins (1.489)
Any ideas?
Hard disk is full.
Try to restart.
Maybe the workspace is corrupted and on your pom.xml is not readable. Have to try to clean the workspace for this specific job ?
This issue was fixed for me by setting the correct version Java version in the PATH (as required in the pom.xml) - See https://issues.jenkins-ci.org/browse/JENKINS-5519

Resources