Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Servlet can not be registered(Servlet can not be registered duu to java.lang.LinkageError: loader constraint violation.)
Servlet can not be registered [message #899728] Thu, 02 August 2012 06:46 Go to next message
Piotr Slonicz is currently offline Piotr Slonicz
Messages: 13
Registered: August 2011
Location: Munich
Junior Member
I use a common implemetation for registering servlets, i.e.:
- Activator Class with start/ stop methods and with HttpServiceTracker
- HttpServiceTracker Class with addingService/ removedService methods
- Servlet Class
- Manifest (Import-Package: javax.servlet, javax.servlet.http)

After I have switch the Rap Target Platform from 1.5 RC1 to newer one (RC2, RC3, R) maven can not build my war product anymore, because of:
Missing Constraint: Import-Package: javax.servlet; version="0.0.0"
Missing Constraint: Import-Package: javax.servlet.http; version="0.0.0"

(1) When I update my Manifest file from "Import-Package: javax.servlet, javax.servlet.http" to "Require-Bundle: javax.servlet;bundle-version="3.0.0" maven build works but servlet can not be correctly registered in my application and following Throwable is thrown:
---
java.lang.LinkageError: loader constraint violation: when resolving interface method "org.osgi.service.http.HttpService.registerServlet(Ljava/lang/String;Ljavax/servlet/Servlet;Ljava/util/Dictionary;Lorg/osgi/service/http/HttpContext;)V"
the class loader (instance of org/eclipse/osgi/internal/baseadaptor/DefaultClassLoader) of the current class, mypackage/servlets/HttpServiceTracker, and the class loader (instance of org/eclipse/osgi/internal/baseadaptor
/DefaultClassLoader) for resolved class, org/osgi/service/http/HttpService, have different Class objects for the type javax/servlet/Servlet used in the signature
---

I am not sure what is wrong in my application or environment and why "LinkageError" is thrown. Maybe I unnecessary change my manifest (1) and I suppose to solve it in another way.

Any ideas, how could I solve this problem?!

Thanks for any hints.
Piotr
Re: Servlet can not be registered [message #899961 is a reply to message #899728] Fri, 03 August 2012 08:45 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan Furnadjiev
Messages: 1846
Registered: July 2009
Senior Member
Hi Piotr,
could be that both servlet 2.5 and servlet 3.0 exists and selected in
your launch configuration?
Best,
Ivan

On 8/2/2012 9:46 AM, Piotr Slonicz wrote:
> I use a common implemetation for registering servlets, i.e.:
> - Activator Class with start/ stop methods and with HttpServiceTracker
> - HttpServiceTracker Class with addingService/ removedService methods
> - Servlet Class
> - Manifest (Import-Package: javax.servlet, javax.servlet.http)
>
> After I have switch the Rap Target Platform from 1.5 RC1 to newer one
> (RC2, RC3, R) maven can not build my war product anymore, because of:
> Missing Constraint: Import-Package: javax.servlet; version="0.0.0"
> Missing Constraint: Import-Package: javax.servlet.http; version="0.0.0"
>
> (1) When I update my Manifest file from "Import-Package:
> javax.servlet, javax.servlet.http" to "Require-Bundle:
> javax.servlet;bundle-version="3.0.0" maven build works but servlet can
> not be correctly registered in my application and following Throwable
> is thrown:
> ---
> java.lang.LinkageError: loader constraint violation: when resolving
> interface method
> "org.osgi.service.http.HttpService.registerServlet(Ljava/lang/String;Ljavax/servlet/Servlet;Ljava/util/Dictionary;Lorg/osgi/service/http/HttpContext;)V"
> the class loader (instance of
> org/eclipse/osgi/internal/baseadaptor/DefaultClassLoader) of the
> current class, mypackage/servlets/HttpServiceTracker, and the class
> loader (instance of org/eclipse/osgi/internal/baseadaptor
> /DefaultClassLoader) for resolved class,
> org/osgi/service/http/HttpService, have different Class objects for
> the type javax/servlet/Servlet used in the signature
> ---
>
> I am not sure what is wrong in my application or environment and why
> "LinkageError" is thrown. Maybe I unnecessary change my manifest (1)
> and I suppose to solve it in another way.
>
> Any ideas, how could I solve this problem?!
>
> Thanks for any hints.
> Piotr

--
Ivan Furnadjiev

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: Servlet can not be registered [message #900072 is a reply to message #899961] Fri, 03 August 2012 19:43 Go to previous messageGo to next message
Piotr Slonicz is currently offline Piotr Slonicz
Messages: 13
Registered: August 2011
Location: Munich
Junior Member
Hi Ivan,

I have just realized, that I haven't write, that, when I start my application locally in Eclipse environment, all works fine and servlet is correctly registered, but if I deploy my war product in Tomcat, already mentioned throwable is thrown.

In my launch configuration there is only one selected servlet jar library and it comes from RAP target platform. Servlet library is also included in my war product and it is also started (I have checked it with osgi console).

Maybe there is some conflict between servlet-api.jar which is delivered together with tomcat and servlet jar delivered with my war product?!
What I do not understand, is why after I have migrate from 1.5TP RC1 to RC2 (or newer) package imports doesn't work anymore (javax.servlet, javax.servlet.http).

Regards,
Piotr
Re: Servlet can not be registered [message #900112 is a reply to message #900072] Sat, 04 August 2012 07:05 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan Furnadjiev
Messages: 1846
Registered: July 2009
Senior Member
Piotr,
servlet library will be provided by the servlet container (Tomcat) and
you must not include it in your war file.
Best,
Ivan

On 8/3/2012 10:43 PM, Piotr Slonicz wrote:
> Hi Ivan,
>
> I have just realized, that I haven't write, that, when I start my
> application locally in Eclipse environment, all works fine and servlet
> is correctly registered, but if I deploy my war product in Tomcat,
> already mentioned throwable is thrown.
>
> In my launch configuration there is only one selected servlet jar
> library and it comes from RAP target platform. Servlet library is also
> included in my war product and it is also started (I have checked it
> with osgi console).
>
> Maybe there is some conflict between servlet-api.jar which is
> delivered together with tomcat and servlet jar delivered with my war
> product?!
> What I do not understand, is why after I have migrate from 1.5TP RC1
> to RC2 (or newer) package imports doesn't work anymore (javax.servlet,
> javax.servlet.http).
>
> Regards,
> Piotr

--
Ivan Furnadjiev

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: Servlet can not be registered [message #900535 is a reply to message #900112] Tue, 07 August 2012 12:26 Go to previous messageGo to next message
Piotr Slonicz is currently offline Piotr Slonicz
Messages: 13
Registered: August 2011
Location: Munich
Junior Member
Hi Ivan,
thanks for hints.
I know that I have already tried it - war product without servlet jar, but it hasn't worked. None of Bundle, which servlet jar use, have been startet. Probabaly jar was not found.
Do I have to say osgi where tomcat classpath is?
Is tomcat classpath by osgi automaticlly inherited?

What is the best practice for other java libraries such as (for example): xml, persistence? Should be included in war product or not?

Regards
Piotr
Re: Servlet can not be registered [message #900538 is a reply to message #900535] Tue, 07 August 2012 12:45 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan Furnadjiev
Messages: 1846
Registered: July 2009
Senior Member
Piotr,
which Tomcat version are you using - 7.0.x? The RAP FAQ topic "Exported
WAR file does not work" might help.
[1] http://wiki.eclipse.org/RAP/FAQ#Exported_WAR_file_does_not_work
Best,
Ivan

On 8/7/2012 3:26 PM, Piotr Slonicz wrote:
> Hi Ivan,
> thanks for hints.
> I know that I have already tried it - war product without servlet jar,
> but it hasn't worked. None of Bundle, which servlet jar use, have been
> startet. Probabaly jar was not found.
> Do I have to say osgi where tomcat classpath is?
> Is tomcat classpath by osgi automaticlly inherited?
>
> What is the best practice for other java libraries such as (for
> example): xml, persistence? Should be included in war product or not?
>
> Regards
> Piotr

--
Ivan Furnadjiev

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: Servlet can not be registered [message #900546 is a reply to message #900538] Tue, 07 August 2012 13:24 Go to previous message
Piotr Slonicz is currently offline Piotr Slonicz
Messages: 13
Registered: August 2011
Location: Munich
Junior Member
Hi Ivan,

I use Tomcat 7.0.19.
Thanks for that link. I see there some hints which might be usefull to solve my problem.

Regards,
Piotr
Previous Topic:Nebula Grid plug-in(JAR) Download Address?
Next Topic:Workspace in RAP
Goto Forum:
  


Current Time: Fri Oct 31 05:53:05 GMT 2014

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

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