Re: OSGi Bundle for FreeMarker?

mraible <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>


Attila Szegedi-3 wrote:
> 
> No...
> 
> Come to think of it, that's something I'd like to see exist --  
> actually, if I understand it correctly, it'd be possible to modify  
> freemarker.jar non-intrusively so it automatically acts as an OSGi  
> bundle if we added the OSGi versioning and dependency attributes to  
> its manifest, right?
> 
> Sounds like something that'd be easy to do, wouldn't upset anything,  
> and would provide value for the (hopefully increasing) part of user  
> base that's composing their systems using OSGi.
> 
> Of course, we could only provide dependency information for those  
> dependencies that are themselves OSGi aware (also, note that all of  
> FreeMarker's dependencies are optional).
> 
> Attila.
> 
> On 2008.04.21., at 5:15, mraible wrote:
> 
>>
>> Does anyone have an OSGi bundle for FreeMarker?
>>
>> Thanks,
>>
>> Matt
> 

You are correct in that adding it should be non-intrusive. I used the bnd
tool[1] to create one from inspecting the JAR. Here's what it came up with:

Manifest-Version: 1.0
Specification-Title: FreeMarker
Created-By: 1.5.0_13 (Apple Inc.)
Import-Package: com.sun.org.apache.xml.internal.utils;resolution:=opti
 onal,com.sun.org.apache.xpath.internal;resolution:=optional,com.sun.o
 rg.apache.xpath.internal.objects;resolution:=optional,freemarker;reso
 lution:=optional,freemarker.cache;resolution:=optional,freemarker.cor
 e;resolution:=optional,freemarker.debug;resolution:=optional,freemark
 er.debug.impl;resolution:=optional,freemarker.ext.ant;resolution:=opt
 ional,freemarker.ext.beans;resolution:=optional,freemarker.ext.dom;re
 solution:=optional,freemarker.ext.jdom;resolution:=optional,freemarke
 r.ext.jsp;resolution:=optional,freemarker.ext.jython;resolution:=opti
 onal,freemarker.ext.rhino;resolution:=optional,freemarker.ext.servlet
 ;resolution:=optional,freemarker.ext.util;resolution:=optional,freema
 rker.ext.xml;resolution:=optional,freemarker.log;resolution:=optional
 ,freemarker.template;resolution:=optional,freemarker.template.utility
 ;resolution:=optional,javax.el;resolution:=optional,javax.servlet;res
 olution:=optional,javax.servlet.http;resolution:=optional,javax.servl
 et.jsp;resolution:=optional,javax.servlet.jsp.el;resolution:=optional
 ,javax.servlet.jsp.tagext;resolution:=optional,javax.swing;resolution
 :=optional,javax.swing.tree;resolution:=optional,javax.xml.parsers;re
 solution:=optional,javax.xml.transform;resolution:=optional,org.apach
 e.log;resolution:=optional,org.apache.log4j;resolution:=optional,org.
 apache.tools.ant;resolution:=optional,org.apache.tools.ant.taskdefs;r
 esolution:=optional,org.apache.xml.utils;resolution:=optional,org.apa
 che.xpath;resolution:=optional,org.apache.xpath.objects;resolution:=o
 ptional,org.dom4j;resolution:=optional,org.dom4j.tree;resolution:=opt
 ional,org.jaxen;resolution:=optional,org.jaxen.dom;resolution:=option
 al,org.jaxen.dom4j;resolution:=optional,org.jaxen.jdom;resolution:=op
 tional,org.jdom;resolution:=optional,org.jdom.input;resolution:=optio
 nal,org.jdom.output;resolution:=optional,org.mozilla.javascript;resol
 ution:=optional,org.python.core;resolution:=optional,org.python.util;
 resolution:=optional,org.w3c.dom;resolution:=optional,org.w3c.dom.tra
 versal;resolution:=optional,org.xml.sax;resolution:=optional,org.xml.
 sax.helpers;resolution:=optional
Specification-Version: 2.3.12
Bnd-LastModified: 1208751105269
Export-Package: freemarker.ext.jsp;uses:="javax.servlet.http,javax.ser
 vlet.jsp.tagext,freemarker.ext.util,freemarker.template,freemarker.co
 re,javax.servlet,javax.xml.parsers,org.xml.sax,javax.servlet.jsp.el,j
 avax.servlet.jsp,freemarker.ext.servlet,freemarker.log,freemarker.ext
 .beans,org.xml.sax.helpers,javax.el,freemarker.template.utility",free
 marker.cache;uses:="freemarker.template,freemarker.core,javax.servlet
 ,freemarker.log,freemarker.template.utility",freemarker.debug;uses:="
 freemarker.template,freemarker.debug.impl,freemarker.template.utility
 ",freemarker.ext.jdom;uses:="freemarker.template,org.jdom.input,org.j
 axen,org.jdom,org.jaxen.jdom,org.jdom.output,freemarker.template.util
 ity",freemarker.ext.util;uses:="freemarker.template",freemarker.debug
 .impl;uses:="freemarker.cache,javax.swing.tree,freemarker.debug,freem
 arker.ext.util,freemarker.log,freemarker.template,freemarker.core,fre
 emarker.template.utility",freemarker.ext.rhino;uses:="freemarker.temp
 late,freemarker.ext.beans,org.mozilla.javascript,freemarker.ext.util"
 ,freemarker.ext.servlet;uses:="javax.servlet.http,freemarker.ext.jsp,
 freemarker.cache,freemarker.ext.jython,freemarker.log,freemarker.temp
 late,javax.servlet,freemarker.template.utility",freemarker.log;uses:=
 "org.apache.log4j,org.apache.log,freemarker.template.utility",freemar
 ker.ext.jython;uses:="freemarker.ext.beans,freemarker.template,org.py
 thon.core,freemarker.ext.util,freemarker.template.utility",freemarker
 .template;uses:="freemarker.cache,javax.swing.tree,freemarker.debug.i
 mpl,org.w3c.dom,freemarker.ext.jython,freemarker.ext.beans,freemarker
 .core,freemarker.ext.dom,freemarker.template.utility",freemarker.ext.
 beans;uses:="freemarker.ext.util,freemarker.log,freemarker.template,f
 reemarker.core,freemarker.template.utility",freemarker.core;uses:="fr
 eemarker.cache,javax.swing.tree,freemarker.debug.impl,freemarker.ext.
 jython,freemarker.log,freemarker.template,freemarker.ext.beans,javax.
 swing,freemarker.template.utility",freemarker,freemarker.ext.ant;uses
 :="org.python.util,org.apache.tools.ant.taskdefs,org.xml.sax,org.apac
 he.tools.ant,org.w3c.dom,freemarker.template,freemarker.core,javax.xm
 l.parsers,freemarker.ext.dom,freemarker.ext.xml,freemarker.template.u
 tility",freemarker.ext.dom;uses:="org.xml.sax,freemarker.cache,freema
 rker.ext.util,org.w3c.dom,com.sun.org.apache.xpath.internal.objects,j
 avax.xml.transform,freemarker.log,org.jaxen.dom,org.apache.xml.utils,
 org.w3c.dom.traversal,freemarker.template,freemarker.core,com.sun.org
 .apache.xml.internal.utils,org.jaxen,org.apache.xpath.objects,javax.x
 ml.parsers,com.sun.org.apache.xpath.internal,org.apache.xpath,freemar
 ker.template.utility",freemarker.template.utility;uses:="org.python.u
 til,org.python.core,org.w3c.dom,freemarker.ext.util,freemarker.log,fr
 eemarker.template,freemarker.ext.beans,freemarker.core",freemarker.ex
 t.xml;uses:="org.w3c.dom,org.jdom,freemarker.log,org.dom4j.tree,org.j
 axen.dom,freemarker.template,org.dom4j,org.jaxen.dom4j,org.jaxen,org.
 jdom.output,org.jaxen.jdom,freemarker.template.utility"
Bundle-Version: 0
Ant-Version: Apache Ant 1.6.5
Originally-Created-By: 1.5.0_14-b03 (Sun Microsystems Inc.)
Bundle-ManifestVersion: 2
Main-Class: freemarker.core.CommandLine
Bundle-SymbolicName: freemarker-2.3.12
Implementation-Title: VSS Java FreeMarker
Tool: Bnd-0.0.249
Specification-Vendor: Visigoth Software Society
Extension-name: FreeMarker
Implementation-Version: 2.3.12
Implementation-Vendor: Visigoth Software Society

However, even after adding this and installing FreeMarker as a bundle, I
still get the following error when using Spring Modules 1.1.0-m2 and Spring
MVC 2.5.2.

org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'freemarkerConfig' defined in ServletContext resource
[/WEB-INF/myapp-servlet.xml]: Instantiation of bean failed; nested exception
is java.lang.NoClassDefFoundError: freemarker/cache/TemplateLoader
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:851)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:807)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:437)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:404)
        at java.security.AccessController.doPrivileged(Native Method)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:375)

I don't believe this is a FreeMarker issue, but it might be if there's
something I have wrong in my manifest.

Thanks,

Matt

[1] http://www.aqute.biz/Code/Bnd

-- 
View this message in context: http://www.nabble.com/OSGi-Bundle-for-FreeMarker--tp16801750p16807920.html
Sent from the freemarker-user mailing list archive at Nabble.com.


-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.