Question

I have a problem with link those two things - Apache Mahout and Java Web Application Integration.

I use standard Java Web Application Maven project and Jersey 2.4 to build my webservice. My application server is Apache Tomcat 7.

When I run this project without Mahout and try:

curl -i -H "Accept: application/json" -H "Content-Type: application/json" 'http://myhost:8089/ensembleRestApi/recommeng/algorithm/articleCore/cf?limit=5'

I got response and also can go through source code (with debugger)

But when I add Mahot dependency to my pom.xml file:

<dependency>
    <groupId>org.apache.mahout</groupId>
    <artifactId>mahout-core</artifactId>
    <version>0.9</version>
</dependency> 

And try to do the same curl command, I got this AbstractMethodError yet before breakpoint in webservice method is invocated in my source code:

Do you know where is the problem please?

SEVERE: Servlet.service() for servlet [jersey-serlvet] in context with path     [/ensembleRestApi] threw exception [Servlet execution threw an exception] with root cause
java.lang.AbstractMethodError:     javax.ws.rs.core.UriBuilder.uri(Ljava/lang/String;)Ljavax/ws/rs/core/UriBuilder;
at javax.ws.rs.core.UriBuilder.fromUri(UriBuilder.java:119)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:286)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:218)
at    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Was it helpful?

Solution

Ok, so if somebody will fight with the same thing, remember that this exception is because of:

Thrown when an application tries to call an abstract method. Normally, this error is caught by the compiler; this error can only occur at run time if the definition of some class has incompatibly changed since the currently executing method was last compiled. by Oracle

This means that you have some conflicts in libraries (which are in dependencies)

So I tried to downgrade my mahout-core library version and with version 0.7 everything works fine.

OTHER TIPS

I just encountered the same problem, and it's because of a conflict in Jersey versions. For my endpoints, I'm using Jersey 2.14. But Mahout 0.9 depends on hadoop-core 1.2.1, which has several Jersey 1.8 dependencies. The AbstractMethodError is caused because your endpoint is using a Jersey 1.8 class which does not have this method defined.

Exclude all the com.sun.jersey dependencies from your pom.xml...Here I'm using gradle:

compile ('org.apache.mahout:mahout-integration:0.11.1'){
    exclude group: 'com.sun.jersey'
}

In eclipse you can go to your 'Maven Dependencies' folder in your project -> right click-> 'Maven' ->'Exclude Maven Artifact...' for all the 'jersey1.xxx' dependencies and the exclusions will be added in your pom.xml file

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top