Unable to load class error with sonarqube in gitlab - javascript

I've been having troubles with getting gitlab to send jobs to sonarqube. I have installed the sonarqube plugin and added my gitlab user token to the sonarqube server. In my gitlab-ci.yml I run the following command:
- git config --global user.email "$GITLAB_USER_EMAIL"
- git config --global user.name "$GITLAB_USER_NAME"
- cd /opt
- wget -q https://sonarsource.bintray.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-3.2.0.1227-linux.zip
- unzip -qq sonar-scanner-cli-3.2.0.1227-linux.zip
- cd /builds/my_user_name/my_project/backend
- /opt/sonar-scanner-3.2.0.1227-linux/bin/sonar-scanner -X -Dsonar.host.url=http://34.230.xx.xx -Dsonar.projectKey=$CI_PROJECT_NAME.develop -Dsonar.projectVersion=$CI_COMMIT_SHA -Dsonar.gitlab.url=https://www.gitlab.com -Dsonar.gitlab.project_id=$CI_PROJECT_ID -Dsonar.gitlab.user_token=$SONAR_PLUGIN_TOKEN -Dsonar.gitlab.commit_sha=$CI_COMMIT_SHA -Dsonar.gitlab.ref_name=$CI_COMMIT_REF_NAME -Dsonar.analysis.mode=preview -Dsonar.sources=.
The error I get is the following. I get this error both with using the npm sonarqube-scanner as well. Does anyone know what is going on?
05:12:15.795 DEBUG: * GitLab 3.0.0 (gitlab)
05:12:16.171 INFO: Process project properties
05:12:16.184 DEBUG: Process project properties (done) | time=13ms
05:12:16.199 INFO: Load project repositories
05:12:16.227 DEBUG: GET 404 http://34.230.xx.xx/batch/project.protobuf?key=my_key_here&issues_mode=true | time=25ms
05:12:16.229 DEBUG: Project repository not available - continuing without it
05:12:16.234 WARN: Project doesn't exist on the server. All issues will be marked as 'new'.
05:12:16.235 INFO: Load project repositories (done) | time=36ms
05:12:16.314 INFO: Scanning only changed files
05:12:16.317 INFO: Execute project builders
05:12:16.999 INFO: ------------------------------------------------------------------------
05:12:17.006 INFO: EXECUTION FAILURE
05:12:17.007 INFO: ------------------------------------------------------------------------
05:12:17.008 INFO: Total time: 4.682s
05:12:17.050 INFO: Final Memory: 11M/104M
05:12:17.051 INFO: ------------------------------------------------------------------------
05:12:17.052 ERROR: Error during SonarQube Scanner execution
java.lang.IllegalStateException: Unable to load component class org.sonar.scanner.scan.ProjectLock
at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:64)
at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:678)
at org.sonar.core.platform.ComponentContainer.getComponentByType(ComponentContainer.java:265)
at org.sonar.scanner.scan.ProjectScanContainer.doBeforeStart(ProjectScanContainer.java:120)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:133)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:121)
at org.sonar.scanner.task.ScanTask.execute(ScanTask.java:48)
at org.sonar.scanner.task.TaskContainer.doAfterStart(TaskContainer.java:84)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:121)
at org.sonar.scanner.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:121)
at org.sonar.batch.bootstrapper.Batch.doExecuteTask(Batch.java:116)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:71)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
at com.sun.proxy.$Proxy0.execute(Unknown Source)
at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:171)
at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:128)
at org.sonarsource.scanner.cli.Main.execute(Main.java:111)
at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
at org.sonarsource.scanner.cli.Main.main(Main.java:61)
Caused by: java.lang.IllegalStateException: Unable to load component class org.sonar.scanner.scan.DefaultInputModuleHierarchy
at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:64)
at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:632)
at org.picocontainer.parameters.BasicComponentParameter$1.resolveInstance(BasicComponentParameter.java:118)
at org.picocontainer.parameters.ComponentParameter$1.resolveInstance(ComponentParameter.java:136)
at org.picocontainer.injectors.SingleMemberInjector.getParameter(SingleMemberInjector.java:78)
at org.picocontainer.injectors.ConstructorInjector$CtorAndAdapters.getParameterArguments(ConstructorInjector.java:309)
at org.picocontainer.injectors.ConstructorInjector$1.run(ConstructorInjector.java:335)
at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270)
at org.picocontainer.injectors.ConstructorInjector.getComponentInstance(ConstructorInjector.java:364)
at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.getComponentInstance(AbstractInjectionFactory.java:56)
at org.picocontainer.behaviors.AbstractBehavior.getComponentInstance(AbstractBehavior.java:64)
at org.picocontainer.behaviors.Stored.getComponentInstance(Stored.java:91)
at org.picocontainer.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:699)
at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:647)
.....

