[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[eclipselink-users] java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost/the_db
|
Hi!
I'm currently facing the following issue, and I don't know where to
look anymore.
I have an OSGI application, which uses EclipseLink.
The structure looks like this:
a bundle MODEL with all entity classes,
a bundle CLIENT with persistense.xml and code that initalizes the
EntityManagerFactory and uses entity managers.
Upon initializing EntityManagerFactory I set an additional class-loader propery:
Map<String, Object> properties = new HashMap<String, Object>();
classLoader = this.getClass().getClassLoader());
properties.put(PersistenceUnitProperties.CLASSLOADER, classLoader);
factory = Persistence.createEntityManagerFactory(unitName, properties);
Here "this" - is a DS component initialized by equinox.ds service.
And this kind of setup works fine on one of my computers, but just
wont work on another.
The target platform is the same (file-to-file - I just "copied" it via
svn), the OS is the same (ArchLinux), as well as the java environment
and mysql database (version, etc).
When I run the application on the second machine I get the subject
error message:
[EL Finer]: java.sql.SQLException: No suitable driver found for
jdbc:mysql://localhost/the_db
at java.sql.DriverManager.getConnection(DriverManager.java:602)
at java.sql.DriverManager.getConnection(DriverManager.java:154)
at org.eclipse.persistence.sessions.DefaultConnector.connect(DefaultConnector.java:97)
at org.eclipse.persistence.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:162)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:583)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:227)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:255)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:111)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:163)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:150)
... skip ...
I tried to trace it - it runs exactly the same on both machines, and
the parameters that DriverManager.getConnection(...) receives are the
same, too: the driver class name and the class loader.
I tried to play with start levels - making mysql bundle load first -
it didn't help.
And just before calling createEntityManager() I check whether the
driver class is available:
try {
Class.forName("com.mysql.jdbc.Driver");
logger.info("class found");
} catch (ClassNotFoundException e) {
logger.info("class not found: {}", e.getMessage());
}
EntityManager em = Services.getEntityManagerFactory()
.createEntityManager();
It shows, that it is available ("class found").
Maybe I missed something important? But I did everything the same way
on both machines - checked out from repository the bundles, the target
platform, created the launch configuration with default settings.