Blocker OSGi #6078

Closed
vaadin-bot opened this Issue Jan 7, 2015 · 6 comments

Projects

None yet

1 participant

@vaadin-bot
Collaborator

Originally by florian.pirchner@gmail.com


Hey,

there is a very bad OSGi blocker in Vaadin 7.3.7.

I could not find out what was the difference to older versions, since we migrated our P2 repo to Vaadin 7.3.7 today.

But it is a class loading issue.

Please run https://github.com/lunifera/lunifera-vaadin-examples/tree/master/org.lunifera.example.vaadin.osgi/org.lunifera.example.vaadin.osgi.bootstrap.simple

If you need any help, give me a call at skype:ktwpif

The problem is, that ServletPortletHelper#verifyUiClass tries to load the UiClass by its name. And the classloader is the classloader from com.vaadin.server. So it does not have access to the UI class, since it is located in a different bundle.

Thanks a lot for quick response...

Best Florian

The stacktrace:
javax.servlet.ServletException: com.vaadin.server.ServiceException: com.vaadin.server.ServiceException: org.lunifera.example.vaadin.osgi.bootstrap.simple.SimpleUI could not be loaded
at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:307)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
at org.eclipse.equinox.http.servlet.internal.ServletRegistration.service(ServletRegistration.java:61)
at org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:128)
at org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:60)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
at org.eclipse.equinox.http.jetty.internal.HttpServerManager$InternalHttpServiceServlet.service(HttpServerManager.java:360)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:684)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:501)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:229)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:428)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
at org.eclipse.jetty.server.Server.handle(Server.java:370)
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:494)
at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:971)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:1033)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:644)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:667)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
at java.lang.Thread.run(Thread.java:745)
Caused by:
com.vaadin.server.ServiceException: com.vaadin.server.ServiceException: org.lunifera.example.vaadin.osgi.bootstrap.simple.SimpleUI could not be loaded
at com.vaadin.server.VaadinService.handleExceptionDuringRequest(VaadinService.java:1464)
at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1418)
at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:305)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
at org.eclipse.equinox.http.servlet.internal.ServletRegistration.service(ServletRegistration.java:61)
at org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:128)
at org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:60)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
at org.eclipse.equinox.http.jetty.internal.HttpServerManager$InternalHttpServiceServlet.service(HttpServerManager.java:360)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:684)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:501)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:229)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:428)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
at org.eclipse.jetty.server.Server.handle(Server.java:370)
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:494)
at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:971)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:1033)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:644)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:667)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
at java.lang.Thread.run(Thread.java:745)
Caused by:
com.vaadin.server.ServiceException: org.lunifera.example.vaadin.osgi.bootstrap.simple.SimpleUI could not be loaded
at com.vaadin.server.ServletPortletHelper.verifyUIClass(ServletPortletHelper.java:77)
at com.vaadin.server.ServletPortletHelper.initDefaultUIProvider(ServletPortletHelper.java:139)
at com.vaadin.server.VaadinService.createAndRegisterSession(VaadinService.java:768)
at com.vaadin.server.VaadinService.doFindOrCreateVaadinSession(VaadinService.java:722)
at com.vaadin.server.VaadinService.findOrCreateVaadinSession(VaadinService.java:663)
at com.vaadin.server.VaadinService.findVaadinSession(VaadinService.java:522)
at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1400)
at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:305)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
at org.eclipse.equinox.http.servlet.internal.ServletRegistration.service(ServletRegistration.java:61)
at org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:128)
at org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:60)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
at org.eclipse.equinox.http.jetty.internal.HttpServerManager$InternalHttpServiceServlet.service(HttpServerManager.java:360)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:684)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:501)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:229)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:428)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
at org.eclipse.jetty.server.Server.handle(Server.java:370)
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:494)
at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:971)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:1033)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:644)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:667)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
at java.lang.Thread.run(Thread.java:745)
Caused by:
java.lang.ClassNotFoundException: org.lunifera.example.vaadin.osgi.bootstrap.simple.SimpleUI
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.eclipse.osgi.internal.framework.ContextFinder.loadClass(ContextFinder.java:131)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at com.vaadin.server.ServletPortletHelper.verifyUIClass(ServletPortletHelper.java:70)
at com.vaadin.server.ServletPortletHelper.initDefaultUIProvider(ServletPortletHelper.java:139)
at com.vaadin.server.VaadinService.createAndRegisterSession(VaadinService.java:768)
at com.vaadin.server.VaadinService.doFindOrCreateVaadinSession(VaadinService.java:722)
at com.vaadin.server.VaadinService.findOrCreateVaadinSession(VaadinService.java:663)
at com.vaadin.server.VaadinService.findVaadinSession(VaadinService.java:522)
at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1400)
at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:305)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
at org.eclipse.equinox.http.servlet.internal.ServletRegistration.service(ServletRegistration.java:61)
at org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:128)
at org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:60)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
at org.eclipse.equinox.http.jetty.internal.HttpServerManager$InternalHttpServiceServlet.service(HttpServerManager.java:360)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:684)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:501)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:229)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:428)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
at org.eclipse.jetty.server.Server.handle(Server.java:370)
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:494)
at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:971)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:1033)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:644)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:667)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
at java.lang.Thread.run(Thread.java:745)


