2013-11-27 53 views
1

我通過在eclipse juno中使用Axis 2自下而上的方法創建了兩個數字Web服務的簡單添加.Web服務正常工作並通過soa客戶端mozilla擴展進行了正確測試,但出現錯誤tomcat.Please經過下面的錯誤在創建Web服務的tomcat中的錯誤

他計算器服務,這是無效的,造成

java.lang.NoClassDefFoundError: javax/ws/rs/Produces 
    at org.apache.axis2.jaxrs.JAXRSUtils.getClassModel(JAXRSUtils.java:53) 
    at org.apache.axis2.description.java2wsdl.DefaultSchemaGenerator.generateSchema(DefaultSchemaGenerator.java:272) 
    at org.apache.axis2.deployment.util.Utils.fillAxisService(Utils.java:468) 
    at org.apache.axis2.deployment.ServiceBuilder.populateService(ServiceBuilder.java:388) 
    at org.apache.axis2.deployment.repository.util.ArchiveReader.buildServiceGroup(ArchiveReader.java:101) 
    at org.apache.axis2.deployment.repository.util.ArchiveReader.processServiceGroup(ArchiveReader.java:178) 
    at org.apache.axis2.deployment.ServiceDeployer.deploy(ServiceDeployer.java:82) 
    at org.apache.axis2.deployment.repository.util.DeploymentFileData.deploy(DeploymentFileData.java:136) 
    at org.apache.axis2.deployment.DeploymentEngine.doDeploy(DeploymentEngine.java:813) 
    at org.apache.axis2.deployment.repository.util.WSInfoList.update(WSInfoList.java:144) 
    at org.apache.axis2.deployment.RepositoryListener.update(RepositoryListener.java:377) 
    at org.apache.axis2.deployment.RepositoryListener.checkServices(RepositoryListener.java:254) 
    at org.apache.axis2.deployment.DeploymentEngine.loadServices(DeploymentEngine.java:142) 
    at org.apache.axis2.deployment.WarBasedAxisConfigurator.loadServices(WarBasedAxisConfigurator.java:283) 
    at org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContext(ConfigurationContextFactory.java:95) 
    at org.apache.axis2.transport.http.AxisServlet.initConfigContext(AxisServlet.java:584) 
    at org.apache.axis2.transport.http.AxisServlet.init(AxisServlet.java:454) 
    at org.apache.axis2.webapp.AxisAdminServlet.init(AxisAdminServlet.java:60) 
    at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1280) 
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1193) 
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1088) 
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5176) 
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5460) 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) 
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559) 
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549) 
    at java.util.concurrent.FutureTask.run(FutureTask.java:262) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) 
    at java.lang.Thread.run(Thread.java:744) 
Caused by: java.lang.ClassNotFoundException: javax.ws.rs.Produces 
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1702) 
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547) 
    ... 30 more 

[INFO] org.apache.axis2.deployment.DeploymentException: java.lang.NoClassDefFoundError: javax/ws/rs/Produces 
[INFO] Deploying Web service: version.aar - file:/M:/mahesh/work/javaws1/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/Calc/WEB-INF/services/version.aar 
[WARN] No transportReceiver for org.apache.axis2.transport.http.AxisServletListener found. An instance for HTTP will be configured automatically. Please update your axis2.xml file! 
+0

計算器服務無效,也無法格式化,請嘗試改進它 –

+0

對不起,我的格式化。我會盡力改進它。請幫助我。 – Mahesh

+0

爲什麼我的計算器服務正常工作並且客戶端也收到了正確的結果,因此出現以下錯誤。 計算器服務無效,導致java.lang.NoClassDefFoundError:javax/ws/rs/Produces – Mahesh

回答

2

Tomcat的只是一個servlet容器和AFAIK,它默認情況下不支持任何類型的web服務的。

您必須在WEB-INF/lib中包含所需的庫,或者將其添加到tomcat lib文件夾並使用它。

您正在獲取ClassNotFoundException,因爲在類路徑中找不到javax/ws/rs/Produces。

將REST實施(例如:Jersey)部署到服務器庫並重新啓動服務器。

+0

我沒有使用rest api。對於使用Axis2的Web服務。 – Mahesh

+0

無論Web服務實現如何,如果您使用的不是基本servlet和jsp以外的任何技術,則必須將該庫提供給tomcat。這在錯誤消息中清楚地反映爲錯誤是ClassNotFoundException。 –

+0

我也一樣,因爲我正在使用SOAP ws,所以我們爲什麼要面對這個錯誤。有人嗎? –