Announcement Announcement Module
Collapse
No announcement yet.
NoClassDefFoundError on OsgiBundleXmlWebApplicationContext Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • NoClassDefFoundError on OsgiBundleXmlWebApplicationContext

    I have a web.xml that uses Spring DM's Spring-MVC Integration as described here:

    http://static.springframework.org/osgi/docs/1.1.0-m2/reference/html/web.html#web:spring-mvc

    To resolve OsgiBundleXmlWebApplicationContext, I have the following in my MANIFEST.MF.

    Import-Package: org.springframework.osgi.web.context.support

    I'm using S2AP Beta 2 and I have spring-osgi-web-1.1.0-m2.jar installed in repository/bundles/usr. I telneted to localhost 2401 and verified it's running:

    70 ACTIVE org.springframework.bundle.osgi.web_1.1.0.m2

    However, I still get the following error in my application:

    java.lang.NoClassDefFoundError: org.springframework.osgi.web.context.support.OsgiB undleXmlWebApplicationContext not found from bundle [Simple OSGi War (myapp)]
    at org.springframework.osgi.util.BundleDelegatingClas sLoader.findClass(BundleDelegatingClassLoader.java :112)
    at org.springframework.osgi.util.BundleDelegatingClas sLoader.loadClass(BundleDelegatingClassLoader.java :156)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:2 51)
    at com.springsource.platform.servlet.tomcat.loader.Os giWebappClassLoader.loadClass(OsgiWebappClassLoade r.java:476)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:2 51)
    at org.springframework.util.ClassUtils.forName(ClassU tils.java:249)
    at org.springframework.util.ClassUtils.forName(ClassU tils.java:202)
    at org.springframework.web.context.ContextLoader.dete rmineContextClass(ContextLoader.java:273)
    at org.springframework.web.context.ContextLoader.crea teWebApplicationContext(ContextLoader.java:243)
    at org.springframework.web.context.ContextLoader.init WebApplicationContext(ContextLoader.java:199)
    at org.springframework.web.context.ContextLoaderListe ner.contextInitialized(ContextLoaderListener.java: 45)
    at org.apache.catalina.core.StandardContext.listenerS tart(StandardContext.java:3843)
    at org.apache.catalina.core.StandardContext.start(Sta ndardContext.java:4350)
    at org.apache.catalina.core.ContainerBase.addChildInt ernal(ContainerBase.java:791)
    at org.apache.catalina.core.ContainerBase.addChild(Co ntainerBase.java:771)
    at org.apache.catalina.core.StandardHost.addChild(Sta ndardHost.java:525)
    at com.springsource.platform.servlet.tomcat.TomcatSer vletContainer.addContext(TomcatServletContainer.ja va:571)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.springframework.osgi.service.importer.internal .aop.ServiceInvoker.doInvoke(ServiceInvoker.java:5 9)
    at org.springframework.osgi.service.importer.internal .aop.ServiceInvoker.invoke(ServiceInvoker.java:67)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :171)
    at org.springframework.aop.support.DelegatingIntroduc tionInterceptor.doProceed(DelegatingIntroductionIn terceptor.java:131)
    at org.springframework.aop.support.DelegatingIntroduc tionInterceptor.invoke(DelegatingIntroductionInter ceptor.java:119)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :171)
    at org.springframework.osgi.service.importer.support. LocalBundleContextAdvice.invoke(LocalBundleContext Advice.java:59)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :171)
    at org.springframework.aop.support.DelegatingIntroduc tionInterceptor.doProceed(DelegatingIntroductionIn terceptor.java:131)
    at org.springframework.aop.support.DelegatingIntroduc tionInterceptor.invoke(DelegatingIntroductionInter ceptor.java:119)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :171)
    at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:204)
    at $Proxy74.addContext(Unknown Source)

    Any ideas?

    Thanks,

    Matt

  • #2
    NoClassDefFoundError on OsgiBundleXmlWebApplicationContext

    Hi Matt,

    You should use PlatformOsgiBundleXmlWebApplicationContext instead.

    It was explained a bit in of threads here.

    Olex

    Comment


    • #3
      NoClassDefFoundError on OsgiBundleXmlWebApplicationContext

      I tried changing to PlatformOsgiBundleXmlWebApplicationContext and now I'm getting:

      [2008-05-16 10:30:10.278] async-delivery-thread-1 inerBase.[SpringSource-AP.catalina].[localhost].[/myapp].unknown E Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListe ner
      java.lang.IllegalArgumentException: interface org.springframework.beans.factory.xml.NamespaceHan dlerResolver is not visible from class loader
      at java.lang.reflect.Proxy.getProxyClass(Proxy.java:3 53)
      at java.lang.reflect.Proxy.newProxyInstance(Proxy.jav a:581)
      at org.springframework.aop.framework.JdkDynamicAopPro xy.getProxy(JdkDynamicAopProxy.java:117)
      at org.springframework.aop.framework.ProxyFactory.get Proxy(ProxyFactory.java:110)
      at org.springframework.osgi.context.support.TrackingU til.getService(TrackingUtil.java:127)
      at org.springframework.osgi.context.support.OsgiBundl eXmlApplicationContext.lookupNamespaceHandlerResol ver(OsgiBundleXmlApplicationContext.java:260)
      at org.springframework.osgi.context.support.OsgiBundl eXmlApplicationContext.createNamespaceHandlerResol ver(OsgiBundleXmlApplicationContext.java:214)
      at org.springframework.osgi.context.support.OsgiBundl eXmlApplicationContext.loadBeanDefinitions(OsgiBun dleXmlApplicationContext.java:129)
      at org.springframework.context.support.AbstractRefres hableApplicationContext.refreshBeanFactory(Abstrac tRefreshableApplicationContext.java:123)
      at org.springframework.context.support.AbstractApplic ationContext.obtainFreshBeanFactory(AbstractApplic ationContext.java:423)
      at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:353)
      at org.springframework.osgi.context.support.AbstractD elegatedExecutionApplicationContext.normalRefresh( AbstractDelegatedExecutionApplicationContext.java: 143)
      at org.springframework.osgi.context.support.AbstractD elegatedExecutionApplicationContext$NoDependencies WaitRefreshExecutor.refresh(AbstractDelegatedExecu tionApplicationContext.java:70)
      at org.springframework.osgi.context.support.AbstractD elegatedExecutionApplicationContext.refresh(Abstra ctDelegatedExecutionApplicationContext.java:131)
      at org.springframework.web.context.ContextLoader.crea teWebApplicationContext(ContextLoader.java:255)
      at org.springframework.web.context.ContextLoader.init WebApplicationContext(ContextLoader.java:199)
      at org.springframework.web.context.ContextLoaderListe ner.contextInitialized(ContextLoaderListener.java: 45)

      I tried adding a namespace init-param to my DispatcherServlet, but that didn't help.

      Thanks,

      Matt

      Comment


      • #4
        NoClassDefFoundError on OsgiBundleXmlWebApplicationContext

        Hi Matt,

        We're going to need a bit more information to help you debug this one...

        - Are you trying to develop a Shared Services WAR or a Web Module?
        - What does your MANIFEST.MF look like, and under which path are you packaging it?
        - What does your web.xml look like?

        regards,

        Sam

        Comment


        • #5
          NoClassDefFoundError on OsgiBundleXmlWebApplicationContext

          It's a WAR and described in the following blog post:

          http://raibledesigns.com/rd/entry/running_spring_mvc_web_applications

          Basically, I'd like to try to get it working in S2AP w/o using any of SpringSource's extensions to OSGi.

          Thanks,

          Matt

          Comment


          • #6
            NoClassDefFoundError on OsgiBundleXmlWebApplicationContext

            Hi Matt,

            I tried to answer your question on your blog, but I unfortunately got an error message stating that my comment has been marked as spam, since it's over 2000 characters. So, I'll post my answer here as well.

            The tool for converting Import-Bundle and Import-Library to Import-Package statements that Adrian and Rob mentioned does not yet exist; however, I'll share a perhaps little know tip with you...

            If you create a bundle using Import-Bundle or Import-Library, you can view the Platform's trace (i.e., PLATFORM_HOME/serviceability/trace/trace.log) and see exactly how those manifest headers get translated into standard OSGi Import-Package statements. Just search for "transformed from:", and just after that you'll find a "to:" with the transformed manifest immediately following.

            Regarding how to get your sample web application to run on the Platform without any SpringSource specific manifest headers: As Adrian mentioned on your blog, it's rather trivial to convert your web-app to run using Import-Bundle and Import-Library. So, to get it to run on the SpringSource Application Platform using only Import-Package, simply follow the steps Adrian mentioned on your blog, but use the following manifest instead:

            * The manifest is apparently too long for this forum as well. So I'll post it in a follow-up comment.

            Then delete the following, as they are not necessary for deploying WARs or Web Modules on the S2AP:

            Spring-DM-Version: 1.1.0-m2-SNAPSHOT
            Spring-Version: 2.5.2
            Bundle-Classpath: .,WEB-INF/classes,WEB-INF/lib/sitemesh-2.3.jar,WEB-INF/lib/urlrewritefilter-3.0.4.jar

            And in web.xml, use PlatformOsgiBundleXmlWebApplicationContext instead of OsgiBundleXmlWebApplicationContext as the 'contextClass' context-param for Spring MVC's ContextLoaderListener. For example:

            <param-value>com.springsource.platform.web.dm.PlatformOsg iBundleXmlWebApplicationContext</param-value>

            I hope this gets you up and running with your Freemarker web-app on the S2AP!

            Best regards,

            Sam

            Comment


            • #7
              NoClassDefFoundError on OsgiBundleXmlWebApplicationContext

              * manifest from previous comment:

              Manifest-Version: 1
              Bundle-ManifestVersion: 2
              Bundle-Name: Simple OSGi War
              Bundle-SymbolicName: myapp
              Import-Package: javax.servlet,
              javax.servlet.http,
              javax.servlet.resources,
              javax.swing.tree,
              javax.naming,
              org.w3c.dom,
              org.apache.commons.logging,
              javax.xml.parsers;resolution:=optional,
              org.xml.sax;resolution:=optional,org.xml.sax.helpe rs;resolution:=optional,
              org.springframework.beans;version="[2.5.2,3.0.0)",
              org.springframework.beans.factory;version="[2.5.2,3.0.0)",
              org.springframework.beans.factory.config;version="[2.5.2,3.0.0)",
              org.springframework.beans.factory.support;version= "[2.5.2,3.0.0)",
              org.springframework.beans.factory.xml;version="[2.5.2,3.0.0)",
              org.springframework.context;version="[2.5.2,3.0.0)",
              org.springframework.context.event;version="[2.5.2,3.0.0)",
              org.springframework.context.support;version="[2.5.2,3.0.0)",
              org.springframework.core;version="[2.5.2,3.0.0)",
              org.springframework.core.enums;version="[2.5.2,3.0.0)",
              org.springframework.core.io;version="[2.5.2,3.0.0)",
              org.springframework.core.io.support;version="[2.5.2,3.0.0)",
              org.springframework.core.style;version="[2.5.2,3.0.0)",
              org.springframework.core.task;version="[2.5.2,3.0.0)",
              org.springframework.osgi;version="[1.1.0,2.0.0)",
              org.springframework.osgi.context;version="[1.1.0,2.0.0)",
              org.springframework.osgi.context.event;version="[1.1.0,2.0.0)",
              org.springframework.osgi.context.support;version="[1.1.0,2.0.0)",
              org.springframework.osgi.extender;version="[1.1.0,2.0.0)",
              org.springframework.osgi.extender.support;version= "[1.1.0,2.0.0)",
              org.springframework.osgi.io;version="[1.1.0,2.0.0)",
              org.springframework.osgi.service.exporter;version= "[1.1.0,2.0.0)",
              org.springframework.osgi.service.importer.support; version="[1.1.0,2.0.0)",
              org.springframework.osgi.util;version="[1.1.0,2.0.0)",
              org.springframework.stereotype;version="[2.5.2,3.0.0)",
              org.springframework.ui;version="[2.5.2,3.0.0)",
              org.springframework.ui.context;version="[2.5.2,3.0.0)",
              org.springframework.ui.context.support;version="[2.5.2,3.0.0)",
              org.springframework.util;version="[2.5.2,3.0.0)",
              org.springframework.web;version="[2.5.2,3.0.0)",
              org.springframework.web.bind;version="[2.5.2,3.0.0)",
              org.springframework.web.bind.annotation;version="[2.5.2,3.0.0)",
              org.springframework.web.bind.annotation.support;ve rsion="[2.5.2,3.0.0)",
              org.springframework.web.bind.support;version="[2.5.2,3.0.0)",
              org.springframework.web.context;version="[2.5.2,3.0.0)",
              org.springframework.web.context.request;version="[2.5.2,3.0.0)",
              org.springframework.web.context.support;version="[2.5.2,3.0.0)",
              org.springframework.web.filter;version="[2.5.2,3.0.0)",
              org.springframework.web.multipart;version="[2.5.2,3.0.0)",
              org.springframework.web.multipart.commons;version= "[2.5.2,3.0.0)",
              org.springframework.web.multipart.support;version= "[2.5.2,3.0.0)",
              org.springframework.web.servlet;version="[2.5.2,3.0.0)",
              org.springframework.web.servlet.handler;version="[2.5.2,3.0.0)",
              org.springframework.web.servlet.handler.metadata;v ersion="[2.5.2,3.0.0)",
              org.springframework.web.servlet.i18n;version="[2.5.2,3.0.0)",
              org.springframework.web.servlet.mvc;version="[2.5.2,3.0.0)",
              org.springframework.web.servlet.mvc.annotation;ver sion="[2.5.2,3.0.0)",
              org.springframework.web.servlet.mvc.multiaction;ve rsion="[2.5.2,3.0.0)",
              org.springframework.web.servlet.mvc.support;versio n="[2.5.2,3.0.0)",
              org.springframework.web.servlet.mvc.throwaway;vers ion="[2.5.2,3.0.0)",
              org.springframework.web.servlet.support;version="[2.5.2,3.0.0)",
              org.springframework.web.servlet.tags;version="[2.5.2,3.0.0)",
              org.springframework.web.servlet.tags.form;version= "[2.5.2,3.0.0)",
              org.springframework.web.servlet.theme;version="[2.5.2,3.0.0)",
              org.springframework.web.servlet.view;version="[2.5.2,3.0.0)",
              org.springframework.web.servlet.view.document;vers ion="[2.5.2,3.0.0)",
              org.springframework.web.servlet.view.freemarker;ve rsion="[2.5.2,3.0.0)",
              org.springframework.web.servlet.view.jasperreports ;version="[2.5.2,3.0.0)",
              org.springframework.web.servlet.view.tiles2;versio n="[2.5.2,3.0.0)",
              org.springframework.web.servlet.view.velocity;vers ion="[2.5.2,3.0.0)",
              org.springframework.web.servlet.view.xslt;version= "[2.5.2,3.0.0)",
              org.springframework.web.util;version="[2.5.2,3.0.0)",
              freemarker.cache,freemarker.core,freemarker.templa te,freemarker.ext.servlet

              Regards,

              Sam

              Comment


              • #8
                NoClassDefFoundError on OsgiBundleXmlWebApplicationContext

                Sam,

                After changing my manifest to match your suggestion (and leaving Spring-DM-Version, Spring-Version and Bundle-Classpath intact), I was able to get my Spring MVC + FreeMarker application running on S2AP. However, using the same MANIFEST.MF (which contains no proprietary S2AP extensions), I was unable to get it running under Equinox. This leads me to believe that there's some trickery going on in S2AP that doesn't exist in standard OSGi containers.

                I'd love to get this app work in Equinox to prove that Spring MVC + FreeMarker is a usable option in OSGi (and not just in S2AP).

                Thanks,

                Matt

                Comment

                Working...
                X