CUBA Reports jsoup in Groovy

Hello, I created a groovy-based dataset which invokes a bean. When I run the report, i get the following error message:

11:19:26.736 ERROR [http-nio-8080-exec-77/app-core/admin] com.haulmont.cuba.core.sys.ServiceInterceptor - Invoking String com.company.flux.service.GenevaService.ConnectToGeneva(String,Integer,String,String) from another service
11:19:27.921 DEBUG [scheduler-4] com.haulmont.cuba.core.app.LockManager - Expiring locks
11:19:31.817 WARN  [http-nio-8080-exec-77/app-core/admin] com.haulmont.cuba.core.sys.ServiceInterceptor - Open transaction left in GenevaService.ConnectToGeneva(..)
11:19:31.831 ERROR [http-nio-8080-exec-77/app-core/admin] com.haulmont.cuba.core.sys.ServiceInterceptor - Invoking String com.company.flux.service.GenevaService.executeGSQL(String,String) from another service
11:19:32.968 INFO  [http-nio-8080-exec-77/app-core/admin] com.company.flux.service.GenevaServiceBean - Invoking executeGSQL...
11:19:34.704 WARN  [http-nio-8080-exec-77/app-core/admin] com.haulmont.cuba.core.sys.ServiceInterceptor - Open transaction left in GenevaService.executeGSQL(..)
11:19:34.717 ERROR [http-nio-8080-exec-77/app-core/admin] com.haulmont.cuba.core.sys.ServiceInterceptor - Invoking List com.company.flux.service.GenevaService.getGenevaOutput(String) from another service
11:19:35.282 ERROR [http-nio-8080-exec-77/app-core/admin] com.haulmont.cuba.core.sys.ServiceInterceptor - Exception: 
java.lang.NoSuchMethodError: org.jsoup.select.Elements.get(I)Lorg/jsoup/nodes/Element;
	at com.company.flux.service.GenevaServiceBean.getGenevaOutput(GenevaServiceBean.java:937) ~[app-core-0.1-SNAPSHOT.jar:na]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_65]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_65]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_65]
	at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_65]
	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302) [spring-aop-4.2.0.RELEASE.jar:4.2.0.RELEASE]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) [spring-aop-4.2.0.RELEASE.jar:4.2.0.RELEASE]

Now, the error refers to jsoup. When I re-assemble the project and redeploy, sometimes the report runs and sometimes it doesn’t. By re-assembling and deploying, I get lucky half the time. I know that jsoup is included at the web tier but I wonder why I’m getting those errors on the middle tier (in my bean).

thanks.

Hi Francis,
You mention that Jsoup is included at web tier - does it mean that it is defined as dependency for web module?
Report queries are executed on the middle tier, so you should add your libraries as dependencies of the core module.

And look at the first error message in your log: “Invoking … from another service”. It probably does not cause problems in this case, but better use regular managed beans instead of services when calling code from inside middleware. See warning here: Creating a Service - CUBA Platform. Developer’s Manual

sorry Jsoup is not included in the web tier. I now created a managed bean and this is where I reference Jsoup. and it’s giving me the error above. When i run the same code from a console app, it runs fine so something is telling me that it’s either not using the correct version of jsoup or that i need to reference my version somewhere.

Here’s my code:

for(int i = 0; i < data.size(); i++)
        {
            HashMap<String,Object> record = new HashMap<>();
            StringBuilder sb = new StringBuilder();
            Elements nodeData = data.get(i).children();
            for(Element node : nodeData)
            {
                String nodeValue = node.text();
                String nodename = node.nodeName();
                record.put(nodename,nodeValue);
            }
            result.add(record);
        }

and it generates the error at the line: Elements nodeData = data.get(i).children();

Please check that you have only one Jsoup JAR in tomcat/shared/lib and this is the version that you specified in dependencies.