Skip to content

jdk11 / guice 4.2.2 #1256

@prasanthgithub

Description

@prasanthgithub

Hi,
As part of migration to jdk11 we are asked to upgrade guice version which supports jdk11.

So in pom.xml I tried to upgrade guice version from 4.0 => 4.2.2 and left other dependency versions as it is but when i started our REST application its unable to get a successful C3p0 connection. However if i revert back to 4.0 version it works fine.

<dependency>
	<groupId>com.google.inject</groupId>
	<artifactId>guice</artifactId>
	**<version>4.2.2</version>**
</dependency>
<dependency>
	<groupId>com.google.inject.extensions</groupId>
	<artifactId>guice-jndi</artifactId>
	<version>4.0</version>
</dependency>
<dependency>
	<groupId>com.google.inject.extensions</groupId>
	<artifactId>guice-servlet</artifactId>
	<version>4.0</version>
</dependency>
<dependency>
	<groupId>com.mchange</groupId>
	<artifactId>c3p0</artifactId>
	<version>0.9.5.2</version>
</dependency>
<!-- END: C3P0 database connection and google guice for inject -->

Java Code:

import javax.sql.DataSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.inject.AbstractModule;
import com.google.inject.Provider;
import com.google.inject.jndi.JndiIntegration;

public class DemoDataSource extends AbstractModule {
private static final String JNDI_ENV = "java:comp/env/jdbc/c3p0DataSource";

@Override
protected void configure() {

bind(javax.naming.Context.class).to(javax.naming.InitialContext.class).asEagerSingleton();
Provider dataSourceProvider = JndiIntegration.fromJndi(DataSource.class, JNDI_ENV);
bind(DataSource.class).toProvider(dataSourceProvider).asEagerSingleton();
bind(DBConnectionPool.class).to(C3P0ConnectionProvider.class).asEagerSingleton();
}
}
}

Any help is much appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions