Appsmith server is not starting because of MongoDB exception - mongodb

My Appsmith instance just upgraded to v1.6.4 and it's not booting up anymore. In the logs, I can see the exception below:
Caused by: com.mongodb.MongoCommandException: Command failed with error 17 (ProtocolError): 'Attempt to switch database target during SASL authentication.' on server mongo:27017. The full response is {"ok": 0.0, "errmsg": "Attempt to switch database target during SASL authentication.", "code": 17, "codeName": "ProtocolError"}
Is there anything I can do to bring up my Appsmith instance?

This is a breaking change that was introduced in v1.6.4 of Appsmith because of Spring library upgrades. A complete fix is described at: https://docs.appsmith.com/troubleshooting-guide/deployment-errors#server-not-booting-because-of-mongocommandexception
Step 1: Edit MongoDB URI
Adding &authSource=admin to the end of your APPSMITH_MONGODB_URI variable’s value in your docker.env file. For example, in your docker.env file, if you have the following line:
# Old config
APPSMITH_MONGODB_URI=mongodb://<your_username>:<your_password>#mongo/appsmith?retryWrites=true
Change it to the following (notice the only change is &authSource=admin. Do NOT copy-paste this whole line. Only add the &authSource=admin part to your existing value.
# New config
APPSMITH_MONGODB_URI=mongodb://<your_username>:<your_password>#mongo/appsmith?retryWrites=true&authSource=admin
Save the file.
Step 2: Restart server
Now restart your container with the following command:
sudo docker-compose up -d --force-recreate appsmith-internal-server
In a minute or two, the server should now come up and be ready.

Related

Hyperledger iroha - schema error while connecting to postgres database

I am trying to deploy Hyperledger Iroha on MacOS (BigSUr) locally, and while running the following command
./build/bin/irohad --config example/config.postgres.sample --genesis_block example/genesis.block --keypair_name example/node0
I get the error
Storage initialization failed: Cannot execute query. Fatal error. ERROR: relation "schema_version" does not exist LINE 1: ... test, iroha_major, iroha_minor, iroha_patch from schema_ver... ^ while executing "select 1 test, iroha_major, iroha_minor, iroha_patch from schema_version;".
I have installed Postgresql DB locally and created the iroha_data database.
Is there a schema that i must load additionally or does it get auto created ?
I was able to overcome this issue by adding -drop_state while starting iroha daemon.

Mongeez with spring boot

I have some set of MongoDB insert commands to be executed during the application startup. refered https://github.com/hzpz/mongeez-spring-boot-starter for my requirement
Followed the below steps
1) Added the dependency in pom
2) Created js and mongeez.xml in an external folder
3) Referred the location in mongeez.location={myDir}/db
I am getting below exception while starting the application
Caused by: com.mongodb.MongoCommandException: Command failed with error 59 (CommandNotFound): 'no such command:
'$eval'' on server localhost:27017. The full response is {"ok": 0.0, "errmsg": "no such command:
'$eval'", "code": 59, "codeName": "CommandNotFound"}
The contents of the js file is
db.organization.save({"Name" : "10Gen", "Location" : "NYC"});
the contents of mongeez.xml is
<changeFiles> <file path="config.js"/> </changeFiles>
Spring Boot Version : 2.2.1.RELEASE
Mongeez Version : 2.0.1
The db.eval() command is not supported after mongo:4.2 verison.
check this link 'no such command: '$eval'' on server localhost:27017
Let me know, if you found something, in the mean time we can only go back to mongo:4.0 or start using mongobee https://github.com/mongobee/mongobee

MongoDB - configure encryption in cfg file

MongoDB v4 Ent, Windows Server 2016 Std
Starting mongodb from command line works fine:
mongod --enableEncryption --encryptionKeyFile c:\key\mongodb-keyfile
Now I need to change mongod.cfg so windows service starts with encryption enabled. After adding following parameters to file
security:
enableEncryption: true
encryptionKeyFile: c:\key\mongodb-keyfile
service throw error while starting
error 1067: the process terminated unexpectedly
Any ideas?

Cannot deploy war to GlassFish 4.1.2 server because database can't be found

I'm working through a book on GlassFish4 application server and have trouble deploying a sample war to the server. The server says:
"Error occurred during deployment: Exception while deploying the app [jpaintro-1.0] : Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.6.1.v20150605-31e8258): org.eclipse.persistence.exceptions.DatabaseException Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: The connection was refused because the database customerdb was not found. Error Code: 0. Please see server.log for more details."
The database server is Derby that comes with GlassFish. The database was created with this from the ./ij prompt:
connect 'jdbc:derby://localhost:1527/customerdb;create=true';
Next I could logon:
connect 'jdbc:derby://localhost:1527/customerdb;user=dev;password=dev';
and successfully enter table creation data and insert table data. Next I could retrieve this data with SQL. All fine, so the database exists.
Physical location database:
/home/fedora/GlassFish/glassfish4/glassfish/databases/1527/customerdb
The DERBY_HOME environment value was set.
I had to set up the following resources from the command line prompt:
./asadmin create-jdbc-connection-pool --datasourceclassname org.apache.derby.jdbc.ClientDataSource --restype javax.sql.DataSource --property DatabaseName=customerdb:User=dev:password=dev CustomerDBPool
./asadmin create-jdbc-resource --connectionpoolid CustomerDBPool jdbc/__CustomerDBPool
And I could verify in the GlassFish console that they were created successfully. The JDBC connection pool does indeed have an entry CustomerDBPool with an "additional property" name=DatabaseName, value=customerdb as well as user/password dev/dev. Also in the console is a JDBC resource with JNDI name jdbc/__CustomerDBPool and pool name CustomerDBPool
The war-file that I can't deploy contains a JPA-entity Customer and CDI named bean JpaDemoBean. The latter constructs a few Customer object and persists them to the database.
In the persistence.xml there is merely a jta-data-source element with value jdbc/__CustomerDBPool
I am all following literally "from the book".
Now why can't I deploy the war?
And all of a sudden I can't connect to the database via command line tool ij either:
ERROR 08004: The connection was refused because the database customerdb was not found.
I can stop and start the database server from the command line, but during startup I get the message:
"Invalid database home directory: /home/fedora/GlassFish/glassfish4/glassfish/databases"
Nevertheless the startup process continues and says it started the database successfully.
Thanks in advance!

