问题
I have been able to understand about the dependencies and procedures to add Jar files into a Confluence project with the help of a friend from here. But I am facing an error with the addition of these JAR's. The exact cause of the error seen is :
javax.servlet.ServletException: Servlet execution threw an exception
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:313)
caused by: java.lang.ExceptionInInitializerError
at org.apache.axis.attachments.AttachmentsImpl.<clinit>(AttachmentsImpl.java:39)
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)
What I am trying to do is :
- Write a custom plugin.
- Modify the UI so that I can accept user entered values say For Eg Credentials.
- Use those credentials and hit a web service method and obtain a ticket for the valid user.
Now I can only consume the web services I do not have the authority to modify them. As a result it does work with 8 essential jars. Of these the ones which I use not created by me are the popular ones.
commons-discovery 0.2
commons-logging 1.1
jaxrpc 1.0
log4j 1.0
wsdl4j
1.0 axis 1.4
If i use axis 1.2.1 instead of 1.4 ; i get the error .
Exception in thread "main" java.lang.NoSuchMethodError: org.apache.axis.description.ParameterDesc.setOmittable(Z)V
But using axis 1.4 gives me the required ticket in my local NON CONFLUENCE test sample Java project. (I am putting my code in paste bin lest the question becomes extremely long)
This is my POM.xml
This is the class I have written. I have in fact been able to add my custom tab in the 'Advanced' area and clicking on the tab triggers the execute method.
This is the error I am seeing on the resulting System Error (the one with the title Oops - an error has occured.)
Would like to have any hints from you which can greatly help understand what needs to be done to get out of this error.
I am sure calling web services from Confluence must be a not a complex chore. Is it the combination of JAR's I am reliant on that's giving me the trouble. Any leads to the same will be immensely helpful.
回答1:
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 a similar problem for me. 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 that.
Edit: here's where you can get the jar and source.
来源:https://stackoverflow.com/questions/11464763/getting-slf4jlogfactory-exception-while-trying-to-access-web-services-from-confl