2010/6/22 Justin Edelson <[email protected]>

> On 6/22/10 10:06 AM, Bertrand Delacretaz wrote:
> > Hi Federico,
> >
> > On Tue, Jun 22, 2010 at 3:33 PM, Federico Paparoni
> > <[email protected]> wrote:
> >> I'm creating a new bundle to test a servlet that manage a new extension.
> >> I have dependency with iText and, obviously, when I try to deploy the
> bundle
> >> I receive this error in log
> >>
> >> ...(org.osgi.framework.BundleException: Unresolved constraint in bun
> >> dle david [64]: package; (package=com.itextpdf.text.pdf))
> >
> >> ... What are the best practises in that case? Where I have to put the
> dependency
> >> JAR?...
> >
> > Best is to find an OSGi bundle that exports the required iText
> > classes. Many Apache projects (like commons.a.o) now include the OSGi
> > metadata in their standard jars, so you can just load them as bundles.
> >
> > I don't know if that's the case for iText, searching "itext osgi
> > bundle" on google should help find out if such bundles are available.
> > Install the bundle (using OSGi console is the easiest for a quick
> > test) , and check the OSGi console to see if it exports the packages
> > that you need.
> FWIW, there is bundle for iText in the SpringSource bundle repository:
>
> http://www.springsource.com/repository/app/bundle/version/detail?name=com.springsource.com.lowagie.text&version=2.0.8
>
> Justin
>
> >
> > If you cannot find an iText bundle, you could "OSGify" an existing
> > iText jar using the bnd tool or the maven-bundle-plugin to add the
> > required MANIFEST.MF information to it.
> >
> > Last (and least optimal) solution is to embed the iText classes in
> > your bundle using the Embed-Dependency option of the
> > maven-bundle-plugin, see
> > http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html
> >
> > That last option might be the easiest for a quick test, the problem is
> > that it adds bloat to your bundle and if another bundle needs those
> > classes that would lead to duplication.
> >
> > Hope this helps,
> > -Bertrand
>
>
That's ok. Now I simply modify the pom using the worst method,
Embed-Dependency, and I receive no error.
Later I will create a bundle for iText (thanks Justin but I'm using a
different version).
I receive no error, but the Servlet isn't called for the extension .pdf.
The configuration of the servlet looks like this

/** Sling Servlet registered with PDF extensions
 *
 * @scr.component immediate="true" metatype="no"
 * @scr.service interface="javax.servlet.Servlet"
 *
 * @scr.property name="service.description" value="PDF Extension Servlet"
 * @scr.property name="service.vendor" value="David Mini CMS"
 *
 * @scr.property name="sling.servlet.resourceTypes"
 *               value="sling/servlet/default"
 *
 * @scr.property name="sling.servlet.extensions"
 *               value = "pdf"
 */

The servlet extends SlingAllMethodsServlet and in the doGet method I create
a simple pdf rappresentation of the node. But when I call in the browser I
see this error

0 (2010-06-22 16:57:55) LOG Method=GET, PathInfo=/content/david/_your_title_.pdf
0 (2010-06-22 16:57:55) TIMER_START{ResourceResolution}
0 (2010-06-22 16:57:55) TIMER_END{0,ResourceResolution}
URI=/content/david/_your_title_.pdf resolves to
Resource=JcrNodeResource, type=david, superType=null,
path=/content/david/_your_title_
0 (2010-06-22 16:57:55) LOG Resource Path Info: SlingRequestPathInfo:
path='/content/david/_your_title_', selectorString='null',
extension='pdf', suffix='null'
0 (2010-06-22 16:57:55) TIMER_START{ServletResolution}
0 (2010-06-22 16:57:55) TIMER_START{resolveServlet(JcrNodeResource,
type=david, superType=null, path=/content/david/_your_title_)}
0 (2010-06-22 16:57:55) TIMER_END{0,resolveServlet(JcrNodeResource,
type=david, superType=null, path=/content/david/_your_title_)} Using
servlet org.apache.sling.servlets.get.DefaultGetServlet
0 (2010-06-22 16:57:55) TIMER_END{0,ServletResolution}
URI=/content/david/_your_title_.pdf handled by
Servlet=org.apache.sling.servlets.get.DefaultGetServlet
0 (2010-06-22 16:57:55) LOG Applying request filters
0 (2010-06-22 16:57:55) LOG Calling filter:
org.apache.sling.engine.impl.debug.RequestProgressTrackerLogFilter
0 (2010-06-22 16:57:55)
TIMER_START{org.apache.sling.servlets.get.DefaultGetServlet#0}
0 (2010-06-22 16:57:55) LOG No renderer for extension pdf
0 (2010-06-22 16:57:55) TIMER_START{handleError:status=404}

Am I missing something to correctly handle the request?


-- 
Federico

Reply via email to