How to fix springboot error Failed to retrieve RMIServer stub: javax.naming.CommunicationException error during JRMP connection establishment - docker

I am having issue with springboot maven project and cassandra in docker.
I want to execute mvn verify and in pre-integration-test to start cassandra docker and api server, execute test and then in post-integration-test to stop server but I am facing error Could not contact Spring Boot application: Failed to retrieve RMIServer stub: javax.naming.CommunicationException [Root exception is java.rmi.ConnectIOException: error during JRMP connection establishment;
I have created github repo so you can easily reproduce error.
Steps to reproduce:
git clone https://github.com/gandra/docker-cassandra-with-initial-seed.git
cd docker-cassandra-with-initial-seed
mvn verify
this will produce error like this:
[INFO]
[INFO] --- spring-boot-maven-plugin:2.2.2.RELEASE:start (api-server-start) # docker-cassandra-with-initial-seed ---
[INFO] Attaching agents: []
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 18.501 s
[INFO] Finished at: 2021-01-21T18:39:05+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.2.2.RELEASE:start (api-server-start) on project docker-cassandra-with-initial-seed: Could not contact Spring Boot application: Failed to retrieve RMIServer stub: javax.naming.CommunicationException [Root exception is java.rmi.ConnectIOException: error during JRMP connection establishment; nested exception is:
[ERROR] java.io.EOFException]
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
Any idea how to fix.
p.s.
I am working on mac and this solution would work on mac and linux as well.

Code https://github.com/gandra/docker-cassandra-with-initial-seed is fixed and now working.
Basically 2 thing are changed:
Removed port mapping 9001 from docker-cassandra.sh.
Added sleep 20 seconds in cassandra_start function in docker-cassandra.sh in order to give time cassandra to properly boot up. Not nice but at least working.
Now followiung code should work with 1 integration test executing successfully:
git clone https://github.com/gandra/docker-cassandra-with-initial-seed.git
cd docker-cassandra-with-initial-seed
mvn verify

If you are using Windows, there was an issue solved in 2020 that is a little bit tricky to find (here the complete thread on Github if you want to read the full story).
Just to recap, the solution is to fix the jmxPort. For example:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<jmxPort>9011</jmxPort>
</configuration>
[...]

The problem here is that he tries to use a port that is already in use.
I had a similar problem with spring boot (not with cassandra).
Two ways i see to solving this:
First way:
Find the program that is using that port (in my case it was "Intel(R) Graphics Command Center" on port 9001). (you can use netstat /a /b in command prompt) or use tcpview (external free program)
disable the program
Profit
Second way
configuring the jmx port in your pom on the spring-boot-maven-plugin
(Answer from sixro)
BUT, i don't like this way because you basically force the others in your project to use your workaround, while the issue is on your machien.

Related

sbt compile error: java.nio.file.FileSystemException: /root: Read-only file system

I am working on a scala project that uses sbt 1.7.1
The project has its external dependencies like the database etc. that run in docker.
I'm not sure what started the issue exactly, but now when I try and go into sbt console I get this error:
[info] [launcher] getting org.scala-sbt sbt 1.7.1 (this may take some time)...
[error] [launcher] java.nio.file.FileSystemException: /root: Read-only file system
[error] [launcher] could not retrieve sbt 1.7.1
Earlier I was able to get into sbt console, but during compilation I got this error:
(I deleted the ~/.sbt folder to start over, that is when I can't even get into sbt console now)
sbt compile
[info] welcome to sbt 1.7.1 (Azul Systems, Inc. Java 11.0.10)
[info] loading settings for project app-backend-build from plugins.sbt ...
[info] loading project definition from /Users/username123/dev/git/project123/app-backend/project
[error] java.nio.file.FileSystemException: /root: Read-only file system
[error] at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:100)
[error] at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
[error] at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)
[error] at java.base/sun.nio.fs.UnixFileSystemProvider.createDirectory(UnixFileSystemProvider.java:389)
[error] at java.base/java.nio.file.Files.createDirectory(Files.java:690)
[error] at java.base/java.nio.file.Files.createAndCheckIsDirectory(Files.java:797)
[error] at java.base/java.nio.file.Files.createDirectories(Files.java:783)
[error] at lmcoursier.internal.shaded.coursier.paths.Util.createDirectories(Util.java:81)
[error] at lmcoursier.internal.shaded.coursier.paths.CachePath.withStructureLock(CachePath.java:140)
[error] at lmcoursier.internal.shaded.coursier.cache.CacheLocks$.withStructureLock(CacheLocks.scala:20)
[error] at lmcoursier.internal.shaded.coursier.cache.CacheLocks$.withLockOr(CacheLocks.scala:37)
[error] at lmcoursier.internal.shaded.coursier.cache.internal.Downloader$Blocking$.remote(Downloader.scala:408)
[error] at lmcoursier.internal.shaded.coursier.cache.internal.Downloader.$anonfun$remote$5(Downloader.scala:510)
[error] at scala.concurrent.Future$.$anonfun$apply$1(Future.scala:659)
[error] at scala.util.Success.$anonfun$map$1(Try.scala:255)
[error] at scala.util.Success.map(Try.scala:213)
[error] at scala.concurrent.Future.$anonfun$map$1(Future.scala:292)
[error] at scala.concurrent.impl.Promise.liftedTree1$1(Promise.scala:33)
[error] at scala.concurrent.impl.Promise.$anonfun$transform$1(Promise.scala:33)
[error] at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:64)
[error] at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
[error] at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
[error] at java.base/java.lang.Thread.run(Thread.java:834)
[error] (update) java.nio.file.FileSystemException: /root: Read-only file system
[warn] Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? (default: r)
If I go into a different folder, and try and create a new sbt project I get the same error:
sbt new scala/scala-seed.g8
I am using sdkman for my sbt installation, I deleted the .sbt folder and uninstalled sbt 1.7.1 and then re-installed it...that didn't help.
It seems as though some process has locked something related to sbt or coursier cache?
My project does have multiple modules, i'm not sure what root means in the error message.. the root project or some root folder that coursier might be using?
My sbt project was running fine earlier today, and now I cannot do anything related to scala on my system that uses sbt.
My system is running OSX, 13.0.1 (22A400).
Java home: ~/.jabba/jdk/zulu#1.11.0/Contents/Home
I just tried deleting the coursier cache and no change:
rm -Rf ~/Library/Caches/Coursier
That sbt console would run and compile the project.

