Logging is easy and there are no problems since apache.log4j and apache.commons.logging etc. exist. Using OSGI bundles its also easy to have the correct versions of bundles in your classpath. Standard Bundles can be re-used easy in OSGI frameworks – the newest example in this direction is SpringSource Enterprise Bundle Repository. Hey – logging paradise is out there ….
My actual project (ERP solution) has to integrate Eclipse Riena, EasyBeans and Equinox. Some problems were to resolve to make Riena and EasyBeans run under Eclipse + Equinox 3.4.RC4. (see also here and here)
The focus of this blog is only logging if these projects were used together – I’ll talk later about the functional use.
The first small problem was easy to solve: Eclipse Riena needs a special version of equinox.log – replacing the equinox.log bundle from Equinox SDK with the version from Riena also works with EasyBeans.
Riena has a dependency to log4j (Require-Bundle) – would be better to use Import-Package instead to make it possible to use log4j Bundles from other repositories.
Riena uses Jetty (contained in Equinox SDK and Platform SDK), Jetty itself has a dependency to org.apache.commons.logging (Import-Package).
All works well with Eclipse Riena – org.apache.commons.logging detects org.apache.log4J and uses this implementation.
EasyBeans components are also dependent from von commons.logging (Import-Package) and they found this package as part of the EasyBeans Bundle ow2-bundles-externals-commons-logging.
As expected – this works wel with EasyBeans – commons.logging sees no log4j and uses the Java JDK Logging.
Riena and EasyBeans Logging – the problems
Are we happy with logging ? YES ! …if we only use Riena OR EasyBeans – but not together😦
Unfortunately the logging in EasyBeans has an implementation only working with JDK – Logging.
But org.apache.commons.logging chooses log4j – if found – and doesn’t look for the JDK logging as implementation.
Running Riena and EasyBeans without changes together (changing start-level doesn’t matter), then there’s an error from commons.logging @ EasyBeans Bundle: NoClassDefFoundError: org/apache/log4j/Category
Next try: We remove the Equinox Bundle org.apache.commons.logging. EasyBeans Bundle ow2-bundles-externals-commons-logging also exports the contained org.apache.commons.logging – packages.
Starting again bundle org.mortbay.jetty reports an error: org.apache.commons.logging expected from version 1.0.0 – the EasyBeans Bundle instead exports org.apache.commons.logging without any version.
Another try: We replace org.apache.commons.logging with com.springsource.org.apache.commons.logging from SpringSource Enterprise Bundle Repository and restart. Now com.springsource.org.apache.commons.logging reports an error: import of log4J needs version 1.2.15, org.apache.log4J from Riena is version 1.2.8 and doesn’t match. We can’t use com.springsource.org.apache.log4j from Spring, because Riena uses Bundle-Required instead of Import-Package.
Also EasyBeans reports an error: No suitable Log implementation
EasyBeans cannot use log4j as logger – only JDK logging.
Riena and EasyBeans Logging – the solution
- use equinox.log_1.1.0.HEAD from Riena instead of equinox.log_1.1.0 from Equinox SDK
- remove org.apache.commons.logging from Equinox SDK
- patch org.mortbay.jetty from Equinox SDK / Platfprm SDK: remove version from Package-Import org.apache.commons.logging
It’s not an elegant solution, but it works: I’m able to log from Riena and EasyBeans running together in Equinox !
- Riena should use Package-Import instead of Bundle-Required for org.apache.log4j (Bugzilla 237221 and Newsgroup)
- Riena should use standard equinox.log_version instead of equinox.log_version.HEAD, perhaps adding a fragment for additional functionality from equinox.log. (Newsgroup)
- EasyBeans should also work using „standard“ org.apache.commons.logging bundles (from Equinox, Spring etc). EasyBeans should also allow log4j as logging implementation (JIRA)
This would make life as an OSGI – application developer easier. Please vote for the bugs – thanks !