【问题标题】:Getting Exception while trying to execute axis2 service client尝试执行axis2服务客户端时出现异常
【发布时间】:2016-02-02 15:07:18
【问题描述】:

我正在尝试创建一个示例axis2 ServiceClient。它抛出错误

org.apache.axiom.om.OMException: No meta factory found for feature 'default'; this usually means that axiom-impl.jar is not in the classpath
    at org.apache.axiom.om.OMAbstractFactory.getMetaFactory(OMAbstractFactory.java:170)
    at org.apache.axiom.om.OMAbstractFactory.getMetaFactory(OMAbstractFactory.java:135)
    at org.apache.axiom.om.OMAbstractFactory.getOMFactory(OMAbstractFactory.java:184)
    at org.apache.axis2.description.AxisDescription.<init>(AxisDescription.java:68)
    at org.apache.axis2.engine.AxisConfiguration.<init>(AxisConfiguration.java:148)
    at org.apache.axis2.deployment.DeploymentEngine.populateAxisConfiguration(DeploymentEngine.java:639)
    at org.apache.axis2.deployment.FileSystemConfigurator.getAxisConfiguration(FileSystemConfigurator.java:116)
    at org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContext(ConfigurationContextFactory.java:68)
    at org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContextFromFileSystem(ConfigurationContextFactory.java:184)
    at org.apache.axis2.client.ServiceClient.configureServiceClient(ServiceClient.java:150)
    at org.apache.axis2.client.ServiceClient.<init>(ServiceClient.java:143)
    at org.apache.axis2.client.ServiceClient.<init>(ServiceClient.java:244)
    at org.apache.axis2.samples.tu.client.TUrlSOAPClient.addUrl(TUrlSOAPClient.java:46)
    at org.apache.axis2.samples.tu.client.TUrlClient.actionPerformed(TUrlClient.java:69)
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at javax.swing.JComponent.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

axiom-impl.jar 存在于类路径中。下面是代码sn-p。在控制台中,我可以看到显示 sysout 语句“Entered”,然后在创建 ServiceClient 对象时抛出错误。尝试使用不同版本的 axiom-impl.jar(1.2.12、1.2.13、1.2.7、1.2.5),但仍然出现相同的错误。

     public static String testFunction(String testData) throws Exception {
     System.out.println("Entered");
    //Create a service client
    ServiceClient client = new ServiceClient();
    System.out.println("Before calling set end point");
    //Set the endpoint address
    client.getOptions().setTo(new EndpointReference(EPR));
    System.out.println("After calling set end point");
    System.out.println("getPayload(url)="+getPayload(testData));
    //Make the reqest and get the response
    OMElement resp = client.sendReceive(getPayload(testData));
    //Extract the URL and return
    return extractUrl(resp);
}

【问题讨论】:

    标签: axis2


    【解决方案1】:

    我遇到了同样的错误,但经过长时间的努力,终于通过使用 axiom-api 1.2.12 和 axiom-impl 1.2.12 解决了。

    【讨论】:

      【解决方案2】:

      通过仅用 axiom.jar 替换所有三个单独的公理 jar(axiom-impl-1.2.13.jar、axiom-dom-1.2.13.jar 和 axiom-api-1.2.13.jar)解决了这个问题。

      【讨论】:

      • 但是为什么会发生这种情况,我仍然无法得到答案我们在 eclipse 或 tomcat 中有一些设置要求最新版本的 axim jars。
      • 由于某种原因,同样的事情发生在我身上,我仍然无法找出造成这种情况的原因。无论如何,谢谢你,你拯救了我的一天。
      【解决方案3】:

      当我使用上面的 jar 时,我遇到了另一个错误。 java.lang.ClassCastException: java.lang.ClassCastException: org.apache.axiom.om.impl.llom.factory.OMLinkedListImplFactory

      我不得不将每个 jar 的版本增加到 1.2.14

      【讨论】:

        【解决方案4】:

        我有同样的错误。我确实用 axiom.jar 替换了单个公理 jar(axiom-impl-1.2.13.jar、axiom-dom-1.2.13.jar 和 axiom-api-1.2.13.jar),但错误仍然发生。

        错误的根本原因是 META-INF/axiom.xml 文件的位置。在我的例子中,当 J2EE 服务器容器的 XMLParser 在 jar 文件中本地化时,它无法打开 axion.xml 文件。

        我不得不将 META-INF/axiom.xml 复制到 WEB-INF/classes/META-INF/axiom.xml 中。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2013-06-24
          • 1970-01-01
          • 1970-01-01
          • 2018-05-11
          • 2012-04-01
          • 2014-01-18
          相关资源
          最近更新 更多