When I was making struts Osgi app to run as standalone application, I encountered with some issues that I am listing below. This would surely help others who might encounter with the same issues.
Issue #1: java.lang.NoClassDefFoundError: org/xml/sax/SAXException
Steps to produce
- Run OSGi container using following command
java -Dlog4j.debug -jar org.eclipse.osgi_3.3.0.v20070530.jar -configuration configuration -consoleLog -debug -clean -dev -console
- Install and run OSGi struts plugin which is exported as plugin from the eclipse IDE,got following error:
- Make OSGi standalone application by exporting plugin project as feature instead of plugin as describe at my blog …….
- Its a general problem not specific to OSGi, but you would encounter with it when using struts in OSGi. The issue is due to the is conflict between commons-logging-1.0.4.jar and log4j-1.2.11.jar. Following error would occur when we would be using log4j-1.2.11.jar in our web application:
org.apache.commons.logging.LogConfigurationException: at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:543) org.apache.commons.logging.LogConfigurationException: No suitable Log constructor [Ljava.lang.Class;@ff2413 for org.apache.commons.logging.impl.Log4JLogger (Caused by java.lang.NoClassDefFoundError: org/apache/log4j/Category) (Caused by org.apache.commons.logging.LogConfigurationException: No suitable Log constructor [Ljava.lang.Class;@ff2413 for org.apache.commons.logging.impl.Log4JLogger (Caused by java.lang.NoClassDefFoundError: org/apache/log4j/Category))
- This bug is documented at https://bugs.eclipse.org/bugs/show_bug.cgi?id=195765
As a work around of this I used JRE logging class instead of log4J to log messages/errors.
Issue#3: OSGi windows closes after jetty is started
Steps to Produce
- When running Osgi application as standalone application (exported as feature) using following command, OSGi console windows opens with jetty server started and then suddenly the windows close.
eclipse -console -clean
Add -NoExit paramter in the argument as shown below. This would make sure that OSGi container window remain open till Osgi container is running:
eclipse -console -clean -noexit