Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » Class loading issues with RCP app
Class loading issues with RCP app [message #109481] Tue, 13 May 2008 10:28 Go to next message
David  Pérez is currently offline David PérezFriend
Messages: 228
Registered: July 2009
Senior Member
Hi,

In my RCP app I use a JDBC driver.
I use the standard mechanism for loading the driver:

Class.forName("com.mysql.jdbc.Driver");
DriverManager.getConnection("jdbc:mysql...")

I have packaged the JDBC driver as a bundle.

-------------------Test 1

If I run the app from Eclipse, it runs ok.
But when I export it with the wizard as a RCP product, the following
happens:

In the error log I can see this error:

java.sql.SQLException: java.lang.ClassNotFoundException:

-------------------Test 2

If I change the Class.forName in this fashion:

com.mysql.jdbc.Driver.class.getName();
DriverManager.getConnection("jdbc:mysql...")

Then I receive this exception:

java.sql.SQLException: No suitable driver found for
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)

-------------------

I don't understand what happens. It must be some class loading issue.

Any help will be greatly appreciated.
Re: Class loading issues with RCP app [message #109494 is a reply to message #109481] Tue, 13 May 2008 10:40 Go to previous messageGo to next message
David  Pérez is currently offline David PérezFriend
Messages: 228
Registered: July 2009
Senior Member
I 3rd experiment:

-------------------Test 3

MyPlugin.getDefault().getBundle().loadClass("com.mysql.jdbc.Driver ");
DriverManager.getConnection("jdbc:mysql...")

When run from the IDE I get the same results that with test 2 when run
from the exported product:

java.sql.SQLException: No suitable driver found for
at java.sql.DriverManager.getConnection(Unknown Source)

I still don't understand how Equinox works, and what must I do to make it
happy.


David Perez wrote:

> Hi,

> In my RCP app I use a JDBC driver.
> I use the standard mechanism for loading the driver:

> Class.forName("com.mysql.jdbc.Driver");
> DriverManager.getConnection("jdbc:mysql...")

> I have packaged the JDBC driver as a bundle.

> -------------------Test 1

> If I run the app from Eclipse, it runs ok.
> But when I export it with the wizard as a RCP product, the following
> happens:

> In the error log I can see this error:

> java.sql.SQLException: java.lang.ClassNotFoundException:

> -------------------Test 2

> If I change the Class.forName in this fashion:

> com.mysql.jdbc.Driver.class.getName();
> DriverManager.getConnection("jdbc:mysql...")

> Then I receive this exception:

> java.sql.SQLException: No suitable driver found for
> at java.sql.DriverManager.getConnection(Unknown Source)
> at java.sql.DriverManager.getConnection(Unknown Source)
Re: Class loading issues with RCP app [message #109519 is a reply to message #109494] Tue, 13 May 2008 10:53 Go to previous messageGo to next message
David  Pérez is currently offline David PérezFriend
Messages: 228
Registered: July 2009
Senior Member
Clearly from my experiments, the IDE and an exported product exhibit
different behaviour, concerning class loading.

Does anyone know what are the differences?
How can I debug exported products specific issues?
Thanks in advance for any help.

David Perez wrote:

> I 3rd experiment:

> -------------------Test 3

> MyPlugin.getDefault().getBundle().loadClass("com.mysql.jdbc.Driver ");
> DriverManager.getConnection("jdbc:mysql...")

> When run from the IDE I get the same results that with test 2 when run
> from the exported product:

> java.sql.SQLException: No suitable driver found for
> at java.sql.DriverManager.getConnection(Unknown Source)

> I still don't understand how Equinox works, and what must I do to make it
> happy.
Re: Class loading issues with RCP app [message #109687 is a reply to message #109519] Wed, 14 May 2008 06:41 Go to previous messageGo to next message
David  Pérez is currently offline David PérezFriend
Messages: 228
Registered: July 2009
Senior Member
Am I the only one to have this kind of problems?

David Perez wrote:

> Clearly from my experiments, the IDE and an exported product exhibit
> different behaviour, concerning class loading.

> Does anyone know what are the differences?
> How can I debug exported products specific issues?
> Thanks in advance for any help.
Re: Class loading issues with RCP app [message #109991 is a reply to message #109687] Wed, 14 May 2008 07:40 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6607
Registered: July 2009
Senior Member
I always thought one has to do:

MyPlugin.getDefault().getBundle().loadClass("com.mysql.jdbc.Driver ").newInstance();


I'm doing exactly the same in my Applications (beside the fact that I my
mysql.jar is wrapped as an OSGi-Bundle). If you would provide your
modified mysql.jar and a test plugin we could maybe take a look what's
wrong because as stated I'm using fairly the same setup in my
applications and it works with different JDBC-Drivers
(mysql/postgres/derby/hsql).

Tom

David Perez schrieb:
> Am I the only one to have this kind of problems?
>
> David Perez wrote:
>
>> Clearly from my experiments, the IDE and an exported product exhibit
>> different behaviour, concerning class loading.
>
>> Does anyone know what are the differences?
>> How can I debug exported products specific issues?
>> Thanks in advance for any help.
>
>


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: Class loading issues with RCP app [message #110001 is a reply to message #109991] Wed, 14 May 2008 07:42 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6607
Registered: July 2009
Senior Member
Tom Schindl schrieb:
> I always thought one has to do:
>
> MyPlugin.getDefault().getBundle().loadClass("com.mysql.jdbc.Driver ").newInstance();
>
>
> I'm doing exactly the same in my Applications (beside the fact that I my
> mysql.jar is wrapped as an OSGi-Bundle). If you would provide your
> modified mysql.jar and a test plugin we could maybe take a look what's

Please upload them somewhere we can fetch them from and don't attach
them to the mail.

Tom

--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: Class loading issues with RCP app [message #110014 is a reply to message #109991] Wed, 14 May 2008 09:00 Go to previous messageGo to next message
David  Pérez is currently offline David PérezFriend
Messages: 228
Registered: July 2009
Senior Member
Thanks Tom for your offerement.

We have the same scenario. MySql driver is also packaged as a plugin,
referenced from where the code fails.

Test 3 is solved. The newInstance() is really necessary for avoiding "No
suitable driver found". I didn't know that helpful and valuable trick.

Now only the problem of ClassNotFoundError is left.

Tom Schindl wrote:

> I always thought one has to do:

>
MyPlugin.getDefault().getBundle().loadClass("com.mysql.jdbc.Driver ").newInstance();


> I'm doing exactly the same in my Applications (beside the fact that I my
> mysql.jar is wrapped as an OSGi-Bundle). If you would provide your
> modified mysql.jar and a test plugin we could maybe take a look what's
> wrong because as stated I'm using fairly the same setup in my
> applications and it works with different JDBC-Drivers
> (mysql/postgres/derby/hsql).

> Tom

> David Perez schrieb:
>> Am I the only one to have this kind of problems?
>>
>> David Perez wrote:
>>
>>> Clearly from my experiments, the IDE and an exported product exhibit
>>> different behaviour, concerning class loading.
>>
>>> Does anyone know what are the differences?
>>> How can I debug exported products specific issues?
>>> Thanks in advance for any help.
>>
>>
Re: Class loading issues with RCP app [message #110027 is a reply to message #109991] Wed, 14 May 2008 09:22 Go to previous messageGo to next message
David  Pérez is currently offline David PérezFriend
Messages: 228
Registered: July 2009
Senior Member
Tom,

Could you please provide the MANIFEST.MF you use.
Maybe some special magic header in the manifest control what is going on.

Here are mines:

MySQL connector plugin:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: MySql Connector
Bundle-SymbolicName: mysql.connector
Bundle-Version: 5.1.6
Bundle-ClassPath: .
Export-Package: com.mysql.jdbc

My RCP plugin:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: com.jobisjob.ui; singleton:=true
Bundle-Version: 1.0.0
Require-Bundle:
....
mysql.connector
Bundle-ClassPath: .,...
Eclipse-LazyStart: true


Tom Schindl wrote:

> I always thought one has to do:

>
MyPlugin.getDefault().getBundle().loadClass("com.mysql.jdbc.Driver ").newInstance();


> I'm doing exactly the same in my Applications (beside the fact that I my
> mysql.jar is wrapped as an OSGi-Bundle). If you would provide your
> modified mysql.jar and a test plugin we could maybe take a look what's
> wrong because as stated I'm using fairly the same setup in my
> applications and it works with different JDBC-Drivers
> (mysql/postgres/derby/hsql).

> Tom
Re: Class loading issues with RCP app [message #110039 is a reply to message #110027] Wed, 14 May 2008 09:48 Go to previous message
David  Pérez is currently offline David PérezFriend
Messages: 228
Registered: July 2009
Senior Member
This configuration works ok. :-)
Sorry for the noise.
I had cleared the config with my tests.

David Perez wrote:

> Tom,

> Could you please provide the MANIFEST.MF you use.
> Maybe some special magic header in the manifest control what is going on.

> Here are mines:

> MySQL connector plugin:

> Manifest-Version: 1.0
> Bundle-ManifestVersion: 2
> Bundle-Name: MySql Connector
> Bundle-SymbolicName: mysql.connector
> Bundle-Version: 5.1.6
> Bundle-ClassPath: .
> Export-Package: com.mysql.jdbc

> My RCP plugin:

> Manifest-Version: 1.0
> Bundle-ManifestVersion: 2
> Bundle-SymbolicName: com.jobisjob.ui; singleton:=true
> Bundle-Version: 1.0.0
> Require-Bundle:
> ....
> mysql.connector
> Bundle-ClassPath: .,...
> Eclipse-LazyStart: true


> Tom Schindl wrote:

>> I always thought one has to do:

>>
>
MyPlugin.getDefault().getBundle().loadClass("com.mysql.jdbc.Driver ").newInstance();


>> I'm doing exactly the same in my Applications (beside the fact that I my
>> mysql.jar is wrapped as an OSGi-Bundle). If you would provide your
>> modified mysql.jar and a test plugin we could maybe take a look what's
>> wrong because as stated I'm using fairly the same setup in my
>> applications and it works with different JDBC-Drivers
>> (mysql/postgres/derby/hsql).

>> Tom
Previous Topic:Replacing a bundle from an installed feature
Next Topic:Troubleshooting OSGi jar wrapping
Goto Forum:
  


Current Time: Thu Oct 28 02:10:09 GMT 2021

Powered by FUDForum. Page generated in 0.02471 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top