Jenkins - Locating maven-wrapper.properties in wrong path - java

Below is the snippet from scripted pipeline(Jenkins):
sh 'echo ${WORKSPACE}'
env.PATH="${WORKSPACE}/xyz-app:${env.PATH}"
sh '${WORKSPACE}/xyz-app/mvnw clean install'
that gives below error:
+ /app/jenkins/workspace/CU_project/for_xyz/xyz-app/mvnw clean install
/app/jenkins/workspace/CU_project/for_xyz/xyz-app/mvnw: 236: /app/jenkins/workspace/CU_project/for_xyz/xyz-app/mvnw: cannot open /app/jenkins/workspace/CU_project/for_xyz/.mvn/wrapper/maven-wrapper.properties: No such file
/app/jenkins/workspace/CU_project/for_xyz/.mvn/wrapper/maven-wrapper.jar: No such file or directory
Error: Could not find or load main class org.apache.maven.wrapper.MavenWrapperMain
echo ${WORKSPACE} gives /app/jenkins/workspace/CU_project/for_xyz
As per the above error: /app/jenkins/workspace/CU_project/for_xyz/.mvn/wrapper/maven-wrapper.properties is wrong path for file maven-wrapper.properties.
Correct path is /app/jenkins/workspace/CU_project/for_xyz/xyz_app/.mvn/wrapper/maven-wrapper.properties
How to configure workspace for mvnw to pick arguments from correct path?

Related

Getting error: Unable to parse POM

While building a Maven project in Jenkins, I am getting below error. Can you provide steps to solve this error?
Building in workspace C:\Program Files (x86)\Jenkins\workspace\JenkinProject
Unpacking https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.5.3/apache-maven-3.5.3-bin.zip to C:\Program Files (x86)\Jenkins\tools\hudson.tasks.Maven_MavenInstallation\TestMaven on Jenkins
ERROR: Failed to parse POMs
java.io.IOException: Failed to rename C:\Program Files (x86)\Jenkins\tools\hudson.tasks.Maven_MavenInstallation\TestMaven\apache-maven-3.5.3 to C:\Program Files (x86)\Jenkins\tools\hudson.tasks.Maven_MavenInstallation\TestMaven\apache-maven-3.5.3.__rename
at hudson.FilePath$29.invoke(FilePath.java:2107)
Finished: FAILURE

The javapackager is unable to generate a dmg on macOS

I am trying to generate a dmg from a jar using the javapackager.
Here is what I put into terminal:
cd "/Users/name/Documents/JarToApplication"
jdk=$(/usr/libexec/java_home -v 1.8)
$jdk/bin/javapackager -deploy -native dmg -BappVersion=8 -name DMSLauncher -srcdir . -srcfiles DMSLauncher.jar -appclass com.blockhead7360.dms.launcher.DMSLauncher -Bicon=package/macosx/DMSLauncher.icns -outdir deploy -outfile DMSLauncher -v
And it runs until here:
Running [osascript, /var/folders/z5/n802xjnx49l4535kq63992280000gn/T/fxbundler8419176091447096668/macosx/DMSLauncher-dmg-setup.scpt]
/var/folders/z5/n802xjnx49l4535kq63992280000gn/T/fxbundler8419176091447096668/macosx/DMSLauncher-dmg-setup.scpt:635:742: execution error: Finder got an error: The operation can’t be completed because there is already an item with that name. (-48)
java.io.IOException: Exec failed with code 1 command [[osascript, /var/folders/z5/n802xjnx49l4535kq63992280000gn/T/fxbundler8419176091447096668/macosx/DMSLauncher-dmg-setup.scpt] in unspecified directory
at com.oracle.tools.packager.IOUtils.exec(IOUtils.java:165)
at com.oracle.tools.packager.IOUtils.exec(IOUtils.java:138)
at com.oracle.tools.packager.IOUtils.exec(IOUtils.java:132)
at com.oracle.tools.packager.mac.MacDmgBundler.buildDMG(MacDmgBundler.java:376)
at com.oracle.tools.packager.mac.MacDmgBundler.bundle(MacDmgBundler.java:92)
at com.oracle.tools.packager.mac.MacDmgBundler.execute(MacDmgBundler.java:556)
at com.sun.javafx.tools.packager.PackagerLib.generateNativeBundles(PackagerLib.java:352)
at com.sun.javafx.tools.packager.PackagerLib.generateDeploymentPackages(PackagerLib.java:319)
at com.sun.javafx.tools.packager.Main.main(Main.java:476)
Config files are saved to /var/folders/z5/n802xjnx49l4535kq63992280000gn/T/fxbundler8419176091447096668/macosx. Use them to customize package.
Exception in thread "main" com.sun.javafx.tools.packager.PackagerException: Error: Bundler "DMG Installer" (dmg) failed to produce a bundle.
at com.sun.javafx.tools.packager.PackagerLib.generateNativeBundles(PackagerLib.java:354)
at com.sun.javafx.tools.packager.PackagerLib.generateDeploymentPackages(PackagerLib.java:319)
at com.sun.javafx.tools.packager.Main.main(Main.java:476)
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.
I went to the file that it said it was having a problem with (DMSLauncher-dmg-setup.scpt) and when I ran the script manually this is what it said:
Can anyone assist me in fixing this problem? Thank you.
In case someone still sees the problem, what I did to resolve it was to check /Volumes folder and eject the volume. Here the volume would be 'DMSLauncher'.

Javapackager - NoSuchFileException while copying libraries JDK 9

When I use the javapacker command, I get a NoSuchFileException when it should copy the libraries to the app folder. I'm running the following command:
javapackager -deploy -nosign -v -native image -name test
-appclass test.Test
-srcdir "E:\projects\test\target"
-srcfiles test-1.0.jar;lib
-outdir "E:\projects\test\target\dist"
Anything seams to work fine, but i get the NoSuchFileException inside the output and the libraries inside the lib folder are missing (did not get copied).
Running [D:\Java64\jdk-9.0.4\bin\java.exe, -version]
Creating app bundle: test in E:\projects\test\target\dist
"Adding modules: [java.rmi, java.sql, javafx.web, ... long list ...
outputDir = E:\projects\test\target\dist\test\runtime
modulePath = [D:\Java64\jdk-9.0.4\jmods]
addModules = [java.rmi, java.sql, javafx.web, ... long list ...
limitModules = []
excludeFileList = .*\.diz
stripNativeCommands = true
userArguments = {}
Using default package resource [icon] (add package/windows/test.ico to the class path to customize)
Using default package resource [Template for creating executable properties file.] (add package/windows\test.properties to the class path to customize)
Running [D:\Java64\jdk-9.0.4\bin\javapackager.exe, --icon-swap, C:\Users\XXX\AppData\Local\Temp\fxbundler15945263774290817340\windows\test.ico, E:\projects\test\target\dist\test\test.exe]
Icon File Name: C:\Users\XXX\AppData\Local\Temp\fxbundler15945263774290817340\windows\test.ico
Executable File Name: E:\projects\test\target\dist\test\test.exe
Running [D:\Java64\jdk-9.0.4\bin\javapackager.exe, --version-swap, C:\Users\XXX\AppData\Local\Temp\fxbundler15945263774290817340\windows\test.properties, E:\projects\test\target\dist\test\test.exe]
Resource File Name: C:\Users\XXX\AppData\Local\Temp\fxbundler15945263774290817340\windows\test.properties
Executable File Name: E:\projects\test\target\dist\test\test.exe
Exception: java.nio.file.NoSuchFileException: E:\projects\test\target\lib\animal-sniffer-annotations-1.14.jar -> E:\projects\test\target\dist\test\app\lib\animal-sniffer-annotations-1.14.jar
Config files are saved to C:\Users\XXX\AppData\Local\Temp\fxbundler15945263774290817340\windows. Use them to customize package.
Result application bundle: E:\projects\test\target\dist
I don't know what the following line of the output is trying to tell me. The file clearly exists inside my lib folder and the javapackager did find it itself by looking inside the lib folder, that I provided with the -srcfiles test-1.0.jar;lib argument.
Exception: java.nio.file.NoSuchFileException: E:\projects\test\target\lib\animal-sniffer-annotations-1.14.jar -> E:\projects\test\target\dist\test\app\lib\animal-sniffer-annotations-1.14.jar
Any idea why javapacker complains that the file would not exist?
As per https://docs.oracle.com/javase/9/tools/javapackager.htm#JSWOR719,
-srcfiles should be provided with a list of files. lib is a directory. I would try using -srcdir.
Also, if you get
Exception: java.lang.Exception: Error: Modules are not allowed in srcfiles
it means you have to use --module-path, and then set the main module using -m <module name>

run.sh - package X does not exist

I'm running ./run.sh from Alfresco All-in-One extension but I got the error:
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-compiler-plugin:3.2:compile
(default-compile) on project repo-amp: Compilation failure:
Compilation failure:
[ERROR]
/home/user/signextension/sign/repo-amp/src/main/java/pt/empt/sign/fields/CreateFields.java:[3,25]
package com.itextpdf.text does not exist
[ERROR]
/home/user/signextension/sign/repo-amp/src/main/java/pt/empt/sign/fields/CreateFields.java:[4,25]
package com.itextpdf.text does not exist
[ERROR]
/home/user/signextension/sign/repo-amp/src/main/java/pt/empt/sign/fields/CreateFields.java:[5,1]
package com.itextpdf.text.pdf does not exist
My run.sh:
#!/bin/bash
# Downloads the spring-loaded lib if not existing and runs the full all-in-one
# (Alfresco + Share + Solr) using the runner project
springloadedfile=~/.m2/repository/org/springframework/springloaded/1.2.3.RELEASE/springloaded-1.2.3.RELEASE.jar
if [ ! -f $springloadedfile ]; then
mvn validate -Psetup
fi
MAVEN_OPTS="-javaagent:$springloadedfile -noverify -Xms256m -Xmx2G" mvn clean install -Prun
I try this:
#!/bin/bash
# Downloads the spring-loaded lib if not existing and runs the full all-in-one
# (Alfresco + Share + Solr) using the runner project
springloadedfile=~/.m2/repository/org/springframework/springloaded/1.2.3.RELEASE/springloaded-1.2.3.RELEASE.jar
itextpdffile=~/.m2/repository/com/itextpdf/itextpdf/5.5.7/itextpdf-5.5.7.jar
if [ ! -f $springloadedfile ] && [ ! -f $itextpdffile ]; then
mvn validate -Psetup
fi
MAVEN_OPTS="-javaagent:$springloadedfile -javaagent:$itextpdffile -noverify -Xms256m -Xmx2G" mvn clean install -Prun
But I got the error:
Failed to find Premain-Class manifest attribute in
/home/user/.m2/repository/com/itextpdf/itextpdf/5.5.7/itextpdf-5.5.7.jar
Error occurred during initialization of VM agent library failed to
init: instrument
Any help for solve this?
The itext library is not a javaagent library, check this link to learn more about java agents and what are they meant for !
The right way to add itext dependency to your project is by adding this snippet:
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>5.5.7</version>
</dependency>
To your main pom.xml file (or the repo-amp pom.xml alternatively) (in the dependencies section). And of course roll back any changes you made to the run.sh file !

Unable to find file associated with ANT (mac)

I recently installed ANT and I am unable to build due to a file not being found.
What I have done so far:
1) Installed ANT 1.9.2 via macports
When I type ant into terminal I get an output "Buildfile: build.xml does not exist!
Build failed". When I type ant -version I get "Apache Ant(TM) version 1.9.2 compiled on July 8 2013".
So it looks like ANT is installed.
2) Added paths for ANT_HOME and JAVA_HOME in Users/<"myName">/.bash_profile
export ANT_HOME=/usr/local/ant
export PATH=${PATH}:${ANT_HOME}/bin
export JAVA_HOME=$(/usr/libexec/java_home)
Did I do this correctly?
Now when I attempt to execute a file (java file with .xml), I get this output:
-bash-3.2$ ant execute
Buildfile: /Users/<"myName">/Desktop/CST420:SER321/Assign0/src/javaFraction/JavaFraction/build.xml
BUILD FAILED
/Users/<"myName">/Desktop/CST420:/Users/<"myName">/Desktop/CST420:SER321/Assign0/src/javaFraction/JavaFraction/build.xml:8: The following error occurred while executing this line:
java.io.FileNotFoundException: /Users/<"myName">/Desktop/CST420:/usr/local/ant/lib/ant.jar (No such file or directory)
at java.io.RandomAccessFile.open(Native Method)
at java.io.RandomAccessFile.(RandomAccessFile.java:216)
at org.apache.tools.zip.ZipFile.(ZipFile.java:211)
at org.apache.tools.zip.ZipFile.(ZipFile.java:176)
at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:255)
at org.apache.tools.ant.helper.ProjectHelper2.parseUnknownElement(ProjectHelper2.java:130)
at org.apache.tools.ant.helper.ProjectHelper2.parseAntlibDescriptor(ProjectHelper2.java:110)
at org.apache.tools.ant.taskdefs.Antlib.createAntlib(Antlib.java:91)
at org.apache.tools.ant.taskdefs.Definer.loadAntlib(Definer.java:425)
at org.apache.tools.ant.taskdefs.Definer.execute(Definer.java:277)
at org.apache.tools.ant.ComponentHelper.checkNamespace(ComponentHelper.java:874)
at org.apache.tools.ant.ComponentHelper.getDefinition(ComponentHelper.java:307)
at org.apache.tools.ant.ComponentHelper.createComponent(ComponentHelper.java:284)
at org.apache.tools.ant.ComponentHelper.createComponent(ComponentHelper.java:263)
at org.apache.tools.ant.UnknownElement.makeObject(UnknownElement.java:429)
at org.apache.tools.ant.UnknownElement.maybeConfigure(UnknownElement.java:163)
at org.apache.tools.ant.Task.perform(Task.java:347)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:179)
at org.apache.tools.ant.ProjectHelper.configureProject(ProjectHelper.java:93)
at org.apache.tools.ant.Main.runBuild(Main.java:826)
at org.apache.tools.ant.Main.startAnt(Main.java:235)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
Total time: 0 seconds
What can I do to remedy this?
Also, I seem to be stuck in the -bash-3.2 shell in my terminal (not sure if this has anything to do with the current issue). Would anyone know how I can get back to the login shell (where is displays the current directory instead of bash)?
Did you check if the file /Users/<"myName">/Desktop/CST420:/usr/local/ant/lib/ant.jar exists.
run this
ls -l /Users/<"myName">/Desktop/CST420:/usr/local/ant/lib/ant.jar
See what happens,
For the second question, try to press ctrl + d.

Categories