java.lang.NoClassDefFoundError:org / apache / commons / discovery / tools / DiscoverSingleton

我用jsf在jsp文件中创建了一个注册表单,我尝试将它与Web服务连接,以便将这些元素传递给数据库。

当我按下提交按钮时,我收到一个错误。 我不认为问题涉及连接代码,但我不确定。

谁能告诉我一些可能在某种程度上对我有帮助的事情?

错误:

javax.servlet.ServletException: #{formabean.submitdetails}: java.lang.NoClassDefFoundError: org/apache/commons/discovery/tools/DiscoverSingleton javax.faces.webapp.FacesServlet.service(FacesServlet.java:256) org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390) 

我的formsjsp:

         Form   


.............

我的Bean类“formavar”:

 package org.forma; import org.imigrant.Migration.MigrationResult; import org.imigrant.Migration.MigrationWS_PortType; import org.imigrant.Migration.MigrationWS_Service; import org.imigrant.Migration.MigrationWS_ServiceLocator; /** libraries for Web Service*/ /** * * @author USER */ public class formavar { private String name; private String lastname;..... public String getName() { return name; } /** * @param name the name to set */ public void setName(String name) { this.name = name; } /** * @return the surname */ public String getLastname() { return lastname; } /** * @param surname the surname to set */ public void setLastname(String lastname) { this.lastname = lastname; }...... public String submitdetails() { String migrationURL = "http://localhost:8080/mule-tomcat/ESB/Migration?wsdl"; MigrationResult registrationResult = new MigrationResult(); try { MigrationWS_Service service = new MigrationWS_ServiceLocator(migrationURL); MigrationWS_PortType port = service.getMigrationImplPort(); registrationResult = port.registerDoc( null, this.granting, this.expire_date, this.name, this.lastname,............. ); return "OK"; } catch (Exception ex) { return "ERROR "+ex.getMessage(); } //return "OK"; } } 

和配置xml:

   formabean org.forma.formavar request  

java.lang.NoClassDefFoundError:org / apache / commons / discovery / tools / DiscoverSingleton

这只是意味着webapp的运行时类路径中缺少所提到的类(或包含该类的JAR文件)。

正如包名称提示,该类是Apache Commons Discovery的一部分,可从http://commons.apache.org/discovery下载。 如果您只是将其JAR文件放在webapp的/WEB-INF/lib中(由webapp的运行时类路径覆盖),则此错误应该消失。

请注意,此问题与JSF / JSP 无关 ,更不用说Java EE了。 它只是基本的Java。 exception的根本原因也暗示; 它是java.lang包的。

执行测试时,项目类路径中缺少指定的类。

解决方案是将以下依赖项添加到您的pom:

  commons-discovery commons-discovery 0.5 test