Uploaded image for project: 'Spring OSGi'
  1. Spring OSGi
  2. OSGI-461

Spring MVC Bundle doesn't support FreeMarker

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Major
    • Resolution: Won't Fix
    • Affects Version/s: 1.1 M2
    • Fix Version/s: 1.1 M2
    • Component/s: WEB
    • Labels:
      None

      Description

      Spring MVC works with "freemarkerConfig" and "viewResolver" beans when Spring JARs are referenced from WEB-INF/lib. However, when they're referenced from bundles (using Import-Package), FreeMarker fails to load with the following error. I've created a bundle for FreeMarker using bnd, but the error still occurs.

      Caused by: java.lang.NoClassDefFoundError: freemarker/cache/TemplateLoader
      at java.lang.Class.getDeclaredConstructors0(Native Method)
      at java.lang.Class.privateGetDeclaredConstructors(Class.java:2357)
      at java.lang.Class.getConstructor0(Class.java:2671)
      at java.lang.Class.getDeclaredConstructor(Class.java:1953)
      at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:54)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:845)
      ... 34 more

        <bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
          <property name="templateLoaderPath" value="/"/>
          <property name="freemarkerSettings">
            <props>
              <prop key="datetime_format">MM/dd/yyyy</prop>
              <prop key="number_format">0.######</prop>
            </props>
          </property>
        </bean>
      
        <bean id="viewResolver" class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
          <property name="exposeSpringMacroHelpers" value="true"/>
          <property name="requestContextAttribute" value="rc"/>
          <property name="prefix" value="/"/>
          <property name="suffix" value=".ftl"/>
        </bean>
      

      MANIFEST.MF:

      Manifest-Version: 1
      Bundle-ManifestVersion: 2
      Spring-DM-Version: 1.1.0-m2-SNAPSHOT
      Spring-Version: 2.5.2
      Bundle-Name: Simple OSGi War
      Bundle-SymbolicName: jobs
      Bundle-Classpath: .,WEB-INF/classes,WEB-INF/lib/sitemesh-2.3.jar,WEB-INF/lib/urlrewritefilter-3.0.4.jar
      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.helpers;resolution:=optional,
      org.springframework.osgi.web.context.support,
      org.springframework.context.support,
      org.springframework.web.context,
      org.springframework.web.servlet,
      org.springframework.web.servlet.mvc,
      org.springframework.web.servlet.mvc.support,
      org.springframework.web.servlet.view,
      org.springframework.ui,
      org.springframework.web.servlet.view.freemarker,
      freemarker.cache

      I'll attach my FreeMarker bundle as well.

        Attachments

          Activity

            People

            • Assignee:
              costin Costin Leau
              Reporter:
              mraible Matt Raible
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: