dropwizard Cannot create new registration for component type class

1,271 views
Skip to first unread message

Jason Novotny

unread,
Jan 21, 2016, 2:45:33 PM1/21/16
to dropwizard-user
Hi,

I'm new to dropwizard and I'm using the mybatis-dropwizard https://github.com/login-box/dropwizard-mybatis integrtaion which I've modified a bit since I need to access two databases.

My code has the following:

@Override
public void run(T configuration, io.dropwizard.setup.Environment environment) throws Exception {
ManagedDataSource fooDataSource = buildFooDataSource(configuration, environment);
ManagedDataSource barDataSource = buildBarDataSource(configuration, environment);

environment.lifecycle().manage(fooDataSource);
environment.lifecycle().manage(barDataSource);

fooSqlSessionFactory = createSqlSessionFactory(fooDataSource);
barSqlSessionFactory = createSqlSessionFactory(barDataSource);

environment.healthChecks().register("foo", new SqlSessionFactoryHealthCheck(fooSqlSessionFactory));
environment.jersey().register(SqlSessionProvider.binder(fooSqlSessionFactory));

environment.healthChecks().register("bar", new SqlSessionFactoryHealthCheck(barSqlSessionFactory));
environment.jersey().register(SqlSessionProvider.binder(barSqlSessionFactory));
}

Basically I had just copied lines I found for one DB/SqlSessionfactory for the other.

Now I get an error/warning after the 2nd environment.jersey().register is executed:

WARN [2016-01-21 19:37:55,529] org.glassfish.jersey.internal.Errors: The following warnings have been detected: WARNING: Cannot create new registration for component type class com.loginbox.dropwizard.mybatis.providers.SqlSessionProvider$Binder: Existing previous registration found for the type.

I'm pretty clueless here, what do I need to register and how?

Thanks, Jason




Carol Schäfer

unread,
Dec 20, 2016, 7:11:59 AM12/20/16
to dropwizard-user
Hi Jason,

did you solve the problem back then? I get exactly the same message. Pretty annoying, don't know what to do about this.

Thanks in advance!

Jason Novotny

unread,
Dec 20, 2016, 1:27:43 PM12/20/16
to dropwiz...@googlegroups.com

Hmm,

That was a while back, I don't recall what the solution was. However, I was able to create two database connections with mybatis in the end.

Jason

-- You received this message because you are subscribed to a topic in the Google Groups "dropwizard-user" group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/dropwizard-user/tQzwQUfcNTE/unsubscribe. To unsubscribe from this group and all its topics, send an email to dropwizard-us...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages