创建Web服务时tomcat出错

时间:2013-11-27 13:44:11

标签: java web-services tomcat7 axis2 eclipse-juno

我通过在eclipse juno中使用Axis 2使用自下而上的方法创建了两个数字Web服务的简单添加.Web服务正常工作并且通过soa客户端mozilla扩展正确测试但是tomcat中存在错误。请通过以下错误< / p>

计算器服务无效,导致

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!

2 个答案:

答案 0 :(得分:2)

Tomcat只是一个servlet容器和AFAIK,默认情况下它不支持任何类型的Web服务。

您必须在WEB-INF / lib中拥有所需的库,或将其添加到tomcat lib文件夹并使用它。

你得到ClassNotFoundException,因为在类路径中找不到javax / ws / rs / Produces。

将REST实现(例如:Jersey)部署到服务器lib并重新启动服务器。

答案 1 :(得分:0)

尝试删除Axis2服务类中的注释。在我们的案例中,删除@Deprecated解决了该错误。