web服务中的selenium引发java.lang.NoClassDefFoundError异常

web服务中的selenium引发java.lang.NoClassDefFoundError异常,java,web-services,selenium,webserver,selenium-webdriver,Java,Web Services,Selenium,Webserver,Selenium Webdriver,我创建了一个动态web项目,实现了一个在其中使用selenium的函数,在项目的构建路径中添加了selenium-server-standalone-2.32.0.jar,然后使用向导生成web服务器和客户端。它弹出了一条警告,内容如下: The service class "test.eko3.TestEko3" does not comply to one or more requirements of the JAX-RPC 1.1 specification, and may not d

我创建了一个动态web项目,实现了一个在其中使用selenium的函数,在项目的构建路径中添加了selenium-server-standalone-2.32.0.jar,然后使用向导生成web服务器和客户端。它弹出了一条警告,内容如下:

The service class "test.eko3.TestEko3" does not comply to one or more requirements of the JAX-RPC 1.1 specification, and may not deploy or function correctly.
The value type "org.openqa.selenium.WebDriver" used via the service class "test.eko3.TestEko3" does not have a public default constructor. Chapter 5.4 of the JAX-RPC 1.1 specification requires a value type to have a public default constructor, otherwise a JAX-RPC 1.1 compliant Web service engine may be unable to construct an instance of the value type during deserialization.
The field or property "windowHandles" on the value type "org.openqa.selenium.WebDriver" used via the service class "test.eko3.TestEko3" has a data type, "java.util.Set", that is not supported by the JAX-RPC 1.1 specification. Instances of the type may not serialize or deserialize correctly. Loss of data or complete failure of the Web service may result.
我点击ok,它继续生成服务器和客户端。当它完成时,我尝试从客户端测试它,它在结果视图中显示此异常:

Exception: java.lang.NoClassDefFoundError: org/openqa/selenium/WebDriver; nested exception is: java.lang.NoClassDefFoundError: org/openqa/selenium/WebDriver Message: java.lang.NoClassDefFoundError: org/openqa/selenium/WebDriver; nested exception is: java.lang.NoClassDefFoundError: org/openqa/selenium/WebDriver
然后,我将相同的jar文件添加到WEB-INF/lib文件夹中,并再次运行它,但它显示了相同的异常。还有其他地方需要我把罐子放进去吗?任何帮助都将不胜感激

服务器的代码如下所示:

package test.eko3;

import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.Wait;
import org.openqa.selenium.support.ui.WebDriverWait;

public class TestEko3 {
public String Ekobilet(String from, String to, String date) {

    //Firefox browser instantiation
    WebDriver driver = new FirefoxDriver();

    //Loading the URL
    driver.get("http://www.amadeusepower.com/trek/portals/trek/default.aspx?Culture=en-US");


    WebElement radioOneway = driver.findElement(By.id("ctl00_ctl00_ctl00_cph1_cph1_QuickSearchAll1_QuickFlightSearchControl1_rbFlightType_1"));
    radioOneway.click();

    waitForPageLoaded(driver);


    WebElement fromText = driver.findElement(By.id("ctl00_ctl00_ctl00_cph1_cph1_QuickSearchAll1_QuickFlightSearchControl1_txtSearch_txtFrom"));
    fromText.clear();
    fromText.sendKeys(from); 


    WebElement toText = driver.findElement(By.id("ctl00_ctl00_ctl00_cph1_cph1_QuickSearchAll1_QuickFlightSearchControl1_txtSearch_txtTo"));
    toText.sendKeys(to); 


    WebElement dateText = driver.findElement(By.id("ctl00_ctl00_ctl00_cph1_cph1_QuickSearchAll1_QuickFlightSearchControl1_txtDepartureDate_txtDate"));
    dateText.sendKeys(date); 

    //Sign in button identification and click it
    WebElement searchbutton = driver.findElement(By.id("ctl00_ctl00_ctl00_cph1_cph1_QuickSearchAll1_QuickFlightSearchControl1_btnSearch"));
    searchbutton.click();

    String page = driver.getPageSource();


    //Closing the browser
    driver.close();

    return page;

    }

    public static void waitForPageLoaded(WebDriver driver) {

        ExpectedCondition<Boolean> expectation = new
    ExpectedCondition<Boolean>() {
           public Boolean apply(WebDriver driver) {
             return ((JavascriptExecutor)driver).executeScript("return document.readyState").equals("complete");
           }
         };

        Wait<WebDriver> wait = new WebDriverWait(driver,30);
         try {
                 wait.until(expectation);
         } catch(Throwable error) {
                 System.out.println("exception yavrum");
         }
    } 

}
package test.eko3;
导入org.openqa.selenium.By;
导入org.openqa.selenium.JavascriptExecutor;
导入org.openqa.selenium.WebDriver;
导入org.openqa.selenium.WebElement;
导入org.openqa.selenium.firefox.FirefoxDriver;
导入org.openqa.selenium.support.ui.ExpectedCondition;
导入org.openqa.selenium.support.ui.Wait;
导入org.openqa.selenium.support.ui.WebDriverWait;
公共类测试3{
公共字符串Ekobilet(字符串开始、字符串结束、字符串日期){
//Firefox浏览器实例化
WebDriver=newfirefoxdriver();
//加载URL
驱动程序。获取(“http://www.amadeusepower.com/trek/portals/trek/default.aspx?Culture=en-美国);
WebElement radioOneway=driver.findElement(By.id(“ctl00_ctl00_ctl00_cph1_cph1_快速搜索控制1_rbflightSearchControl1”);
radioOneway.click();
waitForPageLoaded(驱动程序);
WebElement fromText=driver.findElement(By.id(“ctl00\u ctl00\u ctl00\u cph1\u cph1\u快速搜索控制1\u txtSearch\u txtFrom”);
fromText.clear();
fromText.sendKeys(from);
WebElement toText=driver.findElement(By.id(“ctl00\u ctl00\u ctl00\u cph1\u cph1\u快速搜索控制1\u txtSearch\u txtTo”);
toText.sendKeys(到);
WebElement dateText=driver.findElement(By.id(“ctl00_ctl00_ctl00_cph1_cph1_QuickSearchControl1_QuickFlightSearchControl1_txtDepartureDate_txtDate”);
dateText.sendKeys(日期);
//登录按钮标识并单击它
WebElement searchbutton=driver.findelelement(By.id(“ctl00_ctl00_ctl00_cph1_cph1_QuickSearchControl1_btnSearch”);
搜索按钮。单击();
String page=driver.getPageSource();
//关闭浏览器
driver.close();
返回页面;
}
公共静态无效waitForPageLoaded(WebDriver驱动程序){
预期条件预期=新
期望条件(){
公共布尔应用(WebDriver驱动程序){
return((JavascriptExecutor)driver.executeScript(“return document.readyState”).equals(“complete”);
}
};
Wait Wait=newwebdriverwait(驱动程序,30);
试一试{
等待,直到(期望);
}捕获(可丢弃错误){
System.out.println(“异常yavrum”);
}
} 
}

可能您正在使用selenium单机版jar,这对java中的动态web项目不太好。参见

@JunedAhsan我在问题中添加了代码。