Imported from https://dev.vaadin.com/ issue #15516

@vaadin-bot
Collaborator

Originally by proaccountapp


Updated prioritization date.

@vaadin-bot
Collaborator

Originally by @Legioth


Most likely caused by #11295 - Vaadin now uses the context classloader instead of the classloader of the servlet class.

One observation is that the offending code should only be run if you have set the UI init parameter. That parameter has no other use than to control what UI class is loaded by the default UI provider, which would most likely not make sense in an OSGi environment?

If you know what classloader to use, you can also instruct Vaadin to use it by creating a subclass of VaadinServletService and override getClassLoader().

@vaadin-bot
Collaborator

Originally by florian.pirchner@gmail.com


Sure, but that approach would add a lot of complexity in using OSGi.

Maybe it would be a good idea, to provide com.vaadin.server.OSGiServlet and com.vaadin.server.OSGiServletService.

And the defaults impls from Vaadin do exactly what mentioned above. So people know, that they have to use the com.vaadin.server.OSGiServlet in OSGi environments, but do not have to deal with details about classloading.

WDYT?

Best, Florian

@vaadin-bot
Collaborator

Originally by @Legioth


So just to make sure I've understood the situation correctly: you have your UI class and a VaadinServlet subclass in the same bundle and define the UI class using the standard init parameter?

I was for some reason assuming that you had a UIProvider that used an OSGi service for getting UIs.

I'm a bit reluctant to introducing an OSGiServlet in the framework since there might be many different approaches for using OSGi and we might not want to tie the official framework solution to any specific approach. I would instead suggest introducing an init parameter that instructs Vaadin to use the classloader of the servlet class instead of using the context classloader (if no custom classloader has been defined by overriding VaadinService).

@vaadin-bot
Collaborator

Originally by florianpirchner


I agree. An init parameter would be perfect!

Thanks a lot,
Florian

@vaadin-bot
Collaborator

Originally by @tepi


Hi,

I tried to reproduce this issue, but the linked project in github is no longer buildable due to an abandoned repository.

Additionally I created a simple OSGi bundle using Vaadin 7.5.0.rc1 where I have an activator, servlet and an UI. The UI is defined in the overridden servlet's VaadinServletConfiguration annotation. This setup works fine when I run it on Apache Karaf. I ran the application using both Felix and Equinox frameworks - both seem to work fine.

Please provide a working testcase to reproduce the issue.

@vaadin-bot vaadin-bot closed this Jun 15, 2015
@vaadin-bot vaadin-bot added the bug label Dec 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment