当前位置: 代码迷 >> J2EE >> HelloWorld的webservice为何报java.lang.ClassNotFoundException
  详细解决方案

HelloWorld的webservice为何报java.lang.ClassNotFoundException

热度:335   发布时间:2016-04-22 03:37:31.0
HelloWorld的webservice为什么报java.lang.ClassNotFoundException
我初学webservice,读了不少贴子想做一个HelloWorld的例子,环境为:Win xp,tomcat5.0,Axis2.0,等打包发布后启动tomcat总是报错:
2008-1-2 14:28:23 org.apache.axis2.deployment.DeploymentEngine doDeploy
信息: Deploying module : addressing-1.1.1
2008-1-2 14:28:23 org.apache.axis2.deployment.DeploymentEngine doDeploy
信息: Deploying module : soapmonitor-1.1.1
org.apache.axis2.deployment.DeploymentException: Processing Operations Modules Error in schema generating com.HelloWorld; nested exception is
java.lang.ClassNotFoundException: com.HelloWorld; nested exception is: 
org.apache.axis2.deployment.DeploymentException: Error in schema generating com.HelloWorld; nested exception is: 
java.lang.ClassNotFoundException: com.HelloWorld; nested exception is: 
org.apache.axis2.deployment.DeploymentException: Processing Operations Modules Error in schema generating com.HelloWorld; nested exception is: 
java.lang.ClassNotFoundException: com.HelloWorld; nested exception is: 
org.apache.axis2.deployment.DeploymentException: Error in schema generating com.HelloWorld; nested exception is: 
java.lang.ClassNotFoundException: com.HelloWorld以下是我的代码,附件中也是,项目名称为project结构如:
project
--META-INF
  --services.xml
--com
  --HelloWorld.java

package newsdes.support.service;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
 
public class HelloWorld {
  //读取client端getSayHelloOMElement()方法传递的参数in。
  public OMElement sayHello(OMElement in){
  //将in转换为String。
  String name=in.getText();
  String info=name+"HelloWorld!";
  //创建response SOAP包。
  OMFactory fac=OMAbstractFactory.getOMFactory();
  // OMNamespace指定此SOAP文档名称空间。
  OMNamespace omNs=fac.createOMNamespace("http://helloworld.com/","hw");
  //创建元素sayHello,并指定其在omNs指代的名称空间中。
  OMElement resp=fac.createOMElement("sayHelloResponse",omNs);
  //指定元素的文本内容。
  resp.setText(info);
  return resp;
  }
}

services.xml的代码

<?xml version="1.0" encoding="UTF-8"?>//这一句有没有好像没有关系?<service name="HelloWorld">
<description>
  This is a sample Web Service.
</description>
<parameter name="ServiceClass" locked="false">com.HelloWorld</parameter>
<operation name="sayHello">
<messageReceiver class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
</operation>
</service>


请大家给说说怎么回事?先谢谢了,问题解决后定高分送上.





------解决方案--------------------
你的包路径不一致啊,所以找不到:
newsdes.support.service
com.HelloWorld
------解决方案--------------------
不是哪问题,那个已经改过了,还是不行.附件中的代码是正确的,但发布了也不行.
  相关解决方案