Coder Social home page Coder Social logo

Comments (5)

osantana85 avatar osantana85 commented on June 11, 2024

Hello @francocca , we'll take a look and let you know. A few questions:

Can you provide the code that is using the method configMongockApplicationRunner ?

Are you using @EnableMongock annotation? It seems that Mongock is trying to instanciate a driver bean (autoconfiguration), which is incompatible with builder approach.

Here you have links to Mongock sample projects with different approachs:

  1. Springboot - mongodb with builder

  2. Springboot - mongodb with auto-configuration

from mongock.

francocca avatar francocca commented on June 11, 2024

Hi @osantana85 the code for configMongockApplicationRunner is this:

`private MongockApplicationRunner configMongockApplicationRunner(MongoTemplate mongoTemplate, ConfigurableApplicationContext applicationContext) {

	SpringDataMongoV3Driver driver = SpringDataMongoV3Driver.withDefaultLock(mongoTemplate);
	return MongockSpringboot.builder()
			.setDriver(driver)
			.addMigrationScanPackage("com.app.aut.dashboardmigrations")
			.setSpringContext(applicationContext)
			.buildApplicationRunner();
}`

As you said before, I actually had the @EnableMongock annotation in my application. I already deleted it but now I have another error when the changeUnit is being executed

my change unit class is this:

`@ChangeUnit(id = "results_refactor", order = "1", author = "Magnifai")
public class Version01 {

@Execution
public void changeSet(ResultRepoOld resultRepoOld, ResultRepo resultRepo) {
	int page = 0;
	/*code with both respos......*/
	}
}
@RollbackExecution
public void rollback() {
}`

My main class is this:

`@SpringBootApplication
@EnableMongoRepositories(basePackageClasses = { ResultRepoOld.class, ResultRepo.class })
public class DashboardMigrationApplication {

public static void main(String[] args) {
	SpringApplication application = new SpringApplication(DashboardMigrationApplication.class);
	application.run(args);
}

}`

this is the error that i have in mongockChangeLog:

{"execution-error":"java.lang.reflect.InvocationTargetException: null\njava.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\njava.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\njava.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\njava.base/java.lang.reflect.Method.invoke(Method.java:566)\nio.mongock.runner.core.executor.ChangeLogRuntimeImpl.runChangeSet(ChangeLogRuntimeImpl.java:82)\nio.mongock.runner.core.executor.ChangeExecutorBase.executeChangeSetMethod(ChangeExecutorBase.java:397)\nio.mongock.runner.core.executor.ChangeExecutorBase.executeAndLogChangeSet(ChangeExecutorBase.java:236)\nio.mongock.runner.core.executor.ChangeExecutorBase.processSingleChangeSet(ChangeExecutorBase.java:190)\nio.mongock.runner.core.executor.ChangeExecutorBase.loopRawChangeSets(ChangeExecutorBase.java:157)\nio.mongock.runner.core.executor.ChangeExecutorBase.lambda$processChangeLogInTransactionIfApplies$3(ChangeExecutorBase.java:147)\nio.mongock.runner.core.executor.NonTransactioner.executeInTransaction(NonTransactioner.java:17)\nio.mongock.runner.core.executor.ChangeExecutorBase.processChangeLogInTransactionIfApplies(ChangeExecutorBase.java:147)\nio.mongock.runner.core.executor.ChangeExecutorBase.processSingleChangeLog(ChangeExecutorBase.java:119)\nio.mongock.runner.core.executor.ChangeExecutorBase.processChangeLogs(ChangeExecutorBase.java:107)\nio.mongock.runner.core.executor.ChangeExecutorBase.lambda$processMigration$1(ChangeExecutorBase.java:101)\nio.mongock.runner.core.executor.NonTransactioner.executeInTransaction(NonTransactioner.java:17)\nio.mongock.runner.core.executor.ChangeExecutorBase.processMigration(ChangeExecutorBase.java:101)\nio.mongock.runner.core.executor.operation.migrate.MigrateExecutorBase.executeMigration(MigrateExecutorBase.java:66)\nio.mongock.runner.core.executor.operation.migrate.MigrateExecutorBase.executeMigration(MigrateExecutorBase.java:18)\nio.mongock.runner.core.executor.MongockRunnerImpl.execute(MongockRunnerImpl.java:57)\nio.mongock.runner.springboot.base.MongockApplicationRunner.run(MongockApplicationRunner.java:18)\norg.springframework.boot.SpringApplication.callRunner(SpringApplication.java:759)\norg.springframework.boot.SpringApplication.callRunners(SpringApplication.java:749)\norg.springframework.boot.SpringApplication.run(SpringApplication.java:314)\ncom.globant.aut.dashboardmigrations.DashboardMigrationApplication.main(DashboardMigrationApplication.java:18)\njava.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\njava.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\njava.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\njava.base/java.lang.reflect.Method.invoke(Method.java:566)\norg.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)\norg.springframework.boot.loader.Launcher.launch(Launcher.java:108)\norg.springframework.boot.loader.Launcher.launch(Launcher.java:58)\norg.springframework.boot.loader.JarLauncher.main(JarLauncher.java:65)\n"}

