我正在尝试从Grails上的Web服务运行GEB,因为我需要从页面中提取数据并在我的应用程序中使用它。 服务器用于废弃信息,然后将其返回到视图中。
如果我从grails控制台运行它可以正常工作但是当我从服务运行它时它不起作用
这是代码
package com.bamboozled
import geb.Browser
import grails.transaction.Transactional
@Transactional
class ScraperService {
Data scrapIt(String nombreCiclo, String numeroSolicitud) {
//Variable con los datos a retornar
def d = new Data()
//Inicia el bot
Browser.drive {
go "http://some.page/page.php"
$("form").ciclo = nombreCiclo
$("form").nosol = numeroSolicitud
$("form").find("input", name: "BOTONACEPTAR").click()
def a = getAvailableWindows()
def data = [" "," "," "," "," "]
withWindow(a[1]) {
data[0] = $("td")[5].text()
data[1] = $("td")[6].text()
data[2] = $("td")[7].text()
data[3] = $("td")[8].text()
data[4] = $("td")[9].text()
}
d.numeroSolicitud = data[0]
d.avance = data[1]
d.seEncuentraEn = data[2]
d.numeroCheque = data[3]
d.cheque = data[4]
}
return d
}
}
这是我称之为的控制器
package com.bamboozled
class DataController {
static scaffold = true
def ScraperService
def index() { }
def form() {
}
def consulta(){
def p = Ciclo.findAll()
[solicitudes : p]
}
def resultados() {
def d = ScraperService.scrapIt(params.nombreCiclo, params.numeroSolicitud)
[res : d]
}
}
当我运行它时会出现此错误
URI
/bamboozled/data/resultados
Class
java.lang.NoClassDefFoundError
Message
geb/Browser
Around line 200 of PageFragmentCachingFilter.java
197: if (CollectionUtils.isEmpty(cacheOperations)) {
198: log.debug("No cacheable annotation found for {}:{} {}",
199: new Object[] { request.getMethod(), request.getRequestURI(), getContext() });
200: chain.doFilter(request, response);
201: return;
202: }
203:
Around line 63 of AbstractFilter.java
60: try {
61: // NO_FILTER set for RequestDispatcher forwards to avoid double gzipping
62: if (filterNotDisabled(request)) {
63: doFilter(request, response, chain);
64: }
65: else {
66: chain.doFilter(req, res);
Around line 17 of grails-app/services/com/bamboozled/ScraperService.groovy
14: def d = new Data()
15:
16: //Inicia el bot
17: Browser.drive {
18:
19: go "http://http://some.page/page.php"
20:
Around line 20 of grails-app/controllers/com/bamboozled/DataController.groovy
17: }
18:
19: def resultados() {
20: def d = ScraperService.scrapIt(params.nombreCiclo, params.numeroSolicitud)
21: [res : d]
22: }
23:
Trace
Line | Method
->> 200 | doFilter in PageFragmentCachingFilter.java
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 63 | doFilter in AbstractFilter.java
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 748 | run . . . in java.lang.Thread
Caused by ControllerExecutionException: Runtime error executing action
->> 200 | doFilter in PageFragmentCachingFilter.java
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 63 | doFilter in AbstractFilter.java
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 748 | run . . . in java.lang.Thread
Caused by InvocationTargetException: null
->> 200 | doFilter in PageFragmentCachingFilter.java
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 63 | doFilter in AbstractFilter.java
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 748 | run . . . in java.lang.Thread
Caused by NoClassDefFoundError: geb/Browser
->> 17 | $tt__scrapIt in ScraperService.groovy
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 20 | resultados in DataController.groovy
| 200 | doFilter in PageFragmentCachingFilter.java
| 63 | doFilter in AbstractFilter.java
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 748 | run . . . in java.lang.Thread
我知道如何让它运行?