Sonarqube server not reachable

I am running simple java based web application using maven as building tool.
but when I build the project in jenkins I am getting below error.`
[ERROR] SonarQube server [localhost:9000] can not be reached
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar (default-cli) on project webapp:
Unable to execute SonarQube: Fail to get bootstrap index from server:
Failed to connect to localhost/127.0.0.1:9000: Connection refused (Connection refused) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
ERROR] Re-run Maven using the -X switch to enable full debug logging

how to setup maven setup for jenkins

I'm quite new to Jenkins setup.
Using Eclipse,spring,maven project
Jenkins 의 Global Tool Configuration 에서
NAME: MAVEN_HOME
install from apache 3.6.0
error is following
[INFO] Copying 19 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # egov
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 15 source files to
C:\Users\Administrator.jenkins\workspace\TestJob1\target\classes
[INFO]
[INFO] BUILD FAILURE
[INFO]
[INFO] Total time: 2.154 s
[INFO] Finished at: 2018-12-01T01:44:07Z
[INFO]
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-compiler-plugin:3.1:compile
(default-compile) on project egov: Fatal error compiling:
CompilerException: NullPointerException -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with
the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions,
please read the following articles:
[ERROR] [Help 1]
http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Build step 'Invoke top-level Maven targets' marked build as failure
Finished: FAILURE
In your pipeline (which you should post) run a maven --version and make sure the JRE that is running Maven is also a JDK.
Also, it looks like your Jenkins is running as an administrator. That's not a good idea because the jobs (pipelines) will have admin access to the host.

JENKINS: Unable to load the mojo 'test'

When I am running build from jenkins. I am getting below error.The command I am running is mvn -P dev clean install
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M1:test (default-test) on project OMS: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M1:test failed: Unable to load the mojo 'test' (or one of its required components) from the plugin 'org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M1': com.google.inject.ProvisionException: Guice provision errors:
[ERROR]
[ERROR] 1) No implementation for org.codehaus.plexus.languages.java.jpms.LocationManager was bound.
[ERROR] while locating org.apache.maven.plugin.surefire.SurefirePlugin
[ERROR] at ClassRealm[plugin>org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M1, parent: sun.misc.Launcher$AppClassLoader#5c647e05]
[ERROR] while locating org.apache.maven.plugin.Mojo annotated with #com.google.inject.name.Named(value=org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M1:test)
[ERROR]
[ERROR] 1 error
[ERROR] role: org.apache.maven.plugin.Mojo
[ERROR] roleHint: org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M1:test
But if I run the same command on the build machine manually. The build is getting successful. why I am getting error? I can't make the changes into pom as it is building successful while running mvn command directly.

SonarQube server [https://localhost:9000] can not be reached in Jenkins

I want to build a code coverage from sonarqube in Jenkins. The project is from github. I have configure everything that are necessary but the following errors still arise. Can someone please help me to solve this?
Established TCP socket on 59508
[OData] $ java -cp "D:\Program Files\plugins\maven-plugin\WEB-INF\lib\maven35-agent-1.12-alpha-1.jar;D:\downloads\apache-maven-3.5.4\boot\plexus-classworlds-2.5.2.jar;D:\downloads\apache-maven-3.5.4/conf/logging" jenkins.maven3.agent.Maven35Main D:\downloads\apache-maven-3.5.4 "D:\Program Files\war\WEB-INF\lib\remoting-3.21.1.jar" "D:\Program Files\plugins\maven-plugin\WEB-INF\lib\maven35-interceptor-1.12-alpha-1.jar" "D:\Program Files\plugins\maven-plugin\WEB-INF\lib\maven3-interceptor-commons-1.12-alpha-1.jar" 59508
<===[JENKINS REMOTING CAPACITY]===>channel started
Executing Maven: -B -f D:\Program Files\workspace\OData\pom.xml clean sonar:sonar
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------------< OData:OData >-----------------------------
[INFO] Building OData 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # OData ---
[WARNING] Attempt to (de-)serialize anonymous class hudson.maven.reporters.MavenArtifactArchiver$2; see: https://jenkins.io/redirect/serialization-of-anonymous-classes/
[WARNING] Attempt to (de-)serialize anonymous class hudson.maven.reporters.MavenFingerprinter$1; see: https://jenkins.io/redirect/serialization-of-anonymous-classes/
[INFO]
[INFO] ----------------------------< OData:OData >-----------------------------
[INFO] Building OData 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- sonar-maven-plugin:3.4.1.1168:sonar (default-cli) # OData ---
[INFO] User cache: C:\WINDOWS\system32\config\systemprofile\.sonar\cache
[ERROR] SonarQube server [https://localhost:9000] can not be reached
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.056 s
[INFO] Finished at: 2018-08-27T00:09:08+08:00
[INFO] ------------------------------------------------------------------------
Waiting for Jenkins to finish collecting data
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.4.1.1168:sonar (default-cli) on project OData: Unable to execute SonarQube: Fail to get bootstrap index from server: Unrecognized SSL message, plaintext connection? -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[JENKINS] Archiving D:\Program Files\workspace\OData\pom.xml to OData/OData/0.0.1-SNAPSHOT/OData-0.0.1-SNAPSHOT.pom
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
channel stopped
WARN: Unable to locate 'report-task.txt' in the workspace. Did the SonarScanner succedeed?
Skipping sonar analysis due to bad build status FAILURE
Finished: FAILURE
for your OData project, when your way to scan the code is via jenkins, you have to set in the settings of jenkins with the hostname, don´t recommend put "localhost" or "127.0.0.1"
Try with $HOSTNAME:
Go to Settings in Jenkins
Move to "Sonarqube Servers"
SonarQube servers
-- Sonarqube instalations
--- ie: http://myserversonarqube:9000
Regards.
Error below is self explanatory. I have below questions
Is Sonarqube running on localhost with port 9000 as Secured (i.e https) ?
Which version of maven you are using? sometimes some of the Sonar plugin versions does not work with old maven versions.
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-
plugin:3.4.1.1168:sonar (default-cli) on project OData: Unable to execute SonarQube:
Fail to get bootstrap index from server: Unrecognized SSL message, plaintext connection? -> [Help 1]
[ERROR]

Resources