Unable to run mvn release:prepare from IntelliJ using bundled Maven - java

I have a Maven project in IntelliJ working with the bundled version of Maven however when I come to do a release:prepare release:perform directly from within the IDE I get the following error.
Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.5.3:prepare (default-cli) on project XXXXXX: Maven execution failed, exit code: '126'
Within IntelliJ I am using a project specific JDK (JDK 8) which is different to my machine JDK (JDK 11). I also am using the bundled Maven 3 with IntelliJ 2020.1 but have no Maven installed on my machine outside of the IDE.
I don't use JDK 8 or Maven anywhere other than this one project so would like to not have to install the extra tools globally if I can get away with running then from within this one project in the IDE. Is that possible? I'm building a Jenkins plugin for context if that matters?
Question: What is exit code 126?
Question: In order to perform a release:prepare release:perform do I need to to install the bundled project specific tools on my machine as opposed to keeping them within my project in IntelliJ?
Edit: Running with -x or --debug yields this error:
[INFO] Executing: /bin/sh -c cd /home/XXX/Development/XXXXX-plugin && /home/XXXX/.local/share/JetBrains/Toolbox/apps/IDEA-C/ch-0/201.7223.91/plugins/maven/lib/maven3/bin/mvn -s /tmp/release-settings2724175258197430802.xml clean install --no-plugin-updates -P jenkins
/bin/sh: 1: /home/XXXX/.local/share/JetBrains/Toolbox/apps/IDEA-C/ch-0/201.7223.91/plugins/maven/lib/maven3/bin/mvn: Permission denied
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE

It appears to be this bug: https://youtrack.jetbrains.com/issue/IDEA-139236
Which is duplicated by: https://youtrack.jetbrains.com/issue/IDEA-157229 that contains the following workaround:
Using a newly generated plugin project using the
maven-archytype-plugin, when I tried running the default integration
test, it failed due to the following error:
/bin/sh: /Applications/IntelliJ IDEA 14.app/Contents/plugins/maven/lib/maven3/bin/mvn: Permission denied
When checking the /Applications/IntelliJ IDEA
14.app/Contents/plugins/maven/lib/maven3/bin/:
evil-jim-klo:lib2 jklo$ cd "/Applications/IntelliJ IDEA 14.app/Contents/plugins/maven/lib/maven3/bin/"
evil-jim-klo:bin jklo$ ls -l
total 88
-rw-r--r--# 1 jklo admin 183 Dec 21 04:08 m2.conf
-rw-r--r--# 1 jklo admin 5063 Dec 21 04:08 mvn
-rw-r--r--# 1 jklo admin 5985 Dec 21 04:08 mvn.bat
-rw-r--r--# 1 jklo admin 5253 Dec 21 04:08 mvnDebug
-rw-r--r--# 1 jklo admin 6167 Dec 21 04:08 mvnDebug.bat
-rw-r--r--# 1 jklo admin 5539 Dec 21 04:08 mvnyjp
Note none of the files are set to executable. The expectation is that
all maven binaries should be executable by default upon installation
or application update.
I corrected the problem by performing:
chmod a+x *
chmod a-x m2.conf
to produce the following permissions:
evil-jim-klo:bin jklo$ ls -l
total 88
-rw-r--r--# 1 jklo admin 183 Dec 21 04:08 m2.conf
-rwxr-xr-x# 1 jklo admin 5063 Dec 21 04:08 mvn
-rwxr-xr-x# 1 jklo admin 5985 Dec 21 04:08 mvn.bat
-rwxr-xr-x# 1 jklo admin 5253 Dec 21 04:08 mvnDebug
-rwxr-xr-x# 1 jklo admin 6167 Dec 21 04:08 mvnDebug.bat
-rwxr-xr-x# 1 jklo admin 5539 Dec 21 04:08 mvnyjp

You should use a local install of maven on your machine. You need to tell IntelliJ to use that version of maven in Preferences > Build, Execution, Deployment > Build Tools > Maven > "Maven home directory"

