我需要在 Lotus Notes 6.5 DB 中编写 JavaAgent 来访问 Web 服务。为此,我使用了 Axis Apache API。我创建了一个 Java 代理,并使用“编辑项目”按钮在代理中添加了 axis 的 jar 文件。
下面是代理代码:
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();
}
}
}
下面是抛出的异常:
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)
我尝试访问互联网上的一些链接,例如,但我无法准确了解它要求执行的操作。例如:http://www-10.lotus.com/ldd/nd6forum.nsf/55c38d716d632d9b8525689b005ba1c0/40d033fba3897f4d85256cd30034026a?OpenDocument
任何帮助都会很棒。我想做的就是编写一个代理,以便我可以访问 Web 服务,例如 w3schools 上的温度转换 Web 服务。 http://www.w3schools.com/webservices/tempconvert.asmx?op=FahrenheitToCelsius
最佳答案
我用谷歌搜索了您的错误消息,这是第一个结果:
http://croarkin.blogspot.fi/2010/08/commons-logging-headaches-with-axis.html
它建议使用 commons-logging.properties 文件:
org.apache.commons.logging.Log = org.apache.commons.logging.impl.Log4JLogger
org.apache.commons.logging.LogFactory = org.apache.commons.logging.impl.LogFactoryImpl
或将其放入您的代码中:
@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");
}
可能您已经尝试过此操作,因为这是 Google 的第一次点击,但以防万一...
关于Lotus Notes 6.5 中使用 axis api 的 JavaAgent 出现异常 "No implementation defined for org.apache.commons.logging.LogFactory",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13608460/