Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » eclipse plugin classpath and JDBC access
eclipse plugin classpath and JDBC access [message #464897] Mon, 19 March 2007 14:00 Go to next message
Eclipse UserFriend
Originally posted by: stefandeboey.gmail.com

Hello,

i have a question regarding JDBC and plugin classloaders.

For my RCP application I have 3 plugins:
- 'sqlutil' plugin: contains utility and wrapper classes that make it
easier to use the jdbc API
- 'disccat' plugin: contains the rcp application itself
- org.hsqldb plugin: contains the hsqldb jar

The 'disccat' plugin has 2 dependencies:
- a dependency on the 'sqlutil' plugin because it uses the classes in
that plugin to acces the database
- a dependency on the 'org.hsqldb' plugin, this one is needed because i
also need database access from classes in the 'disccat' plugin

The problem is that the 'sqlutil' has no dependency on the 'org.hsqldb'
plugin because this plugin has generic functionality. I just don't want a
dependeny on the 'org.hsqldb' for this plugin.

So if i do
Platform.getBundle("sqlutil").loadClass("org.hsqldb.jdbcDriver ") from my
'disccat' plugin to load the HSQLDB JDBC driver, off cource i get class
not found because the 'sqlutil' plugin does not know the hsqldb jar.

The question is: how can i solve this problem? How can i add the
hsqldb.jar from the 'org.hsqldb' plugin to the classpath of the 'sqlutil'
plugin at runtime, so without adding it to the dependencies list of the
plugin?

Thanks
Re: eclipse plugin classpath and JDBC access [message #464898 is a reply to message #464897] Mon, 19 March 2007 14:32 Go to previous messageGo to next message
Charlie Kelly is currently offline Charlie KellyFriend
Messages: 276
Registered: July 2009
Senior Member
Hi Stefan,

Your problem is common; it is discussed in "Eclipse Rich Client
Platform" by McAffer and Lemieux (chapter 20).

Their solution makes an analogy between database systems and log4j.
The database (or log4j) needs to be aware of classes that were not
available when the dbms was developed.

1) Create a new plugin using the Wizard to "create a plugin from an
existing jar" and include the jar for hsqldb.

Within the manifest for that plugin, include the following statement:
Eclipse-BuddyPolicy: registered

Within the manifest for the plugin that contains disccat, include the
following statement:
Eclipse-RegisterBuddy: com.charleskelly.support
and replace "com.charleskelly.support" with the name of your plugin

If you have problems, you may have to adjust the classloader within your
disccat plugin, Either see the McAffer book, or write to this list, and
I'll send a code sample.

Charlie




Stefan De Boey wrote:
> Hello,
>
> i have a question regarding JDBC and plugin classloaders.
>
> For my RCP application I have 3 plugins:
> - 'sqlutil' plugin: contains utility and wrapper classes that
> make it easier to use the jdbc API
> - 'disccat' plugin: contains the rcp application itself
> - org.hsqldb plugin: contains the hsqldb jar
>
> The 'disccat' plugin has 2 dependencies:
> - a dependency on the 'sqlutil' plugin because it uses the classes
> in that plugin to acces the database
> - a dependency on the 'org.hsqldb' plugin, this one is needed
> because i also need database access from classes in the 'disccat' plugin
>
> The problem is that the 'sqlutil' has no dependency on the 'org.hsqldb'
> plugin because this plugin has generic functionality. I just don't want
> a dependeny on the 'org.hsqldb' for this plugin.
>
> So if i do
> Platform.getBundle("sqlutil").loadClass("org.hsqldb.jdbcDriver ") from my
> 'disccat' plugin to load the HSQLDB JDBC driver, off cource i get class
> not found because the 'sqlutil' plugin does not know the hsqldb jar.
>
> The question is: how can i solve this problem? How can i add the
> hsqldb.jar from the 'org.hsqldb' plugin to the classpath of the
> 'sqlutil' plugin at runtime, so without adding it to the dependencies
> list of the plugin?
>
> Thanks
>
>
Re: eclipse plugin classpath and JDBC access [message #464934 is a reply to message #464897] Tue, 20 March 2007 20:42 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: lamont_gilbert.rigidsoftware.com

On Mon, 19 Mar 2007 14:00:43 +0000, Stefan De Boey wrote:

> Hello,
>
> i have a question regarding JDBC and plugin classloaders.
>
> For my RCP application I have 3 plugins:
> - 'sqlutil' plugin: contains utility and wrapper classes that make it
> easier to use the jdbc API
> - 'disccat' plugin: contains the rcp application itself
> - org.hsqldb plugin: contains the hsqldb jar
>
> The 'disccat' plugin has 2 dependencies:
> - a dependency on the 'sqlutil' plugin because it uses the classes in
> that plugin to acces the database
> - a dependency on the 'org.hsqldb' plugin, this one is needed because i
> also need database access from classes in the 'disccat' plugin
>
> The problem is that the 'sqlutil' has no dependency on the 'org.hsqldb'
> plugin because this plugin has generic functionality. I just don't want a
> dependeny on the 'org.hsqldb' for this plugin.
>
> So if i do
> Platform.getBundle("sqlutil").loadClass("org.hsqldb.jdbcDriver ") from my
> 'disccat' plugin to load the HSQLDB JDBC driver, off cource i get class
> not found because the 'sqlutil' plugin does not know the hsqldb jar.
>
> The question is: how can i solve this problem? How can i add the
> hsqldb.jar from the 'org.hsqldb' plugin to the classpath of the 'sqlutil'
> plugin at runtime, so without adding it to the dependencies list of the
> plugin?
>
> Thanks

How did Spock say it? "What you want is irrelevant, what you have chosen
is at hand." You need to have ONE plugin that provides the driver, and
everyone that needs it should import that plugin. No way around it.
Re: eclipse plugin classpath and JDBC access [message #464939 is a reply to message #464934] Tue, 20 March 2007 20:57 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: stefandeboey.gmail.com

Gilbert,

i do not completely agree with your statement.

Suppose the 'sqlutil' plugin is a third-party plugin, which i don't want
to alter. Then i can't add a dependency on the 'hsqldb' plugin to that
third-party plugin.

In fact, i found another, smoother solution:
i just created a fragment plugin project with as host-plugin the sqlutil
plugin and then i added the dependency on the hsqldb plugin to that
fragment plugin. And the problem is solved. This way the sqlutil plugin
does not have any dependencies to whatever jdbc driver i want to use.

Regards,
Stefan
Re: eclipse plugin classpath and JDBC access [message #464975 is a reply to message #464939] Wed, 21 March 2007 11:43 Go to previous message
Eclipse UserFriend
Originally posted by: lamont_gilbert.rigidsoftware.com

On Tue, 20 Mar 2007 20:57:19 +0000, Stefan De Boey wrote:

> Gilbert,
>
> i do not completely agree with your statement.

In time you will see the light my child.

>
> Suppose the 'sqlutil' plugin is a third-party plugin, which i don't want
> to alter. Then i can't add a dependency on the 'hsqldb' plugin to that
> third-party plugin.

Are you suggesting the sqlutil plugin has in it the db driver? Well then
that is OK. that is a totally seperate product with its own testing and
compatability. So I am sure it is happy with the driver it uses. The
rest of your program should use a different driver.

>
> In fact, i found another, smoother solution:
> i just created a fragment plugin project with as host-plugin the sqlutil
> plugin and then i added the dependency on the hsqldb plugin to that
> fragment plugin. And the problem is solved. This way the sqlutil plugin
> does not have any dependencies to whatever jdbc driver i want to use.
>

So you add the dbdriver to the fragment, and that adds the dbdriver to the
host-plugins classpath automatically. Yup, I have been there.

The sqlutil plugin certainly has a dependency to the dbdriver. YOu have
just hidden it. But dont think it does not exist. Your setup will all
work fine until you start releasing new versions of your plugins and
trying to ensure that all your plugins are using the same versions of each
other. Make sure your dependencies are linear, and are not branching.
Otherwise its gonna be a pain.


i could comment better if I fully understood your dependency architecture
and what needs classes from what.


> Regards,
> Stefan
Previous Topic:Issue with apostrophes and NLS
Next Topic:How the eclipse error messages are internationalized
Goto Forum:
  


Current Time: Sat Sep 14 12:08:17 GMT 2024

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

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

Back to the top