I am trying to write a new listener for Jira, and I ran into a problem, which I am very grateful for the help and recommendations.
Background We are launching Jira 4.2.2 Enterprise WAR under Apache Tomcat. This includes the following jar files in the webapps / jira / WEB-INF / lib file:
* slf4j-api-1.5.8.jar * slf4j-log4j12-1.5.8.jar
We have a simple class that works like a plugin. It accepts events and is based on the type of event, does some work. This class uses slf4j for logging and works as expected. The class is packaged in a jar and deployed under webapps / jira / WEB-INF / lib and is used from there. We can add this as a listener, configure it, and view error messages in the log. All entries happen through slf4j and work.
When we try to add functionality to our plugin from a third-party library, we get the following exception: com.atlassian.util.concurrent.LazyReference $ InitializationException: java.lang.NoClassDefFoundError: org / slf4j / LoggerFactory
Since slf4j is accessible and used by a class that we call this third-party library, I don’t understand what I am doing wrong, or how to make it available while the call is made.
Working case
In our code, we create the registrar as follows:
import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.3rdparty.login; public class JiraSampleListener extends AbstractIssueEventListener implements IssueEventListener { private final static Logger logger = LoggerFactory.getLogger(JiraSampleListener.class); . . .
Then we can use this by calling
logger.warn("MESSAGE")
The expected message will appear in our magazines.
Error case
As soon as we add the following code to this class, we will get a related exception:
newThing = new 3rdPartyClass("name of thing");
Exception
com.atlassian.util.concurrent.LazyReference $ InitializationException: java.lang.NoClassDefFoundError: org / SLF 4J / LoggerFactory
Any advice on resolving this or pointers to what I am doing wrong here will be greatly appreciated!
What follows is a more complete picture of the exception ...
2011-01-19 05: 30: 51,016 main ERROR [com.atlassian.jira.ComponentManager] Error occurred
while starting component 'com.atlassian.jira.event.DefaultListenerManager'.
com.atlassian.util.concurrent.LazyReference $ InitializationException: java.lang.NoClassDefFoundError: org / slf4j / LoggerFactory
at com.atlassian.util.concurrent.LazyReference.getInterruptibly (LazyReference.java:148)
at com.atlassian.util.concurrent.LazyReference.get (LazyReference.java:111)
at com.atlassian.util.concurrent.ResettableLazyReference.get (ResettableLazyReference.java:89)
at com.atlassian.jira.event.DefaultListenerManager $ Listeners.start (DefaultListenerManager.java:93)
at com.atlassian.jira.event.DefaultListenerManager.start (DefaultListenerManager.java:38)
at com.atlassian.jira.ComponentManager.quickStart (ComponentManager.java:256)
at com.atlassian.jira.ComponentManager.start (ComponentManager.java:212)
at com.atlassian.jira.upgrade.ConsistencyLauncher.launchConsistencyChecker (ConsistencyLauncher.java:63)
at com.atlassian.jira.upgrade.ConsistencyLauncher.contextInitialized (ConsistencyLauncher.java:42)
at org.apache.catalina.core.StandardContext.listenerStart (StandardContext.java:3972)
at org.apache.catalina.core.StandardContext.start (StandardContext.java:4467)
at org.apache.catalina.core.ContainerBase.addChildInternal (ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild (ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild (StandardHost.java∗46)
at org.apache.catalina.startup.HostConfig.deployDescriptor (HostConfig.java:637)
at org.apache.catalina.startup.HostConfig.deployDescriptors (HostConfig.java∗63)
at org.apache.catalina.startup.HostConfig.deployApps (HostConfig.java:498)
at org.apache.catalina.startup.HostConfig.start (HostConfig.java:1277)
at org.apache.catalina.startup.HostConfig.lifecycleEvent (HostConfig.java:321)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent (LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start (ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start (StandardHost.java:785)
at org.apache.catalina.core.ContainerBase.start (ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start (StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start (StandardService.java∗19)
at org.apache.catalina.core.StandardServer.start (StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start (Catalina.java∗81)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke (Method.java∗97)
at org.apache.catalina.startup.Bootstrap.start (Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main (Bootstrap.java:414)
Caused by: java.lang.NoClassDefFoundError: org / slf4j / LoggerFactory
at 3rd.party.3rdPartyClassDefaultImpl. (3rdPartyClassDefaultImpl.java:101)
at java.lang.Class.forName0 (Native Method)
at java.lang.Class.forName (Class.java:169)
at 3rd.party.3rdParty. (3rdParty.java:107)
at 3rd.party.3rdParty. (3rdParty.java:83)
at 3rd.party.3rdParty. (3rdParty.java:67)
at my.organisationlisteners.JiraSampleListener.init (JiraSampleListener.java:36)
at com.atlassian.jira.event.ListenerFactory.getListener (ListenerFactory.java:33)
at com.atlassian.jira.event.DefaultListenerManager $ Listeners.loadListeners (DefaultListenerManager.java:126)
at com.atlassian.jira.event.DefaultListenerManager $ Listeners.create (DefaultListenerManager.java:71)
at com.atlassian.jira.event.DefaultListenerManager $ Listeners.create (DefaultListenerManager.java:66)
at com.atlassian.util.concurrent.ResettableLazyReference $ InternalReference.create (ResettableLazyReference.java:143)
at com.atlassian.util.concurrent.LazyReference $ Sync.run (LazyReference.java data16)
at com.atlassian.util.concurrent.LazyReference.getInterruptibly (LazyReference.java:142)
... 32 more
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
at java.net.URLClassLoader $ 1.run (URLClassLoader.java:202)
at java.security.AccessController.doPrivileged (Native Method)
at java.net.URLClassLoader.findClass (URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass (ClassLoader.java:307)
at sun.misc.Launcher $ AppClassLoader.loadClass (Launcher.javahaps01)
at java.lang.ClassLoader.loadClass (ClassLoader.java:248)
... 46 more