我目前正在尝试将Web服务合并到我的应用程序中。我无权访问Web服务本身,但可以通过jar文件访问。以下是访问Web服务的代码:
import java.util.List;
import java.io.Serializable;
import java.lang.String;
import com.zf.fileviewing.connection.FVConnectData;
import com.zf.fileviewing.connection.FVConnector;
import java.net.URL;
public class CheckOutAxalant implements Serializable
{
private static final long serialVersionUID = 1L;
public List<String> CheckoutAxalant(String docCid)
{
List<String> fileNames;
String userId="";
FVConnectData fvData = new FVConnectData();
fvData.setWsKeyword("");
fvData.setWsUrl("");
FVConnector con = new FVConnector(fvData);
// get all filenames of document
try
{
fileNames = con.getAllFileNames(docCid, userId);
for (String value : fileNames)
{
System.out.println("filename: " + value);
}
return fileNames;
}
catch (Exception e)
{
System.out.println("ERROR: " + e.getMessage());
e.printStackTrace();
return null;
}
}
错误发生在该行:
FVConnectData fvData = new FVConnectData();
完整堆栈跟踪如下:
java.lang.NoClassDefFoundError: com/zf/fileviewing/connection/FVConnectData
at com.zf.proceed.service.checkout.CheckOutAxalant.<init>(CheckOutAxalant.java:15)
at com.zf.proceed.gui.ConversionsCreateNewConversion.<init>(ConversionsCreateNewConversion.java:41)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at com.sun.faces.mgbean.BeanBuilder.newBeanInstance(BeanBuilder.java:188)
at com.sun.faces.mgbean.BeanBuilder.build(BeanBuilder.java:102)
at com.sun.faces.mgbean.BeanManager.createAndPush(BeanManager.java:409)
at com.sun.faces.mgbean.BeanManager.create(BeanManager.java:269)
at com.sun.faces.el.ManagedBeanELResolver.resolveBean(ManagedBeanELResolver.java:244)
at com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:116)
at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
at org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:72)
at org.apache.el.parser.AstValue.getValue(AstValue.java:161)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:185)
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)
at javax.faces.component.UISelectItems.getValue(UISelectItems.java:129)
at org.primefaces.renderkit.InputRenderer.getSelectItems(InputRenderer.java:53)
at org.primefaces.component.selectonemenu.SelectOneMenuRenderer.encodeMarkup(SelectOneMenuRenderer.java:71)
at org.primefaces.component.selectonemenu.SelectOneMenuRenderer.encodeEnd(SelectOneMenuRenderer.java:65)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:312)
at com.sun.faces.renderkit.html_basic.GridRenderer.renderRow(GridRenderer.java:185)
at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:129)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
at org.primefaces.component.wizard.WizardRenderer.encodeCurrentStep(WizardRenderer.java:174)
at org.primefaces.component.wizard.WizardRenderer.encodeContent(WizardRenderer.java:204)
at org.primefaces.component.wizard.WizardRenderer.encodeMarkup(WizardRenderer.java:159)
at org.primefaces.component.wizard.WizardRenderer.encodeEnd(WizardRenderer.java:62)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1786)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:424)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:124)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
由于无法访问网络服务,我非常困惑于此。
另外,仅供参考,如果我运行相同的代码但将其改编为普通的Java应用程序,它就没有问题。
答案 0 :(得分:0)
这是一个类加载器问题:NoClassDefFoundError: com/zf/fileviewing/connection/FVConnectData
。
您确定所部署的应用程序中是否存在所有依赖项?首先查看FVConnectData
中的导入。
编辑:
对于用于webservice调用的JAR文件,请使用mvn install:install-file
目标。它将在本地存储库中安装工件并将其提供给MAven。然后,您可以将其添加到dependencies
部分的pom.xml中(提供groupdId,artifactId和版本)。
您可以通过调用mvn dependency:tree
来验证是否已将其添加到项目的依赖项中。
答案 1 :(得分:0)
您似乎需要将jar文件移动到客户端的默认服务器lib目录中。对于tomcat,它将是...\apache-tomcat-7.0.81\lib
请查看 java.lang.NoClassDefFoundError了解详情。