Can't Connect to MongoDB from play app with salat: command failed [listDatabases]

I am trying to get started with the salat plugin in playframework. I have configured the database in application.conf and added all the dependencies to Build.scala and added salat to the play.plugins file. I haven't actually added any code to the project yet, I just followed the instructions on the github page, and then tried to run the project. I am getting the following error message
(Server started, use Ctrl+D to stop and go back to the console...)
[info] play - mongodb [default] connected at heroku_app4620908#ds031907.mongolab.com:31907/heroku_app4620908
[error] application -
! #6bchnaacn - Internal server error, for request [GET /] ->
play.api.Configuration$$anon$1: Configuration error [couldn't connect to [ds031907.mongolab.com/107.21.153.211:31907]]
at play.api.Configuration$.play$api$Configuration$$configError(Configuration.scala:71) ~[play_2.9.1-2.0.3.jar:2.0.3]
at play.api.Configuration.reportError(Configuration.scala:258) ~[play_2.9.1-2.0.3.jar:2.0.3]
at se.radley.plugin.salat.SalatPlugin$$anonfun$onStart$1.apply(SalatPlugin.scala:105) ~[play-plugins-salat_2.9.1-1.0.8.jar:1.0.8]
at se.radley.plugin.salat.SalatPlugin$$anonfun$onStart$1.apply(SalatPlugin.scala:98) ~[play-plugins-salat_2.9.1-1.0.8.jar:1.0.8]
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:194) ~[scala-library.jar:0.11.3]
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:194) ~[scala-library.jar:0.11.3]
Caused by: com.mongodb.CommandResult$CommandFailure: command failed [listDatabases]: { "serverUsed" : "db-uri" , "errmsg" : "need to login" , "ok" : 0.0}
at com.mongodb.CommandResult.getException(CommandResult.java:88) ~[mongo-java-driver-2.8.0.jar:na
at com.mongodb.CommandResult.throwOnError(CommandResult.java:134) ~[mongo-java-driver-2.8.0.jar:na]
at com.mongodb.Mongo.getDatabaseNames(Mongo.java:356) ~[mongo-java-driver-2.8.0.jar:na]
at com.mongodb.casbah.MongoConnection.getDatabaseNames(MongoConnection.scala:190) ~[casbah-core_2.9.1-2.4.1.jar:2.4.1]
at se.radley.plugin.salat.SalatPlugin$$anonfun$onStart$1.apply(SalatPlugin.scala:103) ~[play-plugins-salat_2.9.1-1.0.8.jar:1.0.8]
at se.radley.plugin.salat.SalatPlugin$$anonfun$onStart$1.apply(SalatPlugin.scala:98) ~[play-plugins-salat_2.9.1-1.0.8.jar:1.0.8]
I am stumped because I added my password and everything to the conf file. From the log it looks as though whatever is trying to connect to the database for me, is not logging in first, using the info I provided.
As you say, it looks like the root issue is that MongoDB is rejecting the command "listDatabases". This command requires administrator access to the MongoDB process since it reveals information about the other databases hosted there.
Unfortunately, the message it returns, "need to login", is a little misleading. You have logged in! You just don't have permission to list the databases.
Here's a simple experiment you can try yourself with the MongoDB shell. See that "show dbs" fails with the same error message you got in your app, but "show collections", which doesn't require access to any other databases outside your own, succeeds?
% mongo ds031907.mongolab.com:31907/heroku_app4620908 -u heroku_app4620908 -p your_password
MongoDB shell version: 2.0.7
connecting to: ds031907.mongolab.com:31907/heroku_app4620908
> show dbs
Fri Aug 17 13:12:10 uncaught exception: listDatabases failed:{ "errmsg" : "need to login", "ok" : 0 }
> show collections
system.indexes
system.users
(Note: I did this with my own MongoLab account and modified the text when copying and pasting here so you could just copy it into your terminal.)
Is there a way to avoid making the listDatabases call? I'm not familiar with the framework you're using.
I've the problem as well...
it should come with the SalatPlugin's onStart method that is requesting all database names: source._2.connection.getDatabaseNames().
This code is just testing the aliveness of the server...
I'm gonna check with leon how we could this differently! Sadly, you won't be able to connect until this will be fixed!
Stay tuned on this issue https://github.com/leon/play-salat/issues/23
This is fixed in the latest version of play-salat, it now uses getCollectionNames instead
use admin
db.addUser('userName', 'userPassword')
db.auth('userName', 'userPassword')
show dbs
java:
DB db = mongo.getDB("YouDBName") ;
db.authenticate("userName", "userPassword".toCharArray()) ;
System.out.println(mongo.getDatabaseNames()) ;