Check your Sonar plugins versions, compared to your SonarQube version.
As in this thread, you would (for instance) be running SonarQube 7.1 with extensions made for SonarQube 7.0 (Branch, Developer).
The OP Coherent reports in the comments using:
docker run -d --name sonarqube -p 80:9000 -p 9092:9092 \
-e SONARQUBE_JDBC_USERNAME=x
-e SONARQUBE_JDBC_PASSWORD=y
-e SONARQUBE_JDBC_URL=jdbc:postgresql://mydatabase-east-1.rds.amazonaws.com/sonar sonarqube:7.0
Tibor Blenessy adds
Try to remove -Dsonar.analysis.mode=preview, this option is no longer supported.

Related

Moralis-Server in vscode

when I type this code ( npm run moralis:sync), I run into this error:
my-app#0.1.0 moralis:sync
moralis-admin-cli connect-local-devchain --chain hardhat --moralisSubdomain cxdjddn5lxdh.usemoralis.com --frpcPath ./frp/frpc
Starting connection to Hardhat
exec error: Error: Command failed: "./frp/frpc" http -s cxdjddn5lxdh.usemoralis.com:7000 -t GCqiUSu6wG -l 8545 -d cxdjddn5lxdh.usemoralis.com
'"./frp/frpc"' is not recognized as an internal or external command,
operable program or batch file.
Hello which version of frp have you installed? Make sure your fprcPath is correct.
Two related threads:
https://forum.moralis.io/t/unable-to-connect-hardhat-local-node-to-moralis/17154
https://forum.moralis.io/t/which-frpc-file-to-download-to-connect-moralis-server-to-blockchain/17294/15
If you have more questions or issues with this, you can post on the Moralis forum: https://forum.moralis.io

React Native Project BUILDS Succesfull(with deprecated warning) and opens in my emulator, but keeps loading forever

