Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » rcp and external jars
rcp and external jars [message #394704] Sat, 20 November 2004 15:03 Go to next message
Eclipse UserFriend
Originally posted by: k.oriordan.oceanfree.net

My program needs extra JARs in its classpath (I'm using XML Stax
parser). Tester methods run fine, I have the jar files in my project
build path. However even when I add the jars to the runtime dependancies
section of my plugin.xml, running my program as an RCP application still
complains of (provider com.bea.xml.stream.MXParserFactory not found)
even though it's in one of the JARs I provided as a dependancy?

Anyone got any ideas?

Kevin.
Re: rcp and external jars [message #394707 is a reply to message #394704] Sun, 21 November 2004 00:43 Go to previous messageGo to next message
Eclipse UserFriend
You select the jar files in the build tab of the plugin.xml?

Regards,

Alejandro

Kevin O'Riordan wrote:

> My program needs extra JARs in its classpath (I'm using XML Stax
> parser). Tester methods run fine, I have the jar files in my project
> build path. However even when I add the jars to the runtime dependancies
> section of my plugin.xml, running my program as an RCP application still
> complains of (provider com.bea.xml.stream.MXParserFactory not found)
> even though it's in one of the JARs I provided as a dependancy?

> Anyone got any ideas?

> Kevin.
Re: rcp and external jars [message #394709 is a reply to message #394707] Sun, 21 November 2004 10:39 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: k.oriordan.oceanfree.net

That didn't work unfortunately. The files are only needed at runtime
anyway (they get picked up by a Factory class).

Kevin.

Alejandro Narancio wrote:
> You select the jar files in the build tab of the plugin.xml?
>
> Regards,
>
> Alejandro
>
> Kevin O'Riordan wrote:
>
>> My program needs extra JARs in its classpath (I'm using XML Stax
>> parser). Tester methods run fine, I have the jar files in my project
>> build path. However even when I add the jars to the runtime
>> dependancies section of my plugin.xml, running my program as an RCP
>> application still complains of (provider
>> com.bea.xml.stream.MXParserFactory not found) even though it's in one
>> of the JARs I provided as a dependancy?
>
>
>> Anyone got any ideas?
>
>
>> Kevin.
>
>
>
Re: rcp and external jars [message #394710 is a reply to message #394709] Sun, 21 November 2004 11:38 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Lamont_Gilbert.rigidsoftware.com

Did you select the jars for the Source or Binary build? I would suspect
they should be selected for the Binary build.

Also, how can you use classes at runtime that you dont at compile time?
Only way I can think of is to use the class name and instantiate it?




Kevin O'Riordan wrote:
> That didn't work unfortunately. The files are only needed at runtime
> anyway (they get picked up by a Factory class).
>
> Kevin.
>
> Alejandro Narancio wrote:
>
>> You select the jar files in the build tab of the plugin.xml?
>>
>> Regards,
>>
>> Alejandro
>>
>> Kevin O'Riordan wrote:
>>
>>> My program needs extra JARs in its classpath (I'm using XML Stax
>>> parser). Tester methods run fine, I have the jar files in my project
>>> build path. However even when I add the jars to the runtime
>>> dependancies section of my plugin.xml, running my program as an RCP
>>> application still complains of (provider
>>> com.bea.xml.stream.MXParserFactory not found) even though it's in one
>>> of the JARs I provided as a dependancy?
>>
>>
>>
>>> Anyone got any ideas?
>>
>>
>>
>>> Kevin.
>>
>>
>>
>>


--
Respectfully,


CL Gilbert

"Verily, verily, I say unto you, He that entereth not by the door() into
the sheepfold{}, but climbeth up some other *way, the same is a thief
and a robber."

GnuPG Key Fingerprint:
82A6 8893 C2A1 F64E A9AD 19AE 55B2 4CD7 80D2 0A2D

For a free Java interface to Freechess.org see
http://www.rigidsoftware.com/Chess/chess.html
Re: rcp and external jars [message #394711 is a reply to message #394710] Sun, 21 November 2004 12:13 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: k.oriordan.oceanfree.net

CL [dnoyeb] Gilbert wrote:
> Did you select the jars for the Source or Binary build? I would suspect
> they should be selected for the Binary build.
>

I've tried both.

> Also, how can you use classes at runtime that you dont at compile time?
> Only way I can think of is to use the class name and instantiate it?
>

I don't know the exact mechanisms as I don't do it myself explicity. But
a lot of Java APIs like the crypto API, the JDBC API and indeed the XML
api :D are able to use classes that aren't available at compile time,
but available at runtime.

You then do something along the lines of

Class.getInstance("implementationname"); in order to get your class
instance.

This problem is really annoying me by the way, there doesn't seem to be
any sane reason for it, stupid eclipse :(

Kevin
Re: rcp and external jars [message #395149 is a reply to message #394711] Sun, 21 November 2004 23:32 Go to previous messageGo to next message
Eclipse UserFriend
Now I was all keen to help you until I read the last line of your post...
;-)

I suspect the problem lies somewhere around your statement "I add the jars
to the runtime dependancies
section of my plugin.xml". What exactly does that mean?

In the plugin.xml you can either state that you depend on some other
*plugin* or that you include some jars on your classpath. If you define a
plugin for your "external jars" (and export their code in the plugin.xml)
then you should simply list them in the <requires> statement of your
consuming plugin.xml. If you want to put the external jars directly in your
plugin then put them in there and list them in <library> statements.

What are you doing that is different from this?

Jeff

p.s., I doubt that it is relevant here but will mention for completeness.
XML stuff is a bit strange wiht JDK1.4 because it includes an XML parser
directly in the "endorsed dirs" which are added to the boot classpath. As a
result, you always get various XML bits from there and no matter what you
do, you will not be able to override types found there. You have to disable
the endorsed XML parser (Crimson on a Sun VM or Xerces on a IBM VM) if you
want to use your own. There may be some random interaction like that going
on.

"Kevin O'Riordan" <k.oriordan@oceanfree.net> wrote in message
news:cnqic7$prj$1@www.eclipse.org...
> CL [dnoyeb] Gilbert wrote:
> > Did you select the jars for the Source or Binary build? I would
suspect
> > they should be selected for the Binary build.
> >
>
> I've tried both.
>
> > Also, how can you use classes at runtime that you dont at compile time?
> > Only way I can think of is to use the class name and instantiate it?
> >
>
> I don't know the exact mechanisms as I don't do it myself explicity. But
> a lot of Java APIs like the crypto API, the JDBC API and indeed the XML
> api :D are able to use classes that aren't available at compile time,
> but available at runtime.
>
> You then do something along the lines of
>
> Class.getInstance("implementationname"); in order to get your class
> instance.
>
> This problem is really annoying me by the way, there doesn't seem to be
> any sane reason for it, stupid eclipse :(
>
> Kevin
Re: rcp and external jars [message #395170 is a reply to message #394704] Mon, 22 November 2004 05:38 Go to previous messageGo to next message
Eclipse UserFriend
Read about loading classes dynamically inside a plugin here:

http://www.eclipseplugincentral.com/index.php?name=PNphpBB2& amp;file=viewtopic&t=631&start=0&postdays=0& postorder=asc&highlight=

Omer


"Kevin O'Riordan" <k.oriordan@oceanfree.net> wrote in message
news:cno7v5$5d2$1@www.eclipse.org...
> My program needs extra JARs in its classpath (I'm using XML Stax parser).
> Tester methods run fine, I have the jar files in my project build path.
> However even when I add the jars to the runtime dependancies section of my
> plugin.xml, running my program as an RCP application still complains of
> (provider com.bea.xml.stream.MXParserFactory not found) even though it's
> in one of the JARs I provided as a dependancy?
>
> Anyone got any ideas?
>
> Kevin.
Re: rcp and external jars [message #395602 is a reply to message #395149] Tue, 23 November 2004 14:41 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: k.oriordan.oceanfree.net

Jeff McAffer wrote:
> Now I was all keen to help you until I read the last line of your post...
> ;-)
>
> I suspect the problem lies somewhere around your statement "I add the jars
> to the runtime dependancies
> section of my plugin.xml". What exactly does that mean?
>
> In the plugin.xml you can either state that you depend on some other
> *plugin* or that you include some jars on your classpath. If you define a
> plugin for your "external jars" (and export their code in the plugin.xml)
> then you should simply list them in the <requires> statement of your
> consuming plugin.xml. If you want to put the external jars directly in your
> plugin then put them in there and list them in <library> statements.
>
> What are you doing that is different from this?
>
> Jeff

I'm definitely adding those jars using <library> tags

Here's my plugin.xml:

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>
<plugin
id="GraphEdit"
name="%pluginName"
version="0.0.0"
provider-name="%providerName">

<runtime>
<library name="jsr173_1.0_ri.jar">
<export name="*"/>
</library>
<library name="jsr173_1.0_api.jar">
<export name="*"/>
</library>
<library name="GraphEdit.jar">
<export name="*"/>
</library>
</runtime>
<requires>
<import plugin="org.eclipse.core.runtime"/>
<import plugin="org.eclipse.ui"/>
<import plugin="org.eclipse.core.resources"/>
<import plugin="org.eclipse.gef"/>
<import plugin="org.eclipse.ui.ide"/>
</requires>

<extension point="org.eclipse.ui.editors">
<editor name="%editor.name" icon="icons/alt16.gif" extensions="xml"
class="GraphEdit.editor.MyEditor"
contributorClass="GraphEdit.action.MyActionBarContributor"
id="GraphEdit.editor.MyEditor">
</editor>
</extension>

<extension
id="RcpApplication"
point="org.eclipse.core.runtime.applications">
<application>
<run
class="GraphEdit.rcp.RcpApplication">
</run>
</application>
</extension>
<extension
point="org.eclipse.ui.perspectives">
<perspective
name="%perspectiveName"
class="GraphEdit.rcp.RcpPerspective"
id="GraphEdit.rcp.RcpPerspective">
</perspective>
</extension>

<extension
point="org.eclipse.ui.views">
<category
name="SampleCategory"
id="GraphEdit.viewCategory">
</category>
<view
name="Sample"
icon="icons/alt16.gif"
category="GraphEdit.viewCategory"
class="GraphEdit.views.SampleView"
id="GraphEdit.views.SampleView">
</view>
</extension>
</plugin>

My tester methods pick up those jar files fine, but when I run my RCP
application I get:

Unhandled event loop exception
Reason:
Provider com.bea.xml.stream.MXParserFactory not found

MXParserFactory being a class file inside jsr173_1.0_ri.jar


>
> p.s., I doubt that it is relevant here but will mention for completeness.
> XML stuff is a bit strange wiht JDK1.4 because it includes an XML parser
> directly in the "endorsed dirs" which are added to the boot classpath. As a
> result, you always get various XML bits from there and no matter what you
> do, you will not be able to override types found there. You have to disable
> the endorsed XML parser (Crimson on a Sun VM or Xerces on a IBM VM) if you
> want to use your own. There may be some random interaction like that going
> on.
>

I think this part of the equation is fine as my tester methods run
perfectly.

:(
Re: rcp and external jars [message #395605 is a reply to message #395602] Tue, 23 November 2004 19:07 Go to previous messageGo to next message
Eclipse UserFriend
> My tester methods pick up those jar files fine, but when I run my RCP
> application I get:
>
> Unhandled event loop exception
> Reason:
> Provider com.bea.xml.stream.MXParserFactory not found
>
> MXParserFactory being a class file inside jsr173_1.0_ri.jar

Have you tried the trick of:

Thread current = Thread.currentThread();
ClassLoader old = current.getContextClassLoader();
try{
current.setContextClassLoader( getClass().getClassLoader() );
// do stuff that's trying to find MXParserFactory
} finally {
current.setContetClassLoader( old );
}

I've often had to do this when using factory classes, though I don't
know if it applies here.

-Don
Re: rcp and external jars [message #395606 is a reply to message #395605] Tue, 23 November 2004 19:15 Go to previous messageGo to next message
Eclipse UserFriend
> } finally {
> current.setContetClassLoader( old );
> }

Ooops, my copy-and-paste from a previous post pasted the syntax error,
too. The above should read:

} finally {
current.setContextClassLoader( old );
}

-Don
Re: rcp and external jars [message #395612 is a reply to message #395602] Wed, 24 November 2004 12:17 Go to previous messageGo to next message
Eclipse UserFriend
Hmmm, can you enter a bug report in Platform>Runtime with this info. Also,
if you would, include the manifest file that we generate for your plugin.
It should be in
<install
location> /eclipse/configuration/org.eclipse.osgi/manifests/GraphEdit_ 0.0.0.m
f
or some such. If you want do some inspection there, all the packages that
you are looking for should be "provided" in the manifest.

Also, I am a little unclear what you mean by "tester methods" and "running
your RCP application". When you are "testing" are you running an Eclipse
instance or just a Java program?

Please ensure that you are using -clean on the command line when launching
your RCP application. This will toss and regen any cached info (e.g.,
generated manifest files).

Jeff

"Kevin O'Riordan" <k.oriordan@oceanfree.net> wrote in message
news:co03op$gt1$1@www.eclipse.org...
> Jeff McAffer wrote:
> > Now I was all keen to help you until I read the last line of your
post...
> > ;-)
> >
> > I suspect the problem lies somewhere around your statement "I add the
jars
> > to the runtime dependancies
> > section of my plugin.xml". What exactly does that mean?
> >
> > In the plugin.xml you can either state that you depend on some other
> > *plugin* or that you include some jars on your classpath. If you define
a
> > plugin for your "external jars" (and export their code in the
plugin.xml)
> > then you should simply list them in the <requires> statement of your
> > consuming plugin.xml. If you want to put the external jars directly in
your
> > plugin then put them in there and list them in <library> statements.
> >
> > What are you doing that is different from this?
> >
> > Jeff
>
> I'm definitely adding those jars using <library> tags
>
> Here's my plugin.xml:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <?eclipse version="3.0"?>
> <plugin
> id="GraphEdit"
> name="%pluginName"
> version="0.0.0"
> provider-name="%providerName">
>
> <runtime>
> <library name="jsr173_1.0_ri.jar">
> <export name="*"/>
> </library>
> <library name="jsr173_1.0_api.jar">
> <export name="*"/>
> </library>
> <library name="GraphEdit.jar">
> <export name="*"/>
> </library>
> </runtime>
> <requires>
> <import plugin="org.eclipse.core.runtime"/>
> <import plugin="org.eclipse.ui"/>
> <import plugin="org.eclipse.core.resources"/>
> <import plugin="org.eclipse.gef"/>
> <import plugin="org.eclipse.ui.ide"/>
> </requires>
>
> <extension point="org.eclipse.ui.editors">
> <editor name="%editor.name" icon="icons/alt16.gif" extensions="xml"
> class="GraphEdit.editor.MyEditor"
> contributorClass="GraphEdit.action.MyActionBarContributor"
> id="GraphEdit.editor.MyEditor">
> </editor>
> </extension>
>
> <extension
> id="RcpApplication"
> point="org.eclipse.core.runtime.applications">
> <application>
> <run
> class="GraphEdit.rcp.RcpApplication">
> </run>
> </application>
> </extension>
> <extension
> point="org.eclipse.ui.perspectives">
> <perspective
> name="%perspectiveName"
> class="GraphEdit.rcp.RcpPerspective"
> id="GraphEdit.rcp.RcpPerspective">
> </perspective>
> </extension>
>
> <extension
> point="org.eclipse.ui.views">
> <category
> name="SampleCategory"
> id="GraphEdit.viewCategory">
> </category>
> <view
> name="Sample"
> icon="icons/alt16.gif"
> category="GraphEdit.viewCategory"
> class="GraphEdit.views.SampleView"
> id="GraphEdit.views.SampleView">
> </view>
> </extension>
> </plugin>
>
> My tester methods pick up those jar files fine, but when I run my RCP
> application I get:
>
> Unhandled event loop exception
> Reason:
> Provider com.bea.xml.stream.MXParserFactory not found
>
> MXParserFactory being a class file inside jsr173_1.0_ri.jar
>
>
> >
> > p.s., I doubt that it is relevant here but will mention for
completeness.
> > XML stuff is a bit strange wiht JDK1.4 because it includes an XML parser
> > directly in the "endorsed dirs" which are added to the boot classpath.
As a
> > result, you always get various XML bits from there and no matter what
you
> > do, you will not be able to override types found there. You have to
disable
> > the endorsed XML parser (Crimson on a Sun VM or Xerces on a IBM VM) if
you
> > want to use your own. There may be some random interaction like that
going
> > on.
> >
>
> I think this part of the equation is fine as my tester methods run
> perfectly.
>
> :(
Re: rcp and external jars [message #395814 is a reply to message #395605] Wed, 24 November 2004 16:23 Go to previous message
Eclipse UserFriend
Originally posted by: k.oriordan.oceanfree.net

Don McKee wrote:
>> My tester methods pick up those jar files fine, but when I run my RCP
>> application I get:
>>
>> Unhandled event loop exception
>> Reason:
>> Provider com.bea.xml.stream.MXParserFactory not found
>>
>> MXParserFactory being a class file inside jsr173_1.0_ri.jar
>
>
> Have you tried the trick of:
>
> Thread current = Thread.currentThread();
> ClassLoader old = current.getContextClassLoader();
> try{
> current.setContextClassLoader( getClass().getClassLoader() );
> // do stuff that's trying to find MXParserFactory
> } finally {
> current.setContetClassLoader( old );
> }
>
> I've often had to do this when using factory classes, though I don't
> know if it applies here.
>
> -Don

Finally, a solution that worked. Thank you so much :)

Kevin.
Previous Topic:Debug Problem RCP Tutorial
Next Topic:global actions/commands
Goto Forum:
  


Current Time: Tue Oct 14 10:26:51 EDT 2025

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

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

Back to the top