Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Cannot cast from a.Class to a.Class
Cannot cast from a.Class to a.Class [message #1221269] Tue, 17 December 2013 09:18 Go to next message
Vincenzo Caselli is currently offline Vincenzo CaselliFriend
Messages: 100
Registered: January 2012
Senior Member
Hi,
in order to integrate our RAP application into a production environment we needed to add a <filter> in the web.xml.
The filter make use of a third-party Jar which contains a class that has to be called from inside the RAP application.
We put this Jar into the application in the usual RCP way (plugin.xml, tab 'Runtime', Classpath section, Add.. and also checked it in build.properties for exporting).
When we deployed the application the first time we got an error about setting the filter; then we put the third-party Jar also into the WEB-INF/lib folder.
In this way the filter error does not show and the application starts.
The problem comes when the application calls the class from the Jar, where we get the following error:
'Cannot cast object from a.Class to a.Class'
It seems that having this double location for the jar may be the cause.
What is the correct way in this cases?
Thank you
Vincenzo
Re: Cannot cast from a.Class to a.Class [message #1221419 is a reply to message #1221269] Tue, 17 December 2013 16:55 Go to previous messageGo to next message
Markus  rüger is currently offline Markus rügerFriend
Messages: 369
Registered: July 2009
Senior Member
Vincenzo Caselli <forums-noreply@xxxxxxxx> wrote:
> Hi,
> in order to integrate our RAP application into a production environment
> we needed to add a <filter> in the web.xml.
> The filter make use of a third-party Jar which contains a class that has
> to be called from inside the RAP application.
> We put this Jar into the application in the usual RCP way (plugin.xml,
> tab 'Runtime', Classpath section, Add.. and also checked it in
> build.properties for exporting).
> When we deployed the application the first time we got an error about
> setting the filter; then we put the third-party Jar also into the WEB-INF/lib folder.
> In this way the filter error does not show and the application starts.
> The problem comes when the application calls the class from the Jar,
> where we get the following error:
> 'Cannot cast object from a.Class to a.Class'
> It seems that having this double location for the jar may be the cause.
> What is the correct way in this cases?
> Thank you
> Vincenzo

Hi Vincenzo,

You could try to use the filter extensionpoint in your plugin instead of
defining it in your web.xml.

Regards,
Markus
Re: Cannot cast from a.Class to a.Class [message #1221440 is a reply to message #1221419] Tue, 17 December 2013 18:05 Go to previous messageGo to next message
Vincenzo Caselli is currently offline Vincenzo CaselliFriend
Messages: 100
Registered: January 2012
Senior Member
Hi Markus,
this third party library is for automatic authentication (a sort of single-signon).
It comes with specific instructions on how to modify the web.xml, so, unless the filter extensionpoint does exactly the same thing of <filter> tag, we would try to stay with the standard J2EE way.

But maybe RAP can handle this.
In fact we saw that the .warproduct file (we followed your tutorial at http://eclipse.org/rap/developers-guide/devguide.php?topic=deployment.html&version=2.1), in the Configuration tab, has the Library section, which says "List all the libraries that go into the lib folder of the WAR file": well, it seems just what we need!
Pressing the Add button we selected the Jar from the plugin where we put at the beginning; once selected it shows in the Libraries section.
When exporting the WAR we see it exactly in the WEB-INF/lib!

Tomorrow I will try the deploy of this war and I'll let you know.
For now I would just be sure to have made the correct usage of the Libraries section in warproduct: in the end what we made was:
1) put the Jar into one of the application plugins in the usual RCP way
2) add it in the .warproduct file, so to have it into WEB-INF/lib when exported
is this the correct procedure?

Thank you very much
Vincenzo
Re: Cannot cast from a.Class to a.Class [message #1221702 is a reply to message #1221440] Wed, 18 December 2013 09:10 Go to previous messageGo to next message
Arnaud MERGEY is currently offline Arnaud MERGEYFriend
Messages: 145
Registered: March 2010
Location: France
Senior Member
Hello,

To avoid lib duplication, and you need to have some libs in WEB-INF/lib of your legacy war,
you can configure servlet bridge to expose these libs in equinox runtime for the web application.

You can update launch.ini :
osgi.parentClassloader=app
osgi.contextClassLoaderParent=ccl

then with org.osgi.framework.system.packages.extra property, you can define which packages will be exported inside equinox runtime
you can import these packages in required bundle, lib define in WEB-INF lib will be used


Regards,
Arnaud

Re: Cannot cast from a.Class to a.Class [message #1221739 is a reply to message #1221702] Wed, 18 December 2013 10:36 Go to previous messageGo to next message
Vincenzo Caselli is currently offline Vincenzo CaselliFriend
Messages: 100
Registered: January 2012
Senior Member
Hi Arnaud,
thank you. Should we follow your suggestion in addition to the procedure I described (add it in the .warproduct file, section Libraries)?
TIA
Vincenzo
Re: Cannot cast from a.Class to a.Class [message #1221863 is a reply to message #1221702] Wed, 18 December 2013 15:19 Go to previous message
Vincenzo Caselli is currently offline Vincenzo CaselliFriend
Messages: 100
Registered: January 2012
Senior Member
Arnaud,
I followed your suggestion after adding the jar to the .warproduct file in Libraries section(this latest step alone did not worked): it worked!!
You saved my day, thank you!!
Cheers
Vincenzo
Previous Topic:ToolTip down not work correctly
Next Topic:ServerPushSessions
Goto Forum:
  


Current Time: Sat Dec 20 19:36:22 GMT 2014

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

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