我请教一个关于 web service的问题.  .            我的异常代码如下:
  org.apache.axis2.AxisFault: Could not initialize class simple.WordSimilarity
at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:512)
at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:370)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:416)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:228)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)
at simpleTest.WordSimServiceStub.service(WordSimServiceStub.java:186)
at simpleTest.WordSimRemote.main(WordSimRemote.java:19)
   我的包里面包含了众多的class . 但是我只发布了其中的一个class 作为 service..   这个service 引用了包中其他的类.  当我测试的时候. 就会出现这个. 我调用了WordSimilarity中的一个静态方法. 这个类里面都是静态方法.simple.WordSimilarity引用了一个外部dat文件.. 调用这个静态方法 要首先加载那个 dat文件.    不通过远程调用程序是没有问题的. 不知何解? 附上service的代码.    package simple;public class RemoteService { public double service(String word1, String word2) {
return WordSimilarity.simWord(word1, word2);
}}

解决方案 »

  1.   


    虽然你只是发布一个类作为service,其它用到的类也必须同时发布过去,否则就会找不到依赖的类啊。
      

  2.   

      Thx .   那如何通过Axis2 service Arch  的plugin来发布  Generate the Service XML file的时候.  可以选择 service name  跟 Class name .   class name那里只能选一个class .  同时发布怎么来发布呢?
      

  3.   

    不会吧,我看到的是第一步让你选择一个class目录,不是选择一个class类啊:http://ws.apache.org/axis2/tools/1_0/eclipse/servicearchiver-plugin.htmlOnce the class file folder (which should be a folder in the file system) is browsed and selected, the Next button will be enabled and you can move to the next page. Note that you have the option of either including all the files or the class files only of the folder on page 1.
      

  4.   

    哦,我明白了,你只是生成 Service XML file,只是一个配置文件,你不是一次性打包成aa文件或者jar文件吗?那你正好看看上面连接的教程吧。第一步:
    第二步,选择类目录:你所生成的service xml文件,只是Web service中的一个描述文件而已,
    用在这个教程的第三步:
      

  5.   

      我最后生成的是一个 aar的 服务文件.  你所提供的链接 我是看过的. 不过还是感谢你的热心.  这个版本的插件 太老了. 
              我现在用的这个. 包含两个小的插件. 一个是用于构建服务的 service arch . 还有一个是Code Generator的.  我现在发布服务这里. 用的是  service arch 这个小的插件.   而现在这个插件跟以前有了不同. .  主要是有这一步. 
        引用了这个blog的内容. 不过这是个入门的blog  . 我跟他的插件是一样的.   http://deltaj.javaeye.com/blog/286257   求教..
      

  6.   

    我觉得这里不存在问题,步骤都是一样的,
    关键有两点:第一步选择class路径的时候,你要保证你的class路径下,确实包含你所用到的所有类。而第五步的构建service xml,选择一个服务类,也是对的,而且这个服务类肯定要在第一步的类路径下。所以,我现在有点不太清楚你到底还有什么问题?