I used yarn to install the packages, Im using typescript, my index is JS.
I'm getting a white screen with the load symbol on the emulator..
Thanks for the ones helping
Here's what Im getting:
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
(node:41396) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
Jetifier found 1123 file(s) to forward-jetify. Using 4 workers...
info JS server already running.
info Installing the app...
> Task :app:installDebug
09:49:22 V/ddms: execute: running am get-config
09:49:22 V/ddms: execute 'am get-config' on 'emulator-5554' : EOF hit. Read: -1
09:49:22 V/ddms: execute: returning
Installing APK 'app-debug.apk' on 'Pixel_2_API_28(AVD) - 9' for app:debug
09:49:22 D/app-debug.apk: Uploading app-debug.apk onto device 'emulator-5554'
09:49:22 D/Device: Uploading file onto device 'emulator-5554'
09:49:22 D/ddms: Reading file permision of C:\Users\Daniel\CalcSol\android\app\build\outputs\apk\debug\app-debug.apk as: rwx------
09:49:22 V/ddms: execute: running pm install -r -t "/data/local/tmp/app-debug.apk"
09:49:24 V/ddms: execute 'pm install -r -t "/data/local/tmp/app-debug.apk"' on 'emulator-5554' : EOF hit. Read: -1
09:49:24 V/ddms: execute: returning
09:49:24 V/ddms: execute: running rm "/data/local/tmp/app-debug.apk"
09:49:24 V/ddms: execute 'rm "/data/local/tmp/app-debug.apk"' on 'emulator-5554' : EOF hit. Read: -1
09:49:24 V/ddms: execute: returning
Installed on 1 device.
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.2/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 29s
141 actionable tasks: 2 executed, 139 up-to-date
info Connecting to the development server...
info Starting the app on "emulator-5554"...
Starting: Intent { cmp=com.calcsol/.MainActivity }'''
You can try:
Delete node_modules and re-install
Go to your android folder and delete the file .idea
In Android Studio: file > Invalidate Caches / Restart and select 'Invalidate and Restart'

Mongodb v4.0 Transaction, MongoError: Transaction numbers are only allowed on a replica set member or mongos

I've installed MongoDB v4.0 for the most amazing feature of it Transaction in Nodejs with mongodb 3.1 as a driver.
When I try to use a transaction session I've faced this error:
MongoError: Transaction numbers are only allowed on a replica set member or mongos.
What's that and how can I get rid of it?
Transactions are undoubtedly the most exciting new feature in MongoDB 4.0. But unfortunately, most tools for installing and running MongoDB start a standalone server as opposed to a replica set. If you try to start a session on a standalone server, you'll get this error.
In order to use transactions, you need a MongoDB replica set, and starting a replica set locally for development is an involved process. The new run-rs npm module makes starting replica sets easy. Running run-rs is all you need to start a replica set, run-rs will even install the correct version of MongoDB for you.
Run-rs has no outside dependencies except Node.js and npm. You do not need to have Docker, homebrew, APT, Python, or even MongoDB installed.
Install run-rs globally with npm's -g flag. You can also list run-rs in your package.json file's devDependencies.
npm install run-rs -g
Next, run run-rs with the --version flag. Run-rs will download MongoDB v4.0.0 for you. Don't worry, it won't overwrite your existing MongoDB install.
run-rs -v 4.0.0 --shell
Then use replicaSet=rs in your connection string.
You find more details about it here.
I got the solution, and it's just three lines configuration inside the MongoDB config file.
After switching from MongoDB atlas and installing MongoDB v 4.4.0 on my CentOS 7 VPS with WHM, I faced that issue also.
the run-rs solution does not work for me, but I managed to solve this issue without any third-party tool, following these steps:
1. turn off mongod.
the most efficient way is by entering the MongoDB shell with the command mongo
checkout the method
db.shutdownServer()
You will be no ability to use the MongoDB server.
For me, the shutdown process took too long, and then I killed the process with the command:
systemctl stop -f mongod
if you killed the mongod process,s probably you will need to run
mongod --dbpath /var/db --repair
The var/db should point to your database directory.
2. setting replicaSet configuration.
for the replicaSet settings step, check out the /etc/mongod.conf file,
look for the replication value line, and you should add the following lines as below:
replication:
oplogSizeMB: <int>
replSetName: <string>
enableMajorityReadConcern: <boolean>
use the replSetName value on the next step.
an example of those settings:
oplogSizeMB: 2000
replSetName: rs0
enableMajorityReadConcern: false
3. add your connection string URL.
add the value of replSetName to your connection URL &replicaSet=--YourReplicationSetName--
if you used the name rs0 from our example, then you should add to your DB connection URL query replicaSet=rs0
4. turn on mongod again
enter the command: systemctl start mongod
5. Access your replicaSet database
enter MongoDB shell with the command mongo, enter the command rs.initiate()
now you should be in your replicaSet database.
Possible solution for local development using docker
Create Dockerfile
FROM mongo:4.4.7
RUN echo "rs.initiate();" > /docker-entrypoint-initdb.d/replica-init.js
CMD [ "--replSet", "rs" ]
Build this Dockerfile
docker build ./ -t mongodb:4.7-replset
Run this created image
docker run --name mongodb-replset -p 27017:27017 -d mongodb:4.7-replset
Connect to database using this URI
mongodb://localhost:27017/myDB
For those who wants to develop against of the dockerized MongoDB instance, here is the single-file docker-compose.yaml solution based on the official MongoDB docker image:
version: '3.9'
services:
mongodb:
image: mongo:5
command: --replSet rs0
ports:
- "28017:27017"
environment:
MONGO_INITDB_DATABASE: attachment-api-local-dev
healthcheck:
test: echo 'db.runCommand("ping").ok' | mongo localhost:27017/admin --quiet
interval: 2s
timeout: 3s
retries: 5
mongo-init:
image: mongo:5
restart: "no"
depends_on:
mongodb:
condition: service_healthy
command: >
mongo --host mongodb:27017 --eval
'
rs.initiate( {
_id : "rs0",
members: [
{ _id: 0, host: "localhost:27017" }
]
})
'
A much easier solution is to just use Bitnami MongoDB image:
services:
mongodb:
image: bitnami/mongodb:5.0
ports:
- "27017:27017"
environment:
MONGODB_REPLICA_SET_MODE: primary
ALLOW_EMPTY_PASSWORD: 'yes'
I faced the same issue recently. In my case it's because I'm connecting to a remote Mongo server with a different version than my local development environment.
To quickly solve the issue, I added the following param to my connection string:
?retryWrites=false
In order to use transactions, you need a MongoDB replica set, and starting a replica set locally for development is an involved process.
You can use the run-rs npm module. Zero-config MongoDB runner. Starts a replica set with no non-Node dependencies, not even MongoDB.
Or you can simply create an account in MongoDB Atlas which gives you a limited resource MongoDB cluster and so you can run/test your application.
MongoDB Atlas
When running MongoDB on a Linux Machine, you can simply use replication by updating connection string via editing service file
/usr/lib/mongod.service or /lib/systemd/system/mongod.service
and update it with following
ExecStart=/usr/bin/mongod --config "/etc/mongod.conf" --replSet rs0
where --config "/etc/mongod.conf" is pointing to your MongoDB Configuration file and --replSet rs0 is telling it to use replication with the name of rs0
and then restart
sudo systemctl daemon-reload //<--To reload service units
sudo systemctl restart mongod //<--To Restart MongoDB Server
and then initiate replication through your mongod instance in terminal
$ mongosh
$ rs.initiate()
I've been fighting against this issue for weeks. I let you my conclusion.
In order to be able to use transactions on a sharded cluster, you need to run at least MongoDB 4.2 on your cluster. If the cluster is not sharded, from 4.0.
I was using a library that has as a sub-dependency mongodb NodeJS driver. This driver from version 3.3.x fails against the sharded MongoDB cluster with version 4.0.4.
The solution for me was to update my cluster to 4.2 version.
src: https://www.bmc.com/blogs/mongodb-transactions/
Works for mongo:5.0.5-focal image.
Dockerfile:
FROM mongo:5.0.5-focal AS rs-mongo
# Make MongoDB a replica set to support transactions. Based on https://stackoverflow.com/a/68621185/1952977
RUN apt-get update && apt-get install patch
# How to create scripts/docker-entrypoint.sh.patch
# 1. Download the original file:
# wget https://github.com/docker-library/mongo/raw/master/5.0/docker-entrypoint.sh
# ( wget https://github.com/docker-library/mongo/raw/b5c0cd58cb5626fee4d963ce05ba4d9026deb265/5.0/docker-entrypoint.sh )
# 2. Make a copy of it:
# cp docker-entrypoint.sh docker-entrypoint-patched.sh
# 3. Add required modifications to docker-entrypoint-patched.sh
# 4. Create patch:
# diff -u docker-entrypoint.sh docker-entrypoint-patched.sh > scripts/docker-entrypoint.sh.patch
# 5. Clean up:
# rm docker-entrypoint.sh docker-entrypoint-patched.sh
COPY scripts/docker-entrypoint.sh.patch .
RUN patch /usr/local/bin/docker-entrypoint.sh docker-entrypoint.sh.patch
RUN mkdir -p /etc/mongo-key && chown mongodb:mongodb /etc/mongo-key
CMD ["--replSet", "rs", "--keyFile", "/etc/mongo-key/mongodb.key"]
scripts/docker-entrypoint.sh.patch:
--- docker-entrypoint.sh 2022-01-04 15:35:19.594435819 +0300
+++ docker-entrypoint-patched.sh 2022-01-06 10:16:26.285394681 +0300
## -288,6 +288,10 ##
fi
if [ -n "$shouldPerformInitdb" ]; then
+
+ openssl rand -base64 756 > /etc/mongo-key/mongodb.key
+ chmod 400 /etc/mongo-key/mongodb.key
+
mongodHackedArgs=( "$#" )
if _parse_config "$#"; then
_mongod_hack_ensure_arg_val --config "$tempConfigFile" "${mongodHackedArgs[#]}"
## -408,7 +412,14 ##
set -- "$#" --bind_ip_all
fi
- unset "${!MONGO_INITDB_#}"
+ echo 'Initiating replica set'
+ "$#" --logpath "/proc/$$/fd/1" --fork
+ echo 'rs.initiate({"_id":"rs","members":[{"_id":0,"host":"127.0.0.1:27017"}]});' | mongosh -u "$MONGO_INITDB_ROOT_USERNAME" -p "$MONGO_INITDB_ROOT_PASSWORD"
+ "$#" --logpath "/proc/$$/fd/1" --shutdown
+ echo 'Done initiating replica set'
+
+ unset "${!MONGO_INITDB_#}"
+
fi
rm -f "$jsonConfigFile" "$tempConfigFile"
docker-compose.yml:
version: '3.9'
services:
mongo:
image: rs-mongo:current
restart: always
env_file:
- .env
ports:
- 127.0.0.1:27017:27017
volumes:
- mongo-db:/data/db
- mongo-configdb:/data/configdb
- mongo-key:/etc/mongo-key
volumes:
mongo-db:
driver: local
mongo-configdb:
driver: local
mongo-key:
driver: local
UPDATED: 6th of Jan, 2022
The error is because you are using MongoDB sessions and it is not configured on your system.
run this to install run-rs :-
npm install run-rs -g
run:-
run-rs -v 4.0.0 --shell
You should see the below output. Please be patient since MongoDB 4.0.0 is about 70MB.
$ run-rs -v 4.0.0 --shell
Downloading MongoDB 4.0.0
Copied MongoDB 4.0.0 to '/home/node/lib/node_modules/run-rs/4.0.0'
Purging database...
Running '/home/node/lib/node_modules/run-rs/4.0.0/mongod'
Starting replica set...
Started replica set on "mongodb://localhost:27017,localhost:27018,localhost:27019"
Running mongo shell: /home/node/lib/node_modules/run-rs/4.0.0/mongo
rs:PRIMARY>
You now have a replica set running MongoDB 4.0.0 locally. Run rs.status() to verify the replica set is running.
NOTE:- Your nodejs version should be $gte v3.1.0

How to run openshift MEAN project in localhost or development system Ubuntu?

I have created a MEAN stack application on https://openshift.redhat.com/ and it was successfully running on the web.
Default source code of the project synced form: https://github.com/linnovate/mean-on-openshift.git
For further development I am cloning the hosted git source using using git url mentioned in the applications page. (e.g git clone ssh://55e86e9f89f5cf1d29000001#nodejs-tapslab.rhcloud.com/~/git/nodejs.git/).
After clone the source code to local system, opening the project in sublime text editor. I can see in the config/env/development.js there are lot of configuration are used like process.env.OPENSHIFT_XXX. I was changed the some config value mentioned below and trying to start server using command : 'node server', but server was not starting throwing error.
{
db: db: 'mongodb://' + (process.env.DB_PORT_27017_TCP_ADDR || 'localhost:27017') + ':' + '/mean-dev',
hostname: process.env.OPENSHIFT_NODEJS_IP || 'http://localhost:3000'
}
Can someone help me how to run Openshift mean project in local system and what all configuration needed before running it in local system.
System Config :
Ubuntu 12.04
MongoDB v2.6.6
Nodejs v0.10.40
npm 1.4.28
grunt-cli v0.1.13
Error :
$ node server
Mean app started on port 3000 (development)
events.js:72
throw er; // Unhandled 'error' event
^
Error: getaddrinfo ENOTFOUND
at errnoException (dns.js:37:11)
at Object.onanswer [as oncomplete] (dns.js:124:16)
Git:
$ NODE_ENV=test node server

Trying to use meteor up on digital ocean

I have a digital ocean droplet that I am trying to deploy the most basic of meteor apps to, but I am getting a failing response. Any idea why this is happening?
UPDATE: added entire output
Anderss-iMac:microscope-deploy anderskitson$ mup deploy
Meteor-UP : Production Quality Meteor Deployments
--------------------------------------------------
Bundling Started: /Users/anderskitson/sites/microscope
Started TaskList: Deploying App
[bray.anderskitson.ca] uploading bundle
[bray.anderskitson.ca] uploading bundle: SUCCESS
[bray.anderskitson.ca] setting up env vars
[bray.anderskitson.ca] setting up env vars: SUCCESS
[bray.anderskitson.ca] invoking deployment process
[bray.anderskitson.ca] invoking deployment process: FAILED
-----------------------------------STDERR-----------------------------------
Warning: Permanently added 'bray.anderskitson.ca,162.243.52.235' (RSA) to the list of known hosts.
npm WARN package.json http-proxy#1.0.0 No repository field.
npm http GET https://registry.npmjs.org/fibers
npm http 304 https://registry.npmjs.org/fibers
stop: Unknown instance:
bash: line 46: wait-for-mongo: command not found
-----------------------------------STDOUT-----------------------------------
> fibers#1.0.1 install /opt/meteor/tmp/bundle/programs/server/node_modules/fibers
> node ./build.js
`linux-x64-v8-3.14` exists; testing
Binary is fine; exiting
fibers#1.0.1 node_modules/fibers
meteor start/running, process 10373
wait for mongo(5 minutes) to initiaze
----------------------------------------------------------------------------
Completed TaskList: Deploying App
I ran into same problem and I figured out that this command wasn't fired really well
sudo npm install -g forever userdown wait-for-mongo
and I manually did that so I can see wait-for-mongo a valid command,
see if that helps you too.

Categories

Resources