【问题标题】:Webservices in Eclipse using Axis2: ClassNotFoundExceptionEclipse 中使用 Axis2 的 Web 服务:ClassNotFoundException
【发布时间】:2012-04-23 14:01:43
【问题描述】:

我一直在为 Eclipse 中的 Web 服务苦苦挣扎。 每次我得到一些东西,它似乎只是基于运气,我已经尝试了很多方法。

我的最新问题涉及以下内容: 我有一个使用大量外部引用(jar)的 java 应用程序。 我已经使用 Fat-jar 插件 (http://fjep.sourceforge.net/) 将这个 java 项目导出到一个简单的 jar 文件,以确保导出的 jar 包含所有需要的资源。 然后我创建了一个动态 Web 项目并将之前的 jar 添加到该项目中。 当我进行一些基本测试时,一切正常,即 Eclipse 会找到所有需要的引用。

但是,当我尝试创建一个 Web 服务时,它的方法使用与测试完全相同的逻辑,我得到了错误。 我不明白为什么会收到 ClassNotFoundException,因为就像我之前所说的,在进行本地测试时,Eclipse 会找到所有需要的资源。

[INFO] Deploying module: addressing-1.6.1 - file:/C:/Users/Flamant/My     master/code/WorkspaceEclipse/.metadata/.plugins/org.eclipse.wst.server.core/tmp3/wtpwebapps    /org.openmarkov.webservice.engine/WEB-INF/modules/addressing-1.6.1.mar
[INFO] Deploying module: metadataExchange-1.6.1 - file:/C:/Users/Flamant/My     master/code/WorkspaceEclipse/.metadata/.plugins/org.eclipse.wst.server.core/tmp3/wtpwebapps    /org.openmarkov.webservice.engine/WEB-INF/modules/mex-1.6.1.mar
[INFO] Deploying module: mtompolicy-1.6.1 - file:/C:/Users/Flamant/My     master/code/WorkspaceEclipse/.metadata/.plugins/org.eclipse.wst.server.core/tmp3/wtpwebapps    /org.openmarkov.webservice.engine/WEB-INF/modules/mtompolicy-1.6.1.mar
[INFO] Deploying module: ping-1.6.1 - file:/C:/Users/Flamant/My     master/code/WorkspaceEclipse/.metadata/.plugins/org.eclipse.wst.server.core/tmp3/wtpwebapps    /org.openmarkov.webservice.engine/WEB-INF/modules/ping-1.6.1.mar
[INFO] Deploying module: script-1.6.1 - file:/C:/Users/Flamant/My     master/code/WorkspaceEclipse/.metadata/.plugins/org.eclipse.wst.server.core/tmp3/wtpwebapps    /org.openmarkov.webservice.engine/WEB-INF/modules/scripting-1.6.1.mar
[INFO] Deploying module: soapmonitor-1.6.1 - file:/C:/Users/Flamant/My     master/code/WorkspaceEclipse/.metadata/.plugins/org.eclipse.wst.server.core/tmp3/wtpwebapps    /org.openmarkov.webservice.engine/WEB-INF/modules/soapmonitor-1.6.1.mar
[INFO] The Engine service, which is not valid, caused java.lang.NoClassDefFoundError:     [Lorg/openmarkov/webservice/Finding;
    at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.privateGetPublicMethods(Unknown Source)
at java.lang.Class.getMethods(Unknown Source)
at org.apache.axis2.description.java2wsdl.bytecode.MethodTable.loadMethods(MethodTable.java:43)
at org.apache.axis2.description.java2wsdl.bytecode.MethodTable.<init>(MethodTable.java:33)
at org.apache.axis2.description.java2wsdl.DefaultSchemaGenerator.<init>(DefaultSchemaGenerator.java:141)
at org.apache.axis2.deployment.util.Utils.fillAxisService(Utils.java:453)
at org.apache.axis2.deployment.ServiceBuilder.populateService(ServiceBuilder.java:389)
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:370)
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:1228)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1147)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1043)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4957)
at org.apache.catalina.core.StandardContext$3.call(StandardContext.java:5284)
at org.apache.catalina.core.StandardContext$3.call(StandardContext.java:5279)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.openmarkov.webservice.Finding
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1678)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1523)
... 34 more

[INFO] org.apache.axis2.deployment.DeploymentException: java.lang.NoClassDefFoundError:     [Lorg/openmarkov/webservice/Finding;
[INFO] Deploying Web service: version.aar - file:/C:/Users/Flamant/My master/code/WorkspaceEclipse/.metadata/.plugins/org.eclipse.wst.server.core/tmp3/wtpwebapps/org.openmarkov.webservice.engine/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!
apr 11, 2012 10:51:45 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8081"]
apr 11, 2012 10:51:45 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8010"]
apr 11, 2012 10:51:45 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 1928 ms

如果有人有想法,我将不胜感激。

谢谢, 托马斯

【问题讨论】:

  • 你是如何创建网络服务的?您使用的是哪个axis2版本?

标签: eclipse web-services axis2 noclassdeffounderror classnotfoundexception


【解决方案1】:

您的意思是在 Eclipse 环境中您的 Web 服务可以正常工作,但在您的动态 Web 项目中不能正常工作?动态 Web 项目中缺少 jar?

【讨论】:

  • 不,在动态 Web 项目中,我制作了一个“测试”包,我在其中调用导入的 .jar 文件中的方法。这些都工作正常。只有当我尝试创建一个 web 服务(从一个类,它使用与 test-package 中的测试完全相同的逻辑)时,才会发生错误。
  • 如果所有需要的 jar 都存在,请检查是否有 jar 冲突。
【解决方案2】:

实际上,您正面临 NoClassDefFoundError,当在运行时找不到所需的库时会发生这种情况...检查库是否在您的运行时类路径中..

【讨论】:

  • 感谢您的回复。我确实得出了同样的结论。但是,我仍然不知道如何解决这个问题。我已将所有需要的 .jar 和项目添加到:(1) lib 目录,(2) 属性中的 java 构建路径和 (3) 属性中的部署程序集。
  • 嗨,在你的运行时类路径中添加库...转到项目视图特定的类/项目右键单击-->运行方式-->运行配置-->在那里设置类路径(添加 jars那里)
【解决方案3】:

确保至少这些 激活1.1.jar, axiom-api-1.2.8.jar, 公理dom-1.2.8.jar, axiom-impl-1.2.8.jar, axis2-adb-1.5.1.jar, axis2-kernel-1.5.1.jar, axis2-transport-http-1.5.1.jar, axis2-transport-local-1.5.1.jar, commons-codec-1.3.jar, commons-fileupload-1.2.jar, commons-httpclient-3.1.jar, commons-logging-1.1.1.jar, geronimo-stax-api_1.0_spec-1.0.1.jar, httpcore-4.0.jar, 邮件1.4.jar, neethi-2.0.4.jar, woden-api-1.0M8.jar, woden-impl-dom-1.0M8.jar, wsdl4j-1.6.2.jar, wstx-asl-3.2.4.jar, XmlSchema-1.4.3.jar

【讨论】:

    【解决方案4】:

    我也遇到过这个问题。就我而言,我没有明确遵循[1] 文章中的步骤。在第 12 步中,不要更改“服务项目”名称。

    【讨论】:

    • 请在您的答案中添加更多细节,而不是引用外部链接。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-09
    • 1970-01-01
    • 2015-04-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多