Common Issues with Resolution encounter in running OSGI Web App as standalone

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:

java.lang.NoClassDefFoundError: org/xml/sax/SAXException

Resolution

  • Make OSGi standalone application by exporting plugin project as feature instead of plugin as describe at my blog …….

Issue#2: org.apache.commons.logging.LogConfigurationException

Steps to Produce

  • 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))

Resolution

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

Resolution

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

Advertisements

One thought on “Common Issues with Resolution encounter in running OSGI Web App as standalone

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s