History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: OSGI-461
Type: New Feature New Feature
Status: Closed Closed
Resolution: Won't Fix
Priority: Major Major
Assignee: Costin Leau
Reporter: Matt Raible
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Spring OSGi

Spring MVC Bundle doesn't support FreeMarker

Created: 23/Apr/08 01:44 PM   Updated: 24/Apr/08 03:09 AM
Component/s: WEB
Affects Version/s: 1.1 M2
Fix Version/s: 1.1 M2

Time Tracking:
Not Specified

File Attachments: 1. Java Archive File freemarker-2.3.12-bundle.jar (854 kb)



 Description  « Hide
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


{code}
  <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>
{code}

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.

 All   Comments   Work Log   Change History   FishEye   Related Builds      Sort Order: Ascending order - Click to sort in descending order
Costin Leau - 23/Apr/08 01:54 PM
Mark, can you please also attach your logs (please enable trace level in both Spring and Spring-DM, the oSgi platform if possible) in zip form? Thanks.

Matt Raible - 23/Apr/08 03:30 PM
How do I enable travel level logging in Spring, Spring-DM and Equinox? Is this something I can do from my project or do I have to modify the bundles?

Costin Leau - 23/Apr/08 03:42 PM
For Spring-DM (and Spring) see http://static.springframework.org/osgi/docs/1.0.2/reference/html/spring-osgi-faq.html#logging.
The group archive contains more information if you're interested.
As for the platform used, you have to check their docs - iirc, in Equinox there is a file that can be added to the config.ini and which (similar to log4j) enabled several categories.
There is no 'travel' logging but rather, each framework will log to the library plugged in - with Spring and Spring-DM you end up with the same output but with Equinox things will be different.

Matt Raible - 23/Apr/08 05:50 PM
You can close this issue. The problem was caused by not having org.springframework.web.context.support in the Import-Package statement. I soon as I added this, everything worked and logging messages started making sense. With this package present, FreeMarker works from WEB-INF/lib or as a bundle.

Thanks,

Matt

Costin Leau - 24/Apr/08 03:09 AM
Not a bug.