1

我一直在为 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

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

谢谢,托马斯

4

4 回答 4

1

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

于 2012-04-11T15:00:59.600 回答
0

确保至少有这些activation-1.1.jar、axiom-api-1.2.8.jar、axiom-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、mail-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

于 2013-09-01T14:16:19.363 回答
0

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

于 2014-03-02T11:28:28.037 回答
0

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

于 2012-04-11T09:24:09.363 回答