Weird ClassNotFoundException during startup of osgi bundles

Hi,

I'm trying to fix the following stacktrace, apparering in logs during Jira startup. It doesn't prevent Jira from running (ie I can access the UI after a while), but I'd really like to avoid this:

2012-07-03 14:35:26,256 Thread-2 INFO      [atlassian.plugin.util.WaitUntil] Plugins that have yet to be enabled: [com.atlassian.jirafisheyeplugin, com.atlassian.jira.jira-issue-link-applinks-common-plugin, com.atlassian.jira.gadgets, com.atlassian.soy.soy-template-plugin, com.atlassian.jira.rest, com.atlassian.streams.streams-thirdparty-plugin, com.atlassian.crowd.embedded.admin, com.atlassian.plugins.rest.atlassian-rest-module, com.atlassian.oauth.serviceprovider, com.atlassian.streams.streams-jira-plugin, com.atlassian.jira.jira-issue-link-confluence-plugin, com.atlassian.gadgets.dashboard, com.atlassian.gadgets.embedded, com.atlassian.oauth.admin, com.atlassian.gadgets.oauth.serviceprovider, com.atlassian.jira.jira-view-issue-plugin, com.atlassian.streams.core, com.atlassian.jira.jira-project-config-plugin, com.atlassian.upm.atlassian-universal-plugin-manager-plugin, com.atlassian.streams, com.atlassian.gadgets.directory, com.atlassian.applinks.applinks-plugin, com.atlassian.jira.plugins.jira-importers-plugin, com.atlassian.activeobjects.activeobjects-plugin, com.atlassian.jira.jira-issue-link-remote-jira-plugin, com.atlassian.gadgets.opensocial, com.atlassian.jira.jira-invite-user-plugin, com.atlassian.jira.plugin.ext.bamboo, com.atlassian.streams.actions], 58 seconds remaining
2012-07-03 14:35:25,709 Spring executor 10 ERROR      [plugin.osgi.factory.OsgiPlugin] Unable to start the Spring context for plugin com.atlassian.crowd.embedded.admin
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'handler' defined in URL [bundle://26.0:0/META-INF/spring/web-context.xml]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: javax/servlet/ServletContext
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:480)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
	at java.security.AccessController.doPrivileged(Native Method)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
	at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:69)
	at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:355)
	at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
	at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
	at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:132)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
	at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.NoClassDefFoundError: javax/servlet/ServletContext
	at java.lang.Class.getDeclaredMethods0(Native Method)
	at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
	at java.lang.Class.privateGetPublicMethods(Class.java:2547)
	at java.lang.Class.getMethods(Class.java:1410)
	at java.beans.Introspector.getPublicDeclaredMethods(Introspector.java:1284)
	at java.beans.Introspector.getTargetMethodInfo(Introspector.java:1158)
	at java.beans.Introspector.getBeanInfo(Introspector.java:408)
	at java.beans.Introspector.getBeanInfo(Introspector.java:167)
	at java.beans.Introspector.getBeanInfo(Introspector.java:230)
	at java.beans.Introspector.<init>(Introspector.java:389)
	at java.beans.Introspector.getBeanInfo(Introspector.java:167)
	at java.beans.Introspector.getBeanInfo(Introspector.java:230)
	at java.beans.Introspector.<init>(Introspector.java:389)
	at java.beans.Introspector.getBeanInfo(Introspector.java:167)
	at java.beans.Introspector.getBeanInfo(Introspector.java:230)
	at java.beans.Introspector.<init>(Introspector.java:389)
	at java.beans.Introspector.getBeanInfo(Introspector.java:167)
	at org.springframework.beans.CachedIntrospectionResults.<init>(CachedIntrospectionResults.java:220)
	at org.springframework.beans.CachedIntrospectionResults.forClass(CachedIntrospectionResults.java:144)
	at org.springframework.beans.BeanWrapperImpl.getCachedIntrospectionResults(BeanWrapperImpl.java:252)
	at org.springframework.beans.BeanWrapperImpl.getPropertyDescriptorInternal(BeanWrapperImpl.java:282)
	at org.springframework.beans.BeanWrapperImpl.isWritableProperty(BeanWrapperImpl.java:333)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1247)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
	... 18 more
Caused by: java.lang.ClassNotFoundException: javax.servlet.ServletContext
	at org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:772)
	at org.apache.felix.framework.ModuleImpl.access$200(ModuleImpl.java:73)
	at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1690)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
	... 43 more

which repeats several times

I searched in my filesystem, I only have 1 servlet-api.jar which is located in my tomcat's lib dir...

Additionnaly, I have lots (about 40) lines like this, speaking about threads and threadlocals, during shutdown:

SEVERE: The web application [/jira] appears to have started a thread named [QuartzWorker-0] but has failed to stop it. This is very likely to create a memory leak.
Jul 3, 2012 2:37:41 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/jira] appears to have started a thread named [JonasBatch] but has failed to stop it. This is very likely to create a memory leak.
Jul 3, 2012 2:37:41 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/jira] appears to have started a thread named [JonasClock] but has failed to stop it. This is very likely to create a memory leak.
Jul 3, 2012 2:37:41 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads

Any clue?

Thank you!

3 answers

1 accepted

Have you marked a Provided scope dependency in your plugin for javax.servlet-api ? Because you are in a plugin you may not have access to the class. I use servlet api often, not in tomcat7, though, my pom contains:

<dependency>

<groupId>javax.servlet</groupId>

<artifactId>servlet-api</artifactId>

<version>2.5</version>

<scope>provided</scope>

</dependency>

Oh, also, Tomcat 7 isnt a supported platform either, perhaps that mean untested, perhaps that it just wont work...

https://confluence.atlassian.com/display/JIRA/Supported+Platforms

Hum I don't use Maven for this, and I don't build anything myself (I use the Jira shipped, out of the box, no additionnal plugin).

But as you said in your message, Tomcat 7 is not supported, so I'll stop trying to make it work and downgrade to a 6.x.

Thank you for pointing me on the right direction!

I confirm: no more exception when using Tomcat 6

I guess that's the price to pay for using Atlassian's product in an unsupported container. Seeing the same behavior for other not supported containers as well, like winstone, glassfish, jetty, tjws etc.

Check your generated JAR, you'll probably have a servlet jar in there, fix your dependencies such that servlet-api is provided scope.

Sorry but there is no other *servlet*.jar anywhere, I've opened every jar located in web-inf/lib to find anything related to javax.servlet, but there isn't any.

For information, I'm using Jira 5.0.4, Tomcat 7 and Mysql. I've built it using the provided batch, then removed the slf4j/log4j libs and put them into my tomcat's lib directory... I don't have any other plugin installed yet.

more infos:

I'm able to reproduce the exact stacktrace on my local machine (Win xp) with Tomcat 7, but not with Tomcat 6!

could anybody confirm that?

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published 3 hours ago in Jira Software

How large do you think Jira Software can grow?

Hi Atlassian Community! My name is Shana, and I’m on the Jira Software team. One of the many reasons this Community exists is to connect you to others on similar product journeys or with comparabl...

57 views 4 4
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you