and this is the error in the console:

aut-database-migrations | 2024-02-06 14:45:51.700 INFO 35 --- [ main] i.m.driver.core.lock.LockManagerDefault : Mongock waiting to release the lock aut-database-migrations | 2024-02-06 14:45:51.700 INFO 35 --- [ main] i.m.driver.core.lock.LockManagerDefault : Mongock releasing the lock aut-database-migrations | 2024-02-06 14:45:51.707 INFO 35 --- [ main] i.m.driver.core.lock.LockManagerDefault : Mongock released the lock aut-database-migrations | 2024-02-06 14:45:51.707 INFO 35 --- [ main] i.m.r.c.e.system.SystemUpdateExecutor : Mongock has finished the system update execution aut-database-migrations | 2024-02-06 14:45:51.749 INFO 35 --- [ main] org.reflections.Reflections : Reflections took 40 ms to scan 1 urls, producing 12 keys and 46 values aut-database-migrations | 2024-02-06 14:45:51.781 INFO 35 --- [ main] org.reflections.Reflections : Reflections took 18 ms to scan 1 urls, producing 12 keys and 46 values aut-database-migrations | 2024-02-06 14:45:51.790 INFO 35 --- [ main] i.m.driver.core.lock.LockManagerDefault : Mongock trying to acquire the lock aut-database-migrations | 2024-02-06 14:45:51.796 INFO 35 --- [ main] i.m.driver.core.lock.LockManagerDefault : Mongock acquired the lock until: Tue Feb 06 14:46:51 GMT 2024 aut-database-migrations | 2024-02-06 14:45:51.798 INFO 35 --- [ Thread-2] i.m.driver.core.lock.LockManagerDefault : Starting mongock lock daemon... aut-database-migrations | 2024-02-06 14:45:51.801 INFO 35 --- [ main] i.m.r.c.e.o.migrate.MigrateExecutorBase : Mongock starting the data migration sequence id[2024-02-06T14:45:48.958145-282]... aut-database-migrations | 2024-02-06 14:45:51.803 INFO 35 --- [ main] i.m.r.c.executor.ChangeLogRuntimeImpl : method[com.globant.aut.dashboardmigrations.v01.Version01] with arguments: [] aut-database-migrations | 2024-02-06 14:45:51.812 INFO 35 --- [ main] i.m.r.c.executor.ChangeLogRuntimeImpl : method[changeSet] with arguments: [com.sun.proxy.$Proxy59, com.sun.proxy.$Proxy58] aut-database-migrations | 2024-02-06 14:45:51.829 INFO 35 --- [ main] org.mongodb.driver.cluster : Cluster aut-database-migrations | Caused by: io.mongock.api.exception.MongockException: Error in method[Version01.changeSet] : Timed out after 30000 ms while waiting to connect. Client view of cluster state is {type=UNKNOWN, servers=[{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused (Connection refused)}}]; nested exception is com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting to connect. Client view of cluster state is {type=UNKNOWN, servers=[{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused (Connection refused)}}]

from mongock.

osantana85 avatar osantana85 commented on June 11, 2024

Hello @francocca .

The output log indicates that Mongock's execution fails trying to connect to mongodb localhost:27017.

Your Springboot application is creating a default MongoTemplate to work with your custom repositories. This MongoTemplate by default is configured to connect to a mongodb server located in localhost:27017. You can change this config in your Springboot properties file to connect to another server, this way (yaml file):

spring:
  data:
    mongodb:
      database: YOUR_DB_NAME
      host: YOUR_DB_SERVER_HOST
      port: YOUR_DB_SERVER_PORT

Note that this configuration is not related to Mongock but to Springboot/Springdata.

Now the question is, are you using a different DB for your application and Mongock on purpose?

  • If not, you can fix it that way.
  • If yes, you cannot use custom repositories and you need a different approach to define your ChangeUnits.

If you go for the first option, you can configure Mongock with auto-configuration approach (instead of builder). Please take a look to Springboot - mongodb with auto-configuration sample project.

Hope it helps you.

from mongock.

francocca avatar francocca commented on June 11, 2024

thank you @osantana85 I applied the way you suggested and it worked. my last two questions:

  1. We want to test Multitenant feature I understand that we need to request a license key but we get a message "this page could not be found" in the link provided on the page https://docs.mongock.io/v5/professional/setup.html, is there another way to obtain that license?

  2. In the mongockChangeLog always is appearing the logs for two default changeUnit migration called system-change-00001_before and system-change-00001. is possible to disable this default changeUnit in order to not appear in my mongockChangeLog:

from mongock.

osantana85 avatar osantana85 commented on June 11, 2024

Hello @francocca , about your questions:

  1. To get support and additional details of Mongock professional licenses please use the contact form in the following link.
  2. Currently there is no way to disable system ChangeUnits logs. We'll take it into account for future releases.

If your problem was solved, could you please close the issue?

Thanks

from mongock.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.