Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Help to run Vaadin in Equinox Bundle
I have tried again to execute Vaadin inside OSGI bundle. Old Post
Again, I followed this video that shows how to create a Servlet as a extension of a OSGI bundle.
After, I created a new extension to direct the requests to Vaadin’s ApplicationServlet, the final configuration of my bundle was:
<extension point="org.eclipse.equinox.http.registry.servlets"> <servlet alias="/go" class="com.vaadin.terminal.gwt.server.ApplicationServlet"> <init-param name="application" value="org.upskill.roadrunner.main.Test"> </init-param> </servlet> </extension>
After to try to execute my Vaadin application inside a bundle I got this error:
Failed to load the widgetset: /VAADIN/widgetsets/com.vaadin.terminal.gwt.DefaultWidgetSet/com.vaadin.terminal.gwt.DefaultWidgetSet.nocache.js?1254683356152
I believe that the problem is related with the organization of my project. The below image shows my project in eclipse.
Do you know how to work around of this issue?
Widgetsets could be either loaded from VAADIN directory in the web content directory or served by ApplicationServlet (that reads them from vaadin.jar). Your options are: either add (somehow) VAADIN directory to your bundle in a such manner that the contents are served as /VAADIN/* or configure bundle (somehow) to forward /VAADIN/* requests to ApplicationServlet.
Please post your experiences.
Thank you Joonas,
I have changed my bundle configuration to send the requests to /VAADIN/* and redirect it to ApplicationServlet; it worked fine. See the below modification,
<extension point="org.eclipse.equinox.http.registry.servlets"> <servlet alias="/[b]VAADIN[/b]" class="com.vaadin.terminal.gwt.server.ApplicationServlet"> <init-param name="application" value="org.upskill.roadrunner.main.Test"> </init-param> </servlet> </extension>
However, there is one inconvinient, the requests must be send to /VAADIN/* directory, so all application must have send the request to this directory ,,, :( I will try to work around latter,
I think it is due to how classloading is handled in an OSGi-container. We are currently working on implementing OSGi-support for Vaadin. I'll let you know when something is ready for testing.
Edit: Sorry, I misunderstood your problem. I ran into a similar problem while trying to deploy the Vaadin library as an OSGi-bundle and that was due to a classloader problem.
I got my bundle up and running with Vaadin library. However, the URL to access my application must be something like that: http://localhost/VAADIN.
I’d like to get evolved with the test of Vaadin in a OSGI bundle, can I participate?
There is a preliminary version of the OSGi-manifest in the nightly builds of Vaadin 6.2 as of October 13, 2009. Feel free to check it out.
Sorry for my late message.
I have replaced the jar files in my project and it doesn’t properly for me. I still need to direct the HTTP requests to /VAADIN URL.
I used vaadin-6.1.nightly-20090813-c8480.jar, is that correct?
You have to use the 6.2 nightly builds to get OSGi-support. However, due to a versioning problem, the manifest in the nightly builds that are available for download is not working.
If you like, you could send me an e-mail (petter dot holmstrom AT itmill dot com) and I'll send you the Vaadin library I've been using to experiment with OSGi.
I think I know what the problem is now. The application servlet generates the path to the themes and the widgetsets like this: [context path]/VAADIN/....
However, when you run the servlet inside the Equinox HTTP server, there is no context path as the servlets are registered directly with the HTTP service. Thus, your applications will try to find the widgetsets in the /VAADIN -directory.
There are a few ways around this:
- Put the VAADIN files somewhere in your bundle and add redirect /VAADIN requests to the directory using the org.eclipse.equinox.http.registry.resources extension point (see this example).
- Create a dummy application servlet with an empty application and let it handle all /VAADIN requests.
- Subclass AbstractApplicationServlet and modify the request somehow (don't know if this works).
- Switch to GlassFish 3, which is a JEE server with OSGi-support. I'm currently writing a series of articles on this subject, you can find one of them here.
I hope this helps you in some way.
I have chosen the first option and it worked fine for me, thank you. The below image illustrates have I have done. Following your directions, I created another extension point to expose the Vaadin resources, so, I put the Vaadin files inside the VAADIN directory.
Do you think is better to use Glasfish?
I'm glad you got it working. As to whether you should use GlassFish or Equninox, it depends on what you are trying to do. There are advantages and disadvantages with both approaches. The advantage with using GlassFish is that it gives you both JEE and OSGi, which may ease development. On the other hand, Equinox has Buddy Loading which may be required to get Hibernate and other OSGi-unfriendly libraries to work properly.
My suggestion is that you try both alternatives (if you package your plugins wisely, you should be able to deploy them both to Equinox and GlassFish without modification) and choose the one that fits your requirements best.