Announcement Announcement Module
Collapse
No announcement yet.
Deploying a PAR application Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Deploying a PAR application

    Hi,

    I'm trying to create a PoC on S2AP and the PAR format.

    My application uses Spring MVC, SpringModules Validation framework, Apache Commons Validator framework and Apache Tiles framework. My PAR application has 3 modules - Domain, Service and WebModule.

    I also have a set of classes extending from various Spring framework classes. I call them collectively 'SpringExtension' (I'm trying to give it a nice shape on SF.net, but I have only 12 classes in my 'org.springextension' right now ).

    I have procured (from S2AP Enterprise Repository) OSGi compatible bundles for several of my dependencies (including some of those listed above). For others (like SpringModules Validation framework and my humble SpringExtension framework), I have created OSGi compatible bundles.

    I checked the bundles one-by-one (as per their inter-dependencies) by putting them in 'pickup' folder. All the bundles get deployed successfully.

    I have a class in this library (SpringExtension) which extends class 'org.springframework.web.servlet.handler.AbstractD etectingUrlHandlerMapping' from Spring MVC. This is where the problem is, or at least the problem starts from here.

    Naturally, the web-module of my PAR project depends upon this class (and others from SpringExtension). The Manifest of my WebModule is:

    ...
    Import-Library: org.springframework.spring;version="[2.5.4,3.0.0)",
    org.springextension,
    org.apache.tiles
    Import-Bundle: com.springsource.javax.servlet;version="2.5.0",
    com.springsource.org.apache.taglibs.standard;versi on="1.1.2",
    com.capgemini.org.springmodules.validation;version ="0.9.0"
    Import-Package: com.acme.crud.domain,
    com.acme.crud.services.bo,
    com.acme.crud.services.exception,
    com.acme.crud.services.util
    ...

    In the above listing, 'com.acme' is the root of my PoC application package.

    When deploying the PAR application, I get the following error:

    <Please see my next message>

    The interesting thing is the last (root) cause: It is not able to find class 'org.springframework.web.servlet.handler.AbstractD etectingUrlHandlerMapping'.

    The Manifest of SpringExtension's webmvc module is:

    ...
    Import-Library: org.springframework.spring
    Import-Bundle: com.springsource.javax.servlet,
    com.capgemini.org.springextension.beans,
    com.capgemini.org.springextension.context
    ...

    So, I'm adding the Spring library, which includes Spring MVC as well.

    There are no errors reported by SpringIDE or S2AP-TS at compile-time.

    I think I'm getting desperate now. Could you please look into the matter?

    One last thing - The SpringExtension library (and bundles) are in 'usr' directory under relevant repository sections, whereas the Spring library and Spring MVC bundle are in 'ext' directory. I don't know if this should pose a problem.

    I would have loved to attach relevant files, if that were an option in these discussions. Since it is not possible, I had to paste entire stack-trace etc. here. I hope it's not too inconvenient.

    Thanks a ton!

    Best regards,

    - Aditya Jha

  • #2
    Deploying a PAR application

    [2008-08-22 15:21:07.406] platform-dm-7 atform.web.dm.PlatformOsgiBundleXmlWebApplicationC ontext.unknown E Post refresh error
    org.springframework.beans.factory.CannotLoadBeanCl assException: Error loading class [org.springextension.web.servlet.handler.BeanIdHand lerMapping] for bean with name 'handlerMapping' defined in URL [bundleentry://89/META-INF/spring/dispatcher-servlet.xml]: problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org.springextension.web.servlet.handler.BeanIdHand lerMapping not found from bundle [CRUD WebModule Bundle (CRUD_PAR-1-CRUD_WebModule)]
    at org.springframework.beans.factory.support.Abstract BeanFactory.resolveBeanClass(AbstractBeanFactory.j ava:1141)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.predictBeanType(Abstrac tAutowireCapableBeanFactory.java:524)
    at org.springframework.beans.factory.support.Abstract BeanFactory.isFactoryBean(AbstractBeanFactory.java :1174)
    at org.springframework.beans.factory.support.Abstract BeanFactory.isFactoryBean(AbstractBeanFactory.java :754)
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:422)
    at org.springframework.context.support.AbstractApplic ationContext.finishBeanFactoryInitialization(Abstr actApplicationContext.java:729)
    at org.springframework.osgi.context.support.AbstractD elegatedExecutionApplicationContext.completeRefres h(AbstractDelegatedExecutionApplicationContext.jav a:276)
    at org.springframework.osgi.extender.internal.depende ncies.startup.DependencyWaiterApplicationContextEx ecutor$CompleteRefreshTask.run(DependencyWaiterApp licationContextExecutor.java:145)
    at com.springsource.platform.kernel.dm.ContextPropaga tingTaskExecutor$2.run(ContextPropagatingTaskExecu tor.java:82)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run Task(ThreadPoolExecutor.java:885)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:907)
    at java.lang.Thread.run(Thread.java:619)
    Caused by: java.lang.NoClassDefFoundError: org.springextension.web.servlet.handler.BeanIdHand lerMapping not found from bundle [CRUD WebModule Bundle (CRUD_PAR-1-CRUD_WebModule)]
    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 org.springframework.util.ClassUtils.forName(ClassU tils.java:242)
    at org.springframework.beans.factory.support.Abstract BeanDefinition.resolveBeanClass(AbstractBeanDefini tion.java:383)
    at org.springframework.beans.factory.support.Abstract BeanFactory.resolveBeanClass(AbstractBeanFactory.j ava:1135)
    ... 11 more
    Caused by: com.springsource.platform.osgi.framework.PlatformN oClassDefFoundError: org/springframework/web/servlet/handler/AbstractDetectingUrlHandlerMapping in PlatformBundleClassLoader: [bundle=com.capgemini.org.springextension.webmvc_0. 1.0] in PlatformBundleClassLoader: [bundle=CRUD_PAR-1-CRUD_WebModule_1.0.0]
    at com.springsource.platform.osgi.framework.equinox.P latformBundleClassLoader.loadClass(PlatformBundleC lassLoader.java:138)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:2 51)
    at org.eclipse.osgi.framework.internal.core.BundleLoa der.loadClass(BundleLoader.java:313)
    at org.eclipse.osgi.framework.internal.core.BundleHos t.loadClass(BundleHost.java:227)
    at org.eclipse.osgi.framework.internal.core.AbstractB undle.loadClass(AbstractBundle.java:1274)
    at org.springframework.osgi.util.BundleDelegatingClas sLoader.findClass(BundleDelegatingClassLoader.java :99)
    ... 16 more

    Comment


    • #3
      Deploying a PAR application

      Caused by: com.springsource.platform.osgi.framework.PlatformN oClassDefFoundError: org/springframework/web/servlet/handler/AbstractDetectingUrlHandlerMapping in PlatformBundleClassLoader: [bundle=com.capgemini.org.springextension.webmvc_0. 1.0]
      at com.springsource.platform.osgi.framework.equinox.P latformBundleClassLoader.defineClass(PlatformBundl eClassLoader.java:316)
      at org.eclipse.osgi.baseadaptor.loader.ClasspathManag er.defineClass(ClasspathManager.java:554)
      at org.eclipse.osgi.baseadaptor.loader.ClasspathManag er.findClassImpl(ClasspathManager.java:524)
      at org.eclipse.osgi.baseadaptor.loader.ClasspathManag er.findLocalClassImpl(ClasspathManager.java:455)
      at org.eclipse.osgi.baseadaptor.loader.ClasspathManag er.findLocalClass_LockClassLoader(ClasspathManager .java:443)
      at org.eclipse.osgi.baseadaptor.loader.ClasspathManag er.findLocalClass(ClasspathManager.java:423)
      at org.eclipse.osgi.internal.baseadaptor.DefaultClass Loader.findLocalClass(DefaultClassLoader.java:193)
      at org.eclipse.osgi.framework.internal.core.BundleLoa der.findLocalClass(BundleLoader.java:368)
      at org.eclipse.osgi.framework.internal.core.SingleSou rcePackage.loadClass(SingleSourcePackage.java:33)
      at org.eclipse.osgi.framework.internal.core.BundleLoa der.findClassInternal(BundleLoader.java:432)
      at org.eclipse.osgi.framework.internal.core.BundleLoa der.findClass(BundleLoader.java:397)
      at org.eclipse.osgi.framework.internal.core.BundleLoa der.findClass(BundleLoader.java:385)
      at org.eclipse.osgi.internal.baseadaptor.DefaultClass Loader.loadClass(DefaultClassLoader.java:87)
      at com.springsource.platform.osgi.framework.equinox.P latformBundleClassLoader.loadClass(PlatformBundleC lassLoader.java:134)
      ... 21 more
      Caused by: java.lang.NoClassDefFoundError: org/springframework/web/servlet/handler/AbstractDetectingUrlHandlerMapping
      at java.lang.ClassLoader.defineClass1(Native Method)
      at java.lang.ClassLoader.defineClass(ClassLoader.java :620)
      at org.eclipse.osgi.internal.baseadaptor.DefaultClass Loader.defineClass(DefaultClassLoader.java:165)
      at com.springsource.platform.osgi.framework.equinox.P latformBundleClassLoader.defineClass(PlatformBundl eClassLoader.java:314)
      ... 34 more
      Caused by: com.springsource.platform.osgi.framework.PlatformC lassNotFoundException: org.springframework.web.servlet.handler.AbstractDe tectingUrlHandlerMapping in PlatformBundleClassLoader: [bundle=com.capgemini.org.springextension.webmvc_0. 1.0]
      at com.springsource.platform.osgi.framework.equinox.P latformBundleClassLoader.loadClass(PlatformBundleC lassLoader.java:136)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:2 51)
      at java.lang.ClassLoader.loadClassInternal(ClassLoade r.java:319)
      ... 38 more
      Caused by: java.lang.ClassNotFoundException: org.springframework.web.servlet.handler.AbstractDe tectingUrlHandlerMapping
      at org.eclipse.osgi.framework.internal.core.BundleLoa der.findClassInternal(BundleLoader.java:481)
      at org.eclipse.osgi.framework.internal.core.BundleLoa der.findClass(BundleLoader.java:397)
      at org.eclipse.osgi.framework.internal.core.BundleLoa der.findClass(BundleLoader.java:385)
      at org.eclipse.osgi.internal.baseadaptor.DefaultClass Loader.loadClass(DefaultClassLoader.java:87)
      at com.springsource.platform.osgi.framework.equinox.P latformBundleClassLoader.loadClass(PlatformBundleC lassLoader.java:134)
      ... 40 more

      Comment


      • #4
        Deploying a PAR application

        Hi,

        I think the problem here is due to the way that the Platform processes Import-Bundle and Import-Library headers. These headers are only expanded into the corresponding set of Import-Package entries during application deployment. No such expansion occurs for bundles that are placed directly in the repository, e.g. in repository/bundles/ext or repository/bundles/usr.

        I'd recommend deploying the com.capgemini.org.springextension.webmvc_0.1.0 bundle by copying it to the pickup directory, using the admin console, or associated it with your server in the tools and then deploying your application which depends upon it. This should mean that the com.capgemini.org.springextension.webmvc_0.1.0 bundle has its Import-Bundle and Import-Library headers expanded so it will be able to load the Spring MVC types and, as you deployed it before you application, your application will also be able to depend upon it.

        Regards,
        Andy

        Comment


        • #5
          Deploying a PAR application

          Wow!

          Great input. I was not aware of this at all.

          This would mean that Manifests of all of my custom (or 'usr') bundles would need to be modified to include only 'Import-Package' and no 'Import-Library' or 'Import-Bundle'.

          Is this how it is supposed to function? I mean, doesn't it make creating OSGi compliant bundles harder?

          On the other hand, I can understand the concept, as traditional OSGi standard allows only for Import-Package and not the other imports.

          May be I would add a 'New Feature' request in Spring IDE forum to have the facility of 'Exapnd Imports' on any bundle's Manifest. That would be a real help.

          I'll update my bundles anyway, and try with the updated ones. I'll make a noise in this forum again, if this doesn't solve the problem.

          Many thanks!

          Best regards,

          - Aditya Jha

          Comment

          Working...
          X