My Jira 5.0 plugin is broken with the following exception:
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
...
Caused by: java.lang.ExceptionInInitializerError
at org.apache.axis.description.OperationDesc.<clinit>(OperationDesc.java:65)
at com.xyz.germander.AddTestTrackLinkDialogAction.doConfirm(AddTestTrackLinkDialogAction.java:23)
... 148 more
Caused by: java.lang.ClassCastException: org.apache.commons.logging.impl.SLF4JLogFactory cannot be cast to org.apache.commons.logging.LogFactory
at org.apache.axis.components.logger.LogFactory.getLogFactory(LogFactory.java:41)
at org.apache.axis.components.logger.LogFactory.<clinit>(LogFactory.java:33)
... 150 more
For reference, this is the method throwing the ClassCastException:
private static final org.apache.commons.logging.LogFactory getLogFactory() {
return (org.apache.commons.logging.LogFactory)
AccessController.doPrivileged(
new PrivilegedAction() {
public Object run() {
return DiscoverSingleton.find(org.apache.commons.logging.LogFactory.class,
org.apache.commons.logging.LogFactory.FACTORY_PROPERTIES,
org.apache.commons.logging.LogFactory.FACTORY_DEFAULT);
}
});
}
... for further reference, org.apache.commons.logging.LogFactory.FACTORY_DEFAULT is "org.apache.commons.logging.impl.LogFactoryImpl", and FACTORY_PROPERTIES is supposed to be the name of the properties file to search for, which in my org.apache.commons.logging jar is "commons-logging.properties".
I've tried creating a commons-logging.properties file in the resource dir of the plugin; that file contains this:
priority=1
org.apache.commons.logging.Log=org.apache.commons.logging.impl.LogFactoryImpl
... but it seems to get ignored since getLogFactory() still gets SLF4JLogFactory and fails to cast it. So it looks like:
- This commons-logging.properties file needs to be somewhere else
- I need to set the logging class to be something else
- The project is otherwise misconfigured, maybe at the Jira level or maybe at the plugin or maybe Maven or... I don't even know
I'm pretty stumped, and would appreciate any guidance.
There is a similar question here, except that poster was getting the same exception in getLogFactory from the initialization of org.apache.axis.attachments.AttachmentsImpl instead of org.apache.axis.description.OperationDesc. (Also a Confluence plugin, not Jira.) Nobody responded there, though.
Including axis-1.3-atlassian-1 only results
java.lang.ClassNotFoundException: org.apache.axis.transport.http.AdminServlet
Due to my application needs AdminServlet which is included in appache axis library. Finally when I included both it works fine with me.
<dependency>
<groupId>org.apache.axis</groupId>
<artifactId>axis</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>axis</groupId>
<artifactId>axis</artifactId>
<version>1.3-atlassian-1</version>
<scope>provided</scope>
</dependency>
Discoveries: Atlassian forked the axis library and Jira now uses axis-1.3-atlassian-1 and not the latest axis-1.4 from Apache; axis-1.3-atlassian-1 uses the 1.0.4 version of commons-logging, not 1.1.1 like axis-1.4.
Changing the dependency of the plugin from axis-1.4 to axis-1.3-atlassian-1 solved the problem. It is my suspicion that SLF4JLogFactory could cast to org.apache.commons.logging.LogFactory in 1.0.4 but not 1.1.1, but I haven't tested it.
If in Jira, be sure to give the scope of the dependency as "provided" or you'll run in to problems due to stuff being loaded twice. Here's a pom snippet:
<dependency>
<groupId>axis</groupId>
<artifactId>axis</artifactId>
<version>1.3-atlassian-1</version>
<scope>provided</scope>
</dependency>
来源:https://stackoverflow.com/questions/11727768/apache-axis-logging-classcastexception-while-using-it-inside-a-jira-plugin