Related

IntelliJ can't find installed packages

I've just installed IntelliJ and imported a Maven / Spring Boot project. I've set up my run configuration as "application", but when I try to run it, it fails and complains of not being able to resolve dependencies. When I check my local Maven repository, those dependencies are installed:
/Users/user/Projects/myapplication/src/test/java/com/something
/SomethingServiceTest.java:23:29
java: package org.junit.jupiter.api does not exist
local maven repo:
$ ll ~/.m2/repository/org/junit/jupiter/
total 0
drwxr-xr-x 6 user Users 192B 21 Aug 2020 ./
drwxr-xr-x 6 user Users 192B 2 Sep 2020 ../
drwxr-xr-x 3 user Users 96B 21 Aug 2020 junit-jupiter/
drwxr-xr-x 3 user Users 96B 21 Aug 2020 junit-jupiter-api/
drwxr-xr-x 3 user Users 96B 21 Aug 2020 junit-jupiter-engine/
drwxr-xr-x 3 user Users 96B 21 Aug 2020 junit-jupiter-params/
IntelliJ and the pom.xml are probably not in-sync.
Right click on the pom.xml and Maven -> Reload Project
I've been the same problems. Sometimes I try to remove or change the name of the ~/.m2/repository directory.
After that, I make
mvn clean compile and install
Try this.

Logstash persistent queue files changes owner to root and gets inaccessible by java

I have just updated my ELK-Stack to 7.9.1 from 7.0.1 (using apt)
System: Ubuntu 18.04.5 LTS
Besides some permission issues I won't get into here there seems to be a problem with permissions for my persistent queue tail files.
as the page.nnn file is updated it gets owned by root which causes java to fail.
Steps to reproduce:
change owner for pipeline tail file folder to logstash.
/data/logstash/data/queue/my_pipeline$ ls -l
total 47016
-rw-r--r-- 1 logstash logstash 34 Oct 21 08:56 checkpoint.head
-rw-r--r-- 1 logstash logstash 67108864 Oct 21 08:56 page.868
Push data to Logstash using FileBeat
Check owner of files
/data/logstash/data/queue/my_pipeline$ ls -l
total 8
-rw-r--r-- 1 root root 34 Oct 21 09:12 checkpoint.head
-rw-r--r-- 1 root root 67108864 Oct 21 09:12 page.869
The error:
/data/logstash/data/queue/my_pipeline$ sudo journalctl -e --unit=logstash | grep FileNotFoundException | tail -1
Oct 21 09:29:06 my_server.my_domain.com logstash[38158]: [2020-10-21T09:29:06,496][ERROR][logstash.agent ]
Failed to execute action {
:action => LogStash::PipelineAction::Create/pipeline_id:my_pipeline, :exception => "Java::JavaLang::IllegalStateException",
:message => "java.io.FileNotFoundException: /data/logstash/data/queue/my_pipeline/page.869 (Permission denied)",
:backtrace => ["org.logstash.execution.AbstractPipelineExt.openQueue(AbstractPipelineExt.java:204)",
"org.logstash.execution.AbstractPipelineExt$INVOKER$i$0$0$openQueue.call(AbstractPipelineExt$INVOKER$i$0$0$openQueue.gen)",
"org.jruby.internal.runtime.methods.JavaMethod$JavaMethodN.call(JavaMethod.java:831)",
"org.jruby.ir.targets.InvokeSite.invoke(InvokeSite.java:207)",
"usr.share.logstash.logstash_minus_core.lib.logstash.java_pipeline.RUBY$method$initialize$0(/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:45)",
"org.jruby.internal.runtime.methods.CompiledIRMethod.call(CompiledIRMethod.java:80)",
"org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:70)",
"org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:332)",
"org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:86)",
"org.jruby.RubyClass.newInstance(RubyClass.java:939)",
"org.jruby.RubyClass$INVOKER$i$newInstance.call(RubyClass$INVOKER$i$newInstance.gen)",
"org.jruby.ir.targets.InvokeSite.invoke(InvokeSite.java:207)",
"usr.share.logstash.logstash_minus_core.lib.logstash.pipeline_action.create.RUBY$method$execute$0(/usr/share/logstash/logstash-core/lib/logstash/pipeline_action/create.rb:52)",
"usr.share.logstash.logstash_minus_core.lib.logstash.pipeline_action.create.RUBY$method$execute$0$__VARARGS__(/usr/share/logstash/logstash-core/lib/logstash/pipeline_action/create.rb)",
"org.jruby.internal.runtime.methods.CompiledIRMethod.call(CompiledIRMethod.java:80)",
"org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:70)",
"org.jruby.ir.targets.InvokeSite.invoke(InvokeSite.java:207)",
"usr.share.logstash.logstash_minus_core.lib.logstash.agent.RUBY$block$converge_state$2(/usr/share/logstash/logstash-core/lib/logstash/agent.rb:357)",
"org.jruby.runtime.CompiledIRBlockBody.callDirect(CompiledIRBlockBody.java:138)",
"org.jruby.runtime.IRBlockBody.call(IRBlockBody.java:58)",
"org.jruby.runtime.IRBlockBody.call(IRBlockBody.java:52)",
"org.jruby.runtime.Block.call(Block.java:139)", "org.jruby.RubyProc.call(RubyProc.java:318)",
"org.jruby.internal.runtime.RubyRunnable.run(RubyRunnable.java:105)",
"java.lang.Thread.run(Thread.java:748)"]
}
I have sourced through config-files for Logstash without being able to find any settings for this. My suspicion is that it's related to my JRE, but as I am not proficient enough I am not able to find the reason for this.
tl;dr: How to make Logstash persistent queue tail files owned by logstash permanently?

