2011-10-06 12 views
15

jspでjspファイルに登録フォームを作成し、これを要素に渡すためにWebサービスに接続しようとします。データベース。java.lang.NoClassDefFoundError:org/apache/commons/discovery/tools/DiscoverSingleton

送信ボタンを押すとエラーになります。問題は接続コードに関係しているとは思えませんが、わかりません。

誰かが私に多分何らかの形で役立つ何かを教えてもらえますか?

エラー:

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) 

私のフォームのjsp:

<%@page contentType="text/html" pageEncoding="UTF-8"%> 

<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%> 
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%> 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
    "http://www.w3.org/TR/html4/loose.dtd"> 

<f:view> 
    <html> 
     <head> 
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> 
      <title>Form</title> 
     </head> 
     <body> 
      <div align="right" > 
       <p> 
        <br>............. 
<h:commandButton value="submit" type="submit" 
           action="#{formabean.submitdetails}" /> 


      </h:form> 

     </body> 
    </html> 
</f:view> 

私の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:

<managed-bean> 
     <managed-bean-name>formabean</managed-bean-name> 
     <managed-bean-class>org.forma.formavar</managed-bean-class> 
     <managed-bean-scope>request</managed-bean-scope> 
    </managed-bean> 
+1

BalusC答えが正解です。コンパイル中ではなく、デプロイ後にエラーが発生しているように見えます。私には、これはあなたがApacheのコモンズ検出ジャーを持っているが、あなたのアプリケーションと共にそれを配備していないことを示しています。 warファイルを構築する場合は、/ WEB-INF/libディレクトリ(war内)に配置することで、検出Jarをランタイムクラスパスに置くことができます。 – DwB

答えて

17

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

これは、前述のクラス(またはクラスを含むJARファイル)がWebアプリケーションのランタイムクラスパスに存在しないことを意味します。

パッケージ名のヒントとして、クラスはApache Commons Discoveryの一部であり、http://commons.apache.org/discoveryからダウンロードできます。あなたのwebappの/WEB-INF/lib(webappのランタイムクラスパスでカバーされている)にそのJARファイルをドロップするだけなら、このエラーは消えるはずです。

この問題は、はありません。は、Java EEではなく、JSF/JSPとは関係ありません。それはちょうど基本的なJavaです。例外の根本的な原因は、そのことをも示唆している。それはjava.langパッケージです。

11

指定されたクラスは、テストの実行時にプロジェクトのクラスパスから欠落しています。

ソリューションは、あなたのポンポンに次の依存関係を追加することです:

<dependency> 
    <groupId>commons-discovery</groupId> 
    <artifactId>commons-discovery</artifactId> 
    <version>0.5</version> 
    <scope>test</scope> 
</dependency> 
+0

があなたのポンポンに追加します。 \t \t コモンズ発見 \t コモンズ発見を \t \t 0.5 \t \t テスト Fadid

+0

あなたは私の問題を解決しました!ありがとう! – hbobenicio