Gradle run error : Java file not found - gradle

I have a project in the Hybris running with gradle.bat
The code setup is working fine until clean and build, but when I run the gradle.bat. I am getting the following error.
Exception in thread "main" java.io.FileNotFoundException: *C:\{path}\gradle-4.6-bin.zip* (The system cannot find the path specified)

This is not a environment issue. Please confirm that the gradle is in the specified path itself.
For better performance :
Step 1 : Place gradle-4.6-bin.zip in the gradle/wrapper folder itself.
Step 2 : Open the gradle.properties and replace the distribution URL with following, distributionUrl=gradle-4.6-bin.zip
I hope this will help you.

Its an issue with the gradle version.
Check your version in the project structure and change gradle settings accordingly.

Related

Error: Could not find or load main class org.gradle.launcher.GradleMain

I'm new to Gradle and while trying to install Gradle in my PC with Windows OS, I got the below mentioned error
Error: Could not find or load main class org.gradle.launcher.GradleMain
Only thing I did is that I followed the gradle installation steps given in gradle site Gradle installation and typed
gradle -v
in command prompt and I got the above mentioned exception. Any clue as to what had happened and how to resolve it.
This is what I have done :
Downloaded the zip file
Copied 'gradle-3.5' from the zip file to a folder I created in C drive (C:\Gradle)
Set GRADLE_HOME to 'C:\Gradle\gradle-3.5'
Set Path to '%GRADLE_HOME%\bin'
Opened cmd and typed gradle -v and got this error
I stopped all gradle daemons by running ./gradlew --stop and the error was resolved for me.
Basically this means that Gradle can't find your gradle/wrapper/gradle-wrapper.jar.
You have to follow Step 3 and setup environment variables:
Microsoft Windows users
In File Explorer right-click on the This PC (or Computer) icon, then
click Properties -> Advanced System Settings -> Environmental
Variables.
Under System Variables select Path, then click Edit. Add an entry for
C:\Gradle\gradle-3.5\bin. Click OK to save.
Source: https://gradle.org/install#configure
The easiest way, is to simply use gradlew.bat in your project and it will auto download Gradle for you!
I had the same issue after I removed the cache, the Gradle worker was running and I was getting this error
Error: Could not find or load main class worker.org.gradle.process.internal.worker.GradleWorkerMain
Steps I performed to resolve the error
Use gradle --stop or ./gradlew --stop
Delete the workerMain.lock file under $USER/.gradle/caches/version/workerMain
re-run the Gradle command

Jenkins ERROR: Failed to parse POMs java.io.IOException: Cannot run program error=2, No such file or directory

In jenkins I am forcing the execution to happen in one of the slaves.
in jenkins configuration I have updated the JAVA_HOME and MAVEN location to the location where its installed in the slave. When I start the build in jenkins I receive the following error
ERROR: Failed to parse POMs
java.io.IOException: Cannot run program "/home/jmeter/jdk1.8.0_112/bin/java" (in directory "/home/jmeter/apache-jmeter-2.13/bin/workspace/MyProject"): error=2, No such file or directory
PS : /home/jmeter/apache-jmeter-2.13/bin/workspace/MyProject - This directory got created and does exist in the slave machine
Can someone please share their expertise in resolving it ?
I needed to add Tool location of JDK8 for machine i run test on.
looks like there is a problem in the MVN installation. PLS make sure in the global config that you have the required mvn installation.
jenkins-->manage-->configure look for Maven installations and use automatic installation for the required version
make sure you have the JDK installation in the same config file
After wasting one day trying with different things going through different suggestions I got nothing. But, it was actually very simple. Please add the JDK path as bellow to your JDK Path in Jenkins-
/Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk/Contents/Home
You should assign the JDK in the Meta Data,The JAVA_HOME of system is not work for build.
Check your Maven version selected into the Manage Jenkins->Global Configurations->Maven->Maven Installations->Install from Apache->Version is same as installed on the server and your maven project.
You might have left out a few dependencies resulting in this issue.
Go back and download java and set the path as before:
To download, use
$yum -y install java-1.8*
Set the path to
JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.amzn2.0.1.x86_64
Note: Get your path using command
find /usr/lib/jvm/java-1.8* | head -n 3
This got resolved after adding maven_home and providing the path in the global properties.
Go to: Jenkins ⟶ Manage Jenkins ⟶ Global Properties ⟶ MAVEN_HOME [C:\Program Files\Apache\apache-maven-3.6.3-bin\apache-maven-3.6.3]
Just in case someone else runs into this. I was getting this error because someone setup the JDK in Global Tool Configuration to download a windows version of the JDK, but my instance of jenkins is running on linux. Once I made the change to use a linux version of the JDK my issue was resolved.

