Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » Vaadin + Virgo not working...(ServletException when accessing simple Vaadin app on Virgo server)
icon5.gif  Vaadin + Virgo not working... [message #676451] Sat, 04 June 2011 13:57 Go to next message
Arnold Schrijver is currently offline Arnold SchrijverFriend
Messages: 6
Registered: June 2011
Junior Member
I am having problems to get Vaadin 6.6.0 to work with Eclipse Virgo 3.0.0.M05.

I created an OSGi Shared Services WAR using Maven3 and installed it in Virgo (either by dropping WAR in the 'pickup' dir, or by running Virgo from Eclipse). The bundle installs correctly and all dependencies can be found (after modifying MANIFEST.MF in vaadin-6.6.0.jar to get it compatible with strict OSGi compliance enforced by Virgo. See 'dev.vaadin.com/ticket/6945' for details).

However, when I open the URL in the browser ('localhost:8080/osgi-webapp') I am receiving a ServletException. Only minimal information is provided:

javax.servlet.ServletException: Failed to load application class: test.vaadin.MyApplication
	com.vaadin.terminal.gwt.server.ApplicationServlet.init(ApplicationServlet.java:71)
	org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
	org.eclipse.virgo.web.tomcat.support.ApplicationNameTrackingValve.invoke(ApplicationNameTrackingValve.java:33)
	org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
	org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)
	org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
	org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:166)
	org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
	java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
	java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
	java.lang.Thread.run(Thread.java:619)


note The full stack trace of the root cause is available in the Apache Tomcat/7.0.12 logs.


Although it says that the full information is in the Tomcat logs, this is really all information there is available. I am really stuck here. Tried a lot of different things. In the end I created two minimal projects based on maven-archetype-webapp: one standard WAR and an OSGi web bundle to demonstrate the problem. The standard WAR is of course working, the other is not. The zipfile containing both projects and the modified Vaadin jar can be found at this location 'vaadin.com/forum/-/message_boards/view_message/491170' (I cross-posted this message because I a do not know whether this is caused by Vaadin or Virgo, and larger attachments are allowed there Smile )

Is there anyone who can help me out here? Any help would be greatly appreciated!

(PS: I cannot create real hyperlinks so I added them between quotes)
Re: Vaadin + Virgo not working... [message #676456 is a reply to message #676451] Sat, 04 June 2011 14:34 Go to previous messageGo to next message
Ryan  is currently offline Ryan Friend
Messages: 17
Registered: May 2011
Junior Member
I don't know anything about Vaadin, but that ServletException looks like it might have a ClassNotFoundException or the like as its root cause. It would be helpful if you could find the "tomcat logs" it's referring to so you could see the exact error/exception and stacktrace. In a stock Tomcat install, that kind of info would end up in the localhost logs. Probably some package just isn't getting imported by a bundle that needs it.
Re: Vaadin + Virgo not working... [message #676465 is a reply to message #676456] Sat, 04 June 2011 16:35 Go to previous messageGo to next message
Arnold Schrijver is currently offline Arnold SchrijverFriend
Messages: 6
Registered: June 2011
Junior Member
Thanks. Yes, this was also the first thing I was looking for. As far as I know the logentries for the embedded Tomcat end up in <virgo-dir>/serviceability/logs/log.log, but unfortunately there is absolutely no additional information there. I looked in all other logs as well...no luck.
Re: Vaadin + Virgo not working... [message #676491 is a reply to message #676465] Sat, 04 June 2011 20:21 Go to previous messageGo to next message
Hristo Iliev is currently offline Hristo IlievFriend
Messages: 156
Registered: May 2010
Location: Sofia, Bulgaria
Senior Member

Seems like Vaadin tries to load the application class:
        // Gets the application class name
        final String applicationClassName = servletConfig
                .getInitParameter("application");
        if (applicationClassName == null) {
            throw new ServletException(
                    "Application not specified in servlet parameters");
        }

        try {
            applicationClass = (Class<? extends Application>) getClassLoader()
                    .loadClass(applicationClassName);
        } catch (final ClassNotFoundException e) {
            throw new ServletException("Failed to load application class: "
                    + applicationClassName);
        }


The ClassNotFound is wrapped in the ServletException you get.

The class loader used here is:
    protected ClassLoader getClassLoader() throws ServletException {
        // Gets custom class loader
        final String classLoaderName = getApplicationOrSystemProperty(
                "ClassLoader", null);
        ClassLoader classLoader;
        if (classLoaderName == null) {
            classLoader = getClass().getClassLoader();
        } else {
            try {
                final Class<?> classLoaderClass = getClass().getClassLoader()
                        .loadClass(classLoaderName);
                final Constructor<?> c = classLoaderClass
                        .getConstructor(new Class[] { ClassLoader.class });
                classLoader = (ClassLoader) c
                        .newInstance(new Object[] { getClass().getClassLoader() });
            } catch (final Exception e) {
                throw new ServletException(
                        "Could not find specified class loader: "
                                + classLoaderName, e);
            }
        }
        return classLoader;
    }


I suspect that the problem here is that Vaadin tries to load your class with its own class loader (vaadin bundle's one).
Re: Vaadin + Virgo not working... [message #676499 is a reply to message #676491] Sat, 04 June 2011 21:42 Go to previous messageGo to next message
Arnold Schrijver is currently offline Arnold SchrijverFriend
Messages: 6
Registered: June 2011
Junior Member
Aah, thanks a lot, that pointed me in the right direction! I can specify a different classloader in an application property.
Also found this thread on Vaadin site that deals with the same issue: vaadin.com/forum/-/message_boards/view_message/235690
Don't know if the solution proposed there is the best solution, but it seems worth a try.

I will try this tomorrow, and I'll probably also need to do some more reading into the way OSGi handles classloading.
Re: Vaadin + Virgo not working... [message #676505 is a reply to message #676499] Sat, 04 June 2011 22:47 Go to previous messageGo to next message
Arnold Schrijver is currently offline Arnold SchrijverFriend
Messages: 6
Registered: June 2011
Junior Member
Seems like I have to do some reading on scoping and plans in Virgo and achieve the equivalent of buddy class loading here. So, something to do tomorrow Smile
Re: Vaadin + Virgo not working... [message #676585 is a reply to message #676505] Sun, 05 June 2011 14:03 Go to previous messageGo to next message
Arnold Schrijver is currently offline Arnold SchrijverFriend
Messages: 6
Registered: June 2011
Junior Member
I can't get it to work properly. Always keep getting CNF exceptions. Tried manipulating the TCCL in various ways and experimented with Virgo Plan's, but unfortunately without success.
Re: Vaadin + Virgo not working... [message #676668 is a reply to message #676585] Mon, 06 June 2011 03:53 Go to previous messageGo to next message
Ryan  is currently offline Ryan Friend
Messages: 17
Registered: May 2011
Junior Member
How much do you know about OSGi? The suggestions in the thread you mentioned earlier largely centered around making Vaadin a shared library with a typical servlet container's classloader setup. Virgo/OSGi is nothing like that. From what I gather--and again, I know nothing about Vaadin--it appears that when you start Vaadin, it tries to access some class that you've created in your own artifact. With OSGi, that just won't work because Vaadin would have to be built to import your package. You'll have to find another way around it. One possibility might be to use a tool like PAX Construct to embed the Vaadin jar in your own bundle, causing them to be part of the same bundle and therefore use the same classloader.
Re: Vaadin + Virgo not working... [message #676680 is a reply to message #676668] Mon, 06 June 2011 06:15 Go to previous messageGo to next message
Glyn Normington is currently offline Glyn NormingtonFriend
Messages: 1222
Registered: July 2009
Senior Member
Does this FAQ help? You can use the technique to import your application's packages into Vaadin.
Re: Vaadin + Virgo not working... [message #676695 is a reply to message #676680] Mon, 06 June 2011 08:18 Go to previous messageGo to next message
Frieder Heugel is currently offline Frieder HeugelFriend
Messages: 61
Registered: October 2010
Location: Basel, CH
Member
Glyn Normington wrote on Mon, 06 June 2011 08:15
Does this FAQ help? You can use the technique to import your application's packages into Vaadin.


Hi Glyn,

doesn't that lead to a cyclic dependency? The WAB imports Vaadin packages and at the same time the Vaadin fragment is going to import the WAP packages into the Vaadin bundle. Maybe I'm missing something here but I thought that's not possible.

One thing I've tried yesterday evening after I've read Arnold's post is to make the WAB (the one Arnold has provided in the Vaadin forum) a fragment of Vaadin but that didn't work. I have to admit I didn't check the spec but from the behaviour I've seen in Virgo I think that's not possible is it?

Another thing I wanted to try today is the following. Specify a custom classloader in the WAB and make this CL available via OSGi services. Then create a fragment (host is the Vaadin bundle) with a class that has the same name as the custom classloader specified in the web.xml (that's what the Vaadin bundle is looking for). This class then has the responsibility to get the custom classloader of the WAB via an OSGi service reference. I didn't try this approach yet but that's the only scenario I can come up with at the moment. If there is a better/easier approach for this I'm eager to hear it.

Regards
Frieder
Re: Vaadin + Virgo not working... [message #676709 is a reply to message #676451] Mon, 06 June 2011 09:12 Go to previous messageGo to next message
Glyn Normington is currently offline Glyn NormingtonFriend
Messages: 1222
Registered: July 2009
Senior Member
Hi Frieder

Cyclic dependencies are ok in OSGi. Usually they are a problem for build, but since a host bundle does not depend on its fragment, fragments break the cycle in this situation at build time.

Regards,
Glyn
Re: Vaadin + Virgo not working... [message #676791 is a reply to message #676709] Mon, 06 June 2011 14:32 Go to previous messageGo to next message
Arnold Schrijver is currently offline Arnold SchrijverFriend
Messages: 6
Registered: June 2011
Junior Member
Thank you all for your responses!

@Ryan: I am not that familiar with OSGi, but I am learning Wink Virgo seems really interesting to me. Today I bought the boek Spring DM in Action (bit out of date, but still a lot of useful info). I thought Plan's would be usable (i.e. to create a Synthetic Context where Vaadin bundle can see my exported packages), but didn't get it to work.

@Frieder and Glyn: Nice FAQ...didn't know about the shell commands. Useful! I'll experiment with creating a Fragment. Frieders' CL solution sounds promising as well.

Also I found an OSGi AddOn for Vaadin and a couple of really interesting blog articles. All solutions are based on Equinox Plugin projects, so project sources need to be ported to Virgo. I would like to have a pure Maven/Bundlor project setup.

URL's are:

Re: Vaadin + Virgo not working... [message #676794 is a reply to message #676791] Mon, 06 June 2011 14:46 Go to previous messageGo to next message
Glyn Normington is currently offline Glyn NormingtonFriend
Messages: 1222
Registered: July 2009
Senior Member
Hi Arnold

Synthetic contexts only help if the library bundle, Vaadin in this case, uses the thread context class loader.

Glad you liked the FAQ - it's only a week old!

Regards,
Glyn
Re: Vaadin + Virgo not working... [message #681970 is a reply to message #676709] Fri, 10 June 2011 07:06 Go to previous message
Frieder Heugel is currently offline Frieder HeugelFriend
Messages: 61
Registered: October 2010
Location: Basel, CH
Member
Glyn Normington wrote on Mon, 06 June 2011 11:12
Hi Frieder

Cyclic dependencies are ok in OSGi. Usually they are a problem for build, but since a host bundle does not depend on its fragment, fragments break the cycle in this situation at build time.

Regards,
Glyn


Hi Glyn,

thank you for the clarification. Looks like I confused the issue.

Bye
Frieder
Previous Topic:Importing packages into a 3rd party bundle: Virgo doesn't pick up my fragment bundle?
Next Topic:Best practices getting started with OSGi development and Virgo?
Goto Forum:
  


Current Time: Thu Apr 18 15:58:46 GMT 2024

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

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

Back to the top