SANN3
SANN3

Reputation: 10099

No implementation of method error when running lein-rpm task

From my clojure project I am creating jar with lein uberjar, the jar is working fine locally.

Then I am creating a rpm via lein-rpm task and then I am deploying the rpm to the server.

After deploying rpm, I am trying to run it with java -jar, but the service starts to give following exception.

java.lang.IllegalArgumentException: No implementation of method: :route-matches of protocol: #'clout.core/Route found for class: clout.core.CompiledRoute
        at clojure.core$_cache_protocol_fn.invokeStatic(core_deftype.clj:566) ~[na:na]
        at clojure.core$_cache_protocol_fn.invoke(core_deftype.clj:560) ~[na:na]
        at clout.core$eval5959$fn__5960$G__5950__5967.invoke(core.clj:39) ~[na:na]
        at compojure.core$route_matches.invokeStatic(core.clj:46) ~[na:na]
        at compojure.core$route_matches.invoke(core.clj:44) ~[na:na]
        at compojure.core$route_request.invokeStatic(core.clj:49) ~[na:na]
        at compojure.core$route_request.invoke(core.clj:48) ~[na:na]
        at compojure.core$wrap_route_matches$fn__6362.invoke(core.clj:145) ~[na:na]
        at compojure.core$wrap_routes$fn__6478.invoke(core.clj:348) ~[na:na]
        at compojure.api.routes.Route.invoke(routes.clj:74) [na:na]
        at compojure.api.core$handle$fn__17370.invoke(core.clj:8) ~[na:na]
        at clojure.core$some.invokeStatic(core.clj:2592) [na:na]
        at clojure.core$some.invoke(core.clj:2583) [na:na]
        at compojure.api.core$handle.invokeStatic(core.clj:8) ~[na:na]
        at compojure.api.core$handle.invoke(core.clj:7) ~[na:na]
        at clojure.core$partial$fn__533.invoke(core.clj:2515) ~[na:na]
        at compojure.api.routes.Route.invoke(routes.clj:74) [na:na]
        at ring.swagger.middleware$wrap_swagger_data$fn__14534.invoke(middleware.clj:33) ~[na:na]
        at ring.middleware.http_response$wrap_http_response$fn__11869.invoke(http_response.clj:19) ~[na:na]
        at ring.swagger.middleware$wrap_swagger_data$fn__14534.invoke(middleware.clj:33) ~[na:na]
        at compojure.api.middleware$wrap_options$fn__15814.invoke(middleware.clj:74) [na:na]
        at ring.middleware.format_params$wrap_format_params$fn__10747.invoke(format_params.clj:119) ~[na:na]
        at ring.middleware.format_params$wrap_format_params$fn__10747.invoke(format_params.clj:119) ~[na:na]
        at ring.middleware.format_params$wrap_format_params$fn__10747.invoke(format_params.clj:119) ~[na:na]
        at ring.middleware.format_params$wrap_format_params$fn__10747.invoke(format_params.clj:119) ~[na:na]
        at ring.middleware.format_params$wrap_format_params$fn__10747.invoke(format_params.clj:119) ~[na:na]
        at compojure.api.middleware$wrap_exceptions$fn__15804.invoke(middleware.clj:43) ~[na:na]
        at ring.middleware.format_response$wrap_format_response$fn__11767.invoke(format_response.clj:183) [na:na]
        at ring.middleware.keyword_params$wrap_keyword_params$fn__11907.invoke(keyword_params.clj:36) [na:na]
        at ring.middleware.nested_params$wrap_nested_params$fn__11955.invoke(nested_params.clj:89) [na:na]
        at ring.middleware.params$wrap_params$fn__12029.invoke(params.clj:67) [na:na]
        at compojure.api.middleware$wrap_options$fn__15814.invoke(middleware.clj:74) [na:na]
        at compojure.api.routes.Route.invoke(routes.clj:74) [na:na]
        at clojure.lang.Var.invoke(Var.java:379) [supply-planning-api-service-standalone.jar:na]
        at compojure.core$routing$fn__6377.invoke(core.clj:185) [na:na]
        at clojure.core$some.invokeStatic(core.clj:2592) [na:na]
        at clojure.core$some.invoke(core.clj:2583) [na:na]
        at compojure.core$routing.invokeStatic(core.clj:185) [na:na]
        at compojure.core$routing.doInvoke(core.clj:182) [na:na]

Lib and Environment Details

lein-rpm - 0.0.5

OS - CentOS Linux 7

What am I missing?

Edit :

As per @Mrinal's comment I checked the jar size before and after rpm build. If we extract the jar from rpm the size was little less than the original.

Upvotes: 4

Views: 107

Answers (1)

Mrinal Saurabh
Mrinal Saurabh

Reputation: 978

I had this exact same problem. Took two days to solve.

So if you see the jar size generated by lein uberjar and the lein rpm task, they will be different. The culprit is brp-java-repack-jars which packs and repacks the jar during rpm builds. To see the option you need to run rpm -E '%{__os_install_post}' on the terminal, you will see something like:

/usr/lib/rpm/redhat/brp-compress 
/usr/lib/rpm/redhat/brp-strip /usr/bin/strip 
/usr/lib/rpm/redhat/brp-strip-comment-note /usr/bin/strip /usr/bin/objdump 
/usr/lib/rpm/redhat/brp-strip-static-archive /usr/bin/strip 
/usr/lib/rpm/brp-python-bytecompile /usr/bin/python 1 
/usr/lib/rpm/redhat/brp-python-hardlink 
/usr/lib/rpm/redhat/brp-java-repack-jars

The last one is the problem as it messes with the jar created by lein uberjar. To get rid of the problem we have to disable the __os_install_post option during rpm create. This blog explains it very nicely.

What we did was, removed the rpm step and copy the .jar package created by lein uberjar step directly to the server and run it. But we have tried this other option and it works as well.

Hope this helps. Ping in comments for any doubts.

Upvotes: 4

Related Questions