Jenkins startup error: jenkins.model.InvalidBuildsDir: does not contain ${ITEM_FULL_NAME} or ${ITEM_ROOTDIR}, cannot distinguish between projects

Help please. In our workflow we only work with pre-packaged offline deploys where we do not have root access and therefore use supervisord to stop start ALL packages. We deploy all our packages under a user account. I have created a custom Jenkins package. Its basically its a folder containing the Jenkins war file and configurations from when I tool a vanilla initial setup.
My installation has worked up until now. Seems trying to get things running for the first time seems flaky. Once running Jenkins is fine. This time I am trying to deploy the packages (they have not changed) however I cannot start Jenkins and get and error:
jenkins.model.InvalidBuildsDir: does not contain ${ITEM_FULL_NAME} or ${ITEM_ROOTDIR}, cannot distinguish between projects
So what I did was get a clean fresh install running and packaged it up. Basically I untar the jenkins directory then use supervisord to control start/stop.
Supervisord config:
[program:jenkins]
autorestart = true
autostart = true
command = /bin/bash -c "set JENKINS_HOME=/opt/home/svc_user/opskit/jenkins; /opt/home/svc_user/opskit/jdk/bin/java -Djava.awt.headless=true -Djenkins.model.Jenkins.buildsDir=/opt/home/svc_user/data/jenkins/builds/${ITEM_FULL_NAME} -Djenkins.model.Jenkins.workspacesDir=/opt/home/svc_user/data/jenkins/workspace/${ITEM_FULL_NAME} -jar /opt/home/svc_user/opskit/jenkins/bin/jenkins.war -path=/opt/home/svc_user/opskit/jenkins"
directory = /opt/home/svc_user/opskit/jenkins
redirect_stderr = true
stdout_logfile = /opt/home/svc_user/opskit/log/jenkins.log
stdout_logfile_backups = 5
stdout_logfile_maxbytes = 10MB
stopwaitsecs = 300
Full error:
jenkins.model.InvalidBuildsDir: /opt/home/svc_user/data/jenkins/builds does not contain ${ITEM_FULL_NAME} or ${ITEM_ROOTDIR}, cannot distinguish between projects
at jenkins.model.Jenkins.checkRawBuildsDir(Jenkins.java:3179)
at jenkins.model.Jenkins.setBuildsAndWorkspacesDir(Jenkins.java:3135)
at jenkins.model.Jenkins.loadConfig(Jenkins.java:3123)
Caused: java.io.IOException
at jenkins.model.Jenkins.loadConfig(Jenkins.java:3125)
at jenkins.model.Jenkins.access$1200(Jenkins.java:320)
at jenkins.model.Jenkins$13.run(Jenkins.java:3219)
at org.jvnet.hudson.reactor.TaskGraphBuilder$TaskImpl.run(TaskGraphBuilder.java:169)
at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:296)
at jenkins.model.Jenkins$5.runTask(Jenkins.java:1133)
at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:214)
at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:117)
at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:59)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused: org.jvnet.hudson.reactor.ReactorException
at org.jvnet.hudson.reactor.Reactor.execute(Reactor.java:282)
at jenkins.InitReactorRunner.run(InitReactorRunner.java:50)
at jenkins.model.Jenkins.executeReactor(Jenkins.java:1166)
at jenkins.model.Jenkins.<init>(Jenkins.java:966)
at hudson.model.Hudson.<init>(Hudson.java:85)
at hudson.model.Hudson.<init>(Hudson.java:81)
at hudson.WebAppMain$3.run(WebAppMain.java:233)
Caused: hudson.util.HudsonFailedToLoad
at hudson.WebAppMain$3.run(WebAppMain.java:250)
Jenkins config.xml:
<workspaceDir>/opt/home/svc_user/data/jenkins/workspace/${ITEM_FULL_NAME}</workspaceDir>
<buildsDir>/opt/home/svc_user/data/jenkins/builds/${ITEM_FULL_NAME}</buildsDir>
Folder permissions (install dir):
lrwxrwxrwx 1 svc_user svc_user 39 Jun 4 02:51 jenkins -> /opt/home/svc_user/opskit/jenkins-2.222.3
drwxr-xr-x 13 svc_user svc_user 4096 May 1 05:07 jenkins-2.222.3
Folder permissions (custom dir for builds and workspaces):
lrwxrwxrwx 1 svc_user svc_user 37 Jun 4 02:51 jenkins -> /opt/home/svc_user/data/jenkins-2.222.3
drwxr-xr-x 4 svc_user svc_user 37 Jun 4 16:39 jenkins-2.222.3
|-nginx-1.16.1
|-jdk-8u91
|-jenkins-2.222.3
| |-builds
| |-workspace
Help would be greatly appreciated. Thank you in advance.
Modified this:
command = /bin/bash -c "JENKINS_HOME=/opt/home/svc_user/opskit/jenkins /opt/home/svc_user/opskit/jdk/bin/java...
^^
Nothing to do with the fix, just launches 1 java process instead of 2.
Deleted:
-Djenkins.model.Jenkins.buildsDir=/opt/home/svc_user/data/jenkins/builds/${ITEM_FULL_NAME}
-Djenkins.model.Jenkins.workspacesDir=/opt/home/svc_user/data/jenkins/workspace/${ITEM_FULL_NAME}
^^
Fixed my startup issue. Not sure why these had no negative effects on previous installations.
Also deleted:
path=/opt/home/svc_user/opskit/jenkins
Seemed isnt necessary.
¯_(ツ)_/¯