Jenkins/Maven build test failure

When I ran maven project from my terminal it works fine but when I ran the same test using Jenkins job it failed giving the following error :
Error Message
/build-nas/jenkins/jenkins163/workspace/Gitrepo/MAVEN/TestConfig.properties
(No such file or directory).
I see that the file is present in the workspace and I am using Git repo where I can see the file named TestConfig.properties present. Please advise. Thank you for the help.

Error during SonarQube Scanner execution

I'm running sonar-runner inside my project folder
I have put and configured the sonar-runner.properties in my project as well. But still the execution Sonar failed. Any idea as to what could be the problem ?
If project configuration file(sonar-project-properties) is being ignored then what is the workaround. Pl suggest asap.
This error is telling you that the Scanner is not finding your project properties. That is likely because the default name of the file is not sonar-runner.properties, nor sonar-project-properties, but sonar-project.properties.

gradle build causing error :startScripts Failed

I am following the step-by-step instructions provided in http://spring.io/guides/gs/consuming-web-service/#scratch to learn how to consume a SOAP web service using Gradle and Spring-WS. I have created the folder structure specified in the above URL (namely., c:/src/main/java/hello) and copied the source code for build.gradle, WeatherClient.java, WeatherConfiguration.java and Application.java into this directory structure. When I execute the command "gradle build" in c:\src\main\java\hello, I am getting the following error:
FAILURE: Build failed with an exception.
* What went wrong:
A problem was found with the configuration of task ':startScripts'.
No value has been specified for property 'mainClassName'.
Following a suggestion I found in one of the Q&A in stackoverflow, I included mainClassName = '' at the end of the build.gradle file. The above error was overcome, but I do not find the "gs-consuming-web-service.jar" file in the C:\src\main\java\hello\build\libs folder as suggested by the instructions. Rather, I find a jar file named "hello.jar" in this folder.
And if I try to execute the hello.jar executable, I get a java.lang.ClassNotFoundException.
Has anyone tried to follow the instructions given in the URL: http://spring.io/guides/gs/consuming-web-service/#scratch with success? If yes, can you please advise where I have gone wrong?
I was able to get the demo project work by following the steps:
Create a folder named gs-consuming-web-service and in it, create a file named build.gradle with the source code provided in http://spring.io/guides/gs/consuming-web-service/#scratch. Add an extra dependency (the one that is highlighted below) in this build.gradle file at the location below:
dependencies {
compile("org.springframework.boot:spring-boot-starter")
compile("org.springframework.ws:spring-ws-core")
compile(files(genJaxb.classesDir).builtBy(genJaxb))
**compile("org.springframework:spring-web:4.1.4.RELEASE")**
jaxb "com.sun.xml.bind:jaxb-xjc:2.1.7"
}
Create the directory structure ...gs-consuming-web-service/src/main/java/hello and in the hello folder, create the java files for WeatherClient.java, WeatherConfiguration.java and Application.java using the source code in http://spring.io/guides/gs/consuming-web-service/#scratch.
Launch InteliJ IDE and select the import project option. In the ensuing screen/step, select the build.gradle file in gs-consuming-web-service folder. Select check-boxes "Use auto-import" and "Create directories for empty content roots automatically". In this screen, make sure that the Gradle home, Gradle JVM are pre-populated correctly (in my case, these have been pre-populated with the path to Gradle-2.8 and JDK 1.8 respectively). Click OK.
At command prompt window, while within the gs-consuming-web-service folder, execute the command "gradle build".
This should get you to a successful gradle build. Good luck and happy learning.

Resources