cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jos Snellings <>
Subject Cocoon 3: the three sisters as OSGi bundles?
Date Thu, 24 Jun 2010 11:32:12 GMT
Dear all,

Some weeks ago, I was coding a servlet in an OSGi context (apache 
In the process, of course, I wanted to use the triplet cocoon-pipeline, 
cocoon-sax, cocoon-xml, which as a result of the
design goals of Cocoon 3, can be used without further dependencies. A 
wise thing !

Of course, a first rough attempt is to just embed the jars in the 
bundle. This worked.
But now, I would like to take the thing an obvious step further: prepare 
OSGi bundles for the three sisters.

When I checked out the trunk again, I was pleasantly surprised to notice 
that ... cocoon-xml already is!
That means that I am not the only guy in the world thinking this would 
be a good idea.

I prepared bundles for the other two, but ... there is a class loading 
issue with cocoon-sax.
1. in spite of adding the xerces bundle to felix, inside the SAX2 
classes a class.forName("") gives a
   org.apache.cocoon.pipeline.ProcessingException: Cannot create and 
prepare an XMLReader.
   and this is because:
Caused by: java.lang.ClassNotFoundException: 
2.  On the other hand, inside 'my' bundle a code like:
XMLReader reader = new SAXParser();
             reader = null;
             String className = System.getProperty("org.xml.sax.driver");
             try {
                 reader = 
             catch (Exception e) {
                 System.err.println("No love...");

             URL here = new 

             URLConnection hc = here.openConnection();
             InputStream in = hc.getInputStream();

             ContentHandler contentHandler = new MyFavoriteContentHandler();

             InputSource input = new InputSource(in);
             try {
             catch (Exception e) {
                 System.err.println("Can't parse your file");

So, clearly there is a classloader confusion.
But the question is: is this the right way to go inside OSGi? Probably 
it would be better to ask the framework what parser
services it has available for us, and then use XMLParserActivator?
We could think about adding such a method to XMLUtils.

Of course I can take the embedded solution, but this is really a 
third-class solution. I really think there is an interest
to transform cocoon-sax into a genuine OSGi bundle.
I do not expect problems with cocoon-pipeline, being nicely insulated 
from the JAXP-loading issues.
Is there any interest in this group to dig into the matter?

Please let me know. If we can set up a discussion on this matter I am 
willing to address the issues in my own time.


View raw message