Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
413 views
in Technique[技术] by (71.8m points)

java - JavaAgent in Lotus Notes 6.5 using axis api gives Exception "No implementation defined for org.apache.commons.logging.LogFactory"

I needed to write a JavaAgent in a Lotus Notes 6.5 DB to access a web service. I used Axis Apache API for this purpose. I created A Java agent and added the jar files of axis in the agent by using Edit Project button.

Below is the agent code:

import lotus.domino.*;
import javax.xml.*;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import javax.xml.namespace.QName;
import java.net.URL;

public class JavaAgent extends AgentBase {

    public void NotesMain() {

        try {


            Session session = getSession();
            AgentContext agentContext = session.getAgentContext();

            String  endpoint = "http://ws.apache.org:5049/axis/services/echo";
            Service service = new Service();
            Call     call    = (Call) service.createCall();
            call.setTargetEndpointAddress(new java.net.URL(endpoint) );

            call.setOperationName(new QName("http://soapinterop.org/", "echoString"));
            String ret = (String) call.invoke( new Object[] { "Hello!" } );
            System.out.println("Sent 'Hello!', got '" + ret + "'");

        } catch(Exception e) {
            e.printStackTrace();
        }
    }
}

And below is the exception thrown:

java.lang.ExceptionInInitializerError: org.apache.commons.discovery.DiscoveryException: No implementation defined for org.apache.commons.logging.LogFactory

    at org.apache.commons.discovery.tools.SPInterface.newInstance(SPInterface.java:197)

    at org.apache.commons.discovery.tools.DiscoverClass.newInstance(DiscoverClass.java:579)

    at org.apache.commons.discovery.tools.DiscoverSingleton.find(DiscoverSingleton.java:418)

    at org.apache.commons.discovery.tools.DiscoverSingleton.find(DiscoverSingleton.java:378)

    at org.apache.axis.components.logger.LogFactory$1.run(LogFactory.java:84)

    at java.security.AccessController.doPrivileged(Native Method)

    at org.apache.axis.components.logger.LogFactory.getLogFactory(LogFactory.java:80)

    at org.apache.axis.components.logger.LogFactory.<clinit>(LogFactory.java:72)

    at org.apache.axis.configuration.EngineConfigurationFactoryFinder.<clinit>(EngineConfigurationFactoryFinder.java:94)

    at org.apache.axis.client.Service.<init>(Service.java:111)

    at JavaAgent.NotesMain(JavaAgent.java:17)

    at lotus.domino.AgentBase.runNotes(Unknown Source)

    at lotus.domino.NotesThread.run(NotesThread.java:218)

I thried to follow some links on the internet like, But i was not able to get exactly what it was asking to do. eg: http://www-10.lotus.com/ldd/nd6forum.nsf/55c38d716d632d9b8525689b005ba1c0/40d033fba3897f4d85256cd30034026a?OpenDocument

Any help will be great. All i wanted to do is write an agent so that i can access a web service, say temperature conversion web service on w3schools. http://www.w3schools.com/webservices/tempconvert.asmx?op=FahrenheitToCelsius

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I googled with your error message and this is the first hit:

http://croarkin.blogspot.fi/2010/08/commons-logging-headaches-with-axis.html

It suggests using a commons-logging.properties file with:

org.apache.commons.logging.Log = org.apache.commons.logging.impl.Log4JLogger  
org.apache.commons.logging.LogFactory = org.apache.commons.logging.impl.LogFactoryImpl

or putting this to your code:

@BeforeClass  
public static void beforeClass() {  
 System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.Log4JLogger");  
 System.setProperty("org.apache.commons.logging.LogFactory", "org.apache.commons.logging.impl.LogFactoryImpl");  
}

Probably you've already tried this because it's the first hit with google but just in case...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...