How to have IntelliJ automatically overwrite files when exporting jar

In eclipse it does it anyway when exporting jars, and will only give a warning unless you tell it not to. However in IntelliJ, it refuses to delete the file when building a new version, and I have to go through and manually delete the jar myself for IntelliJ to export properly. Is there a way I force IntelliJ to overwrite jars when it exports?
IntelliJ always overrides artifacts. Try it again. Make sure no other process is using the file with:
$ lsof |grep [file name]
I just tried to make a project with artifact generation, no issues whatsoever.
bender:queues_jar demo$ ls -ltra
total 1408
-rw-r--r-- 1 demo staff 718737 Feb 11 21:26 queues.jar
drwxr-xr-x 3 demo staff 102 Feb 11 21:26 ..
drwxr-xr-x 3 demo staff 102 Feb 11 21:26 .
bender:queues_jar demo$ ls -ltra
total 1408
drwxr-xr-x 3 demo staff 102 Feb 11 21:26 ..
-rw-r--r-- 1 demo staff 718737 Feb 11 21:27 queues.jar
drwxr-xr-x 3 demo staff 102 Feb 11 21:27 .

Subclipse can't rename file (OS X)

I can't perform any Subversion operations on my Eclipse project as Subclipse can't rename a file. The error is:
Caused by: org.tigris.subversion.javahl.ClientException: svn: Cannot rename file '/Users/damianharvey/Sites/Odyssey3.5/OdysseyEDIJAXB/src/com/locuslive/edi/edifact/d95b/coreor/.svn/tmp/entries' to '/Users/damianharvey/Sites/Odyssey3.5/OdysseyEDIJAXB/src/com/locuslive/edi/edifact/d95b/coreor/.svn/entries'
at org.tigris.subversion.javahl.JavaHLObjectFactory.throwException(JavaHLObjectFactory.java:777)
at org.tmatesoft.svn.core.javahl.SVNClientImpl.throwException(SVNClientImpl.java:1850)
at org.tmatesoft.svn.core.javahl.SVNClientImpl.cleanup(SVNClientImpl.java:863)
at org.tigris.subversion.svnclientadapter.javahl.AbstractJhlClientAdapter.cleanup(AbstractJhlClientAdapter.java:1958)
... 8 more
Caused by: org.tmatesoft.svn.core.SVNException: svn: Cannot rename file '/Users/damianharvey/Sites/Odyssey3.5/OdysseyEDIJAXB/src/com/locuslive/edi/edifact/d95b/coreor/.svn/tmp/entries' to '/Users/damianharvey/Sites/Odyssey3.5/OdysseyEDIJAXB/src/com/locuslive/edi/edifact/d95b/coreor/.svn/entries'
I'm running OSX Snow Leopard, Eclipse 3.5, Subclipse 1.6.5.
It looks like a permissions problem. If I list the directories in the error I get:
drwxrwxrwx 8 damianharvey staff 272 19 Nov 17:43 .
drwxrwxrwx 16 damianharvey staff 544 21 Sep 14:53 ..
-r--r--r-- 1 damianharvey staff 2030 21 Sep 14:53 all-wcprops
-r--r--r-- 1 damianharvey staff 2313 21 Sep 14:53 entries
drwxrwxrwx 2 damianharvey staff 68 21 Sep 14:53 prop-base
drwxrwxrwx 2 damianharvey staff 68 21 Sep 14:53 props
drwxrwxrwx 15 damianharvey staff 510 21 Sep 14:53 text-base
drwxrwxrwx 6 damianharvey staff 204 19 Nov 17:19 tmp
So I assume that it's the read-only permissions that is preventing this. If I try to chmod this to a very broad 777:
sudo chmod 777 /Users/damianharvey/Sites/Odyssey3.5/OdysseyEDIJAXB/src/com/locuslive/edi/edifact/d95b/coreor/.svn/entries
chmod: Unable to change file mode on /Users/damianharvey/Sites/Odyssey3.5/OdysseyEDIJAXB/src/com/locuslive/edi/edifact/d95b/coreor/.svn/entries: Operation not permitted
Any ideas? Would quite like to commit my code.
Many Thanks.
No worries. Aunty Google found it for me
chflags -R nouchg .
From the comments here:
If you're changing workspaces on OS X
and you import an SVN-based project
into your new workspace, some of your
files may have the uchg flag set.
SubClipse/SVN will not be able to
update this project. You will get an
error:
svn: Cannot rename file
every time you try invoke svn. If you
issue:
chflags -R nouchg .
at the top-level of the project
directory this will clear these flags
and restore SVN function.

Categories