You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jclouds.apache.org by Max Countryman <ma...@me.com> on 2013/09/08 04:12:56 UTC

Trouble compiling JClouds with Clojure

Hi all,

I am attempting to compile a jar via leiningen's uberjar command that uses JCloud's org.jclouds.blobstore2.

The trouble I'm running into is that it seems the providers list isn't populated. Interestingly this works fine from the repl, but the compiled jar throws this error:

Exception in thread "main" java.util.NoSuchElementException: key [cloudfiles-us] not in the list of providers or apis: {providers=[hpcloud-objectstorage], apis=[atmos]}
	at org.jclouds.ContextBuilder.newBuilder(ContextBuilder.java:178)
	at org.jclouds.blobstore2$blobstore.doInvoke(blobstore2.clj:103)
	at clojure.lang.RestFn.invoke(RestFn.java:445)
	at stint_uploader.core$_main.invoke(core.clj:40)
	at clojure.lang.AFn.applyToHelper(AFn.java:159)
	at clojure.lang.AFn.applyTo(AFn.java:151)
	at stint_uploader.core.main(Unknown Source)

Here's a simple example:

(ns my-app.core
  (:require [org.jclouds.blobstore2 :refer :all])
  (:gen-class))

(defn -main []
  (blobstore "cloudfiles-us" "foo" "bar"))

And the project.clj would look something like:

(defproject my-app "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.4.0"]
                 [org.clojure/tools.logging "0.2.3"]
                 [org.clojure/core.incubator "0.1.0"]
                 [org.jclouds/jclouds-allblobstore "1.6.0"]]
  :main my-app.core)

Any advice is greatly appreciated,

Thanks,


Max

Re: Trouble compiling JClouds with Clojure

Posted by Andrew Phillips <an...@apache.org>.
Thanks, Paolo!

@Max: if you're using Gradle or other build tools, this might help too:

http://java.dzone.com/articles/jar-deps-dont-meta

ap

Re: Trouble compiling JClouds with Clojure

Posted by Max Countryman <ma...@me.com>.
Yes this would definitely work…if I ever get serious about deploying this I may have to do that. Thanks again for the useful feedback!


On Sep 9, 2013, at 3:46 PM, Andrew Phillips <an...@apache.org> wrote:

>> But it does seem like this is the problem so for the time being I  may have to give up trying to build with Leiningen.
> 
> If you know what your dependency set is for the time being, you could always go the *really* ugly way and create your *own*, pre-merged *Metadata files and ensure they're the ones that get packaged in your final über-JAR..?
> 
> ap
> 
> PS: It hurt a little to write that, but it should work... ;-)


Re: Trouble compiling JClouds with Clojure

Posted by Andrew Phillips <an...@apache.org>.
> But it does seem like this is the problem so for the time being I   
> may have to give up trying to build with Leiningen.

If you know what your dependency set is for the time being, you could  
always go the *really* ugly way and create your *own*, pre-merged  
*Metadata files and ensure they're the ones that get packaged in your  
final über-JAR..?

ap

PS: It hurt a little to write that, but it should work... ;-)

Re: Trouble compiling JClouds with Clojure

Posted by Max Countryman <ma...@me.com>.
Hi Paolo,

Thank for the reply, this is very helpful!

Unfortunately it seems like there may not be a sane way to do this currently with Leiningen: https://github.com/technomancy/leiningen/issues/973

But it does seem like this is the problem so for the time being I may have to give up trying to build with Leiningen.


Max

On Sep 8, 2013, at 5:43 AM, Paolo Viotti <pa...@eurecom.fr> wrote:

> Hello,
> 
> recently I had the same problem with Java and Maven.
> The root cause was that in the created uber-jar the files "org.jclouds.apis.ApiMetadata" "org.jclouds.providers.ProviderMetadata" located in /META-INF/services didn't contain all the API/Provider ids.
> So I had to tell Maven to merge those metadata files present in each of the providers' jar into one single file in the uber-jar, instead of just overwriting them.
> 
> This, with Maven, can be accomplished in two ways:
> using the maven assembly plugin: with a configuration file in which you specify the metaInf-services handler (e.g. like this)
> using the maven shade plugin: with a "ServicesResourceTransformer"
> 
> Hope this helps,
> Paolo
> 
> 
> 
> On 08/09/2013 06:46, Max Countryman wrote:
>> Hi Everett,
>> 
>> Thanks for the quick response. I've tried updating to 1.6.2-incubating but still seem to receive the same error.
>> 
>> From inside the compiled jar I tried calling:
>> 
>> (clojure.pprint/pprint (.getURLs (java.lang.ClassLoader/getSystemClassLoader))).
>> 
>> This was the result:
>> 
>> [#<URL file:/Users/max/Documents/projects/my-app/target/my-app-0.1.0-SNAPSHOT-standalone.jar>]
>> 
>> I'm wondering if this could have something to do with AOT complication given that it works fine from the repl?
>> 
>> Thanks,
>> 
>> 
>> Max
>> 
>> On Sep 7, 2013, at 7:28 PM, Everett Toews <ev...@RACKSPACE.COM> wrote:
>> 
>>> It means that the cloudfiles-us JAR isn't contained on your classpath. Although [org.jclouds/jclouds-allblobstore "1.6.0"] should contain it. Can you list your classpath from within your app or see what leiningen is using for the classpath?
>>> 
>>> You might also want to try [org.apache.jclouds/jclouds-allblobstore "1.6.2-incubating"] as that's our most recent release.
>>> 
>>> HTH,
>>> Everett
>>> 
>>> 
>>> On Sep 7, 2013, at 9:12 PM, Max Countryman wrote:
>>> 
>>>> Hi all,
>>>> 
>>>> I am attempting to compile a jar via leiningen's uberjar command that uses JCloud's org.jclouds.blobstore2.
>>>> 
>>>> The trouble I'm running into is that it seems the providers list isn't populated. Interestingly this works fine from the repl, but the compiled jar throws this error:
>>>> 
>>>> Exception in thread "main" java.util.NoSuchElementException: key [cloudfiles-us] not in the list of providers or apis: {providers=[hpcloud-objectstorage], apis=[atmos]}
>>>> 	at org.jclouds.ContextBuilder.newBuilder(ContextBuilder.java:178)
>>>> 	at org.jclouds.blobstore2$blobstore.doInvoke(blobstore2.clj:103)
>>>> 	at clojure.lang.RestFn.invoke(RestFn.java:445)
>>>> 	at stint_uploader.core$_main.invoke(core.clj:40)
>>>> 	at clojure.lang.AFn.applyToHelper(AFn.java:159)
>>>> 	at clojure.lang.AFn.applyTo(AFn.java:151)
>>>> 	at stint_uploader.core.main(Unknown Source)
>>>> 
>>>> Here's a simple example:
>>>> 
>>>> (ns my-app.core
>>>> (:require [org.jclouds.blobstore2 :refer :all])
>>>> (:gen-class))
>>>> 
>>>> (defn -main []
>>>> (blobstore "cloudfiles-us" "foo" "bar"))
>>>> 
>>>> And the project.clj would look something like:
>>>> 
>>>> (defproject my-app "0.1.0-SNAPSHOT"
>>>> :description "FIXME: write description"
>>>> :url "http://example.com/FIXME"
>>>> :license {:name "Eclipse Public License"
>>>>           :url "http://www.eclipse.org/legal/epl-v10.html"}
>>>> :dependencies [[org.clojure/clojure "1.4.0"]
>>>>                [org.clojure/tools.logging "0.2.3"]
>>>>                [org.clojure/core.incubator "0.1.0"]
>>>>                [org.jclouds/jclouds-allblobstore "1.6.0"]]
>>>> :main my-app.core)
>>>> 
>>>> Any advice is greatly appreciated,
>>>> 
>>>> Thanks,
>>>> 
>>>> 
>>>> Max
> 


Re: Trouble compiling JClouds with Clojure

Posted by Paolo Viotti <pa...@eurecom.fr>.
Hello,

recently I had the same problem with Java and Maven.
The root cause was that in the created uber-jar the files 
"org.jclouds.apis.ApiMetadata" "org.jclouds.providers.ProviderMetadata" 
located in /META-INF/services didn't contain all the API/Provider ids.
So I had to tell Maven to merge those metadata files present in each of 
the providers' jar into one single file in the uber-jar, instead of just 
overwriting them.

This, with Maven, can be accomplished in two ways:

  * using the maven assembly plugin: with a configuration file in which
    you specify the metaInf-services handler (e.g. like this
    <https://dl.dropboxusercontent.com/u/782932/jar-with-dependencies.xml>)
  * using the maven shade plugin: with a "ServicesResourceTransformer"


Hope this helps,
Paolo



On 08/09/2013 06:46, Max Countryman wrote:
> Hi Everett,
>
> Thanks for the quick response. I've tried updating to 1.6.2-incubating but still seem to receive the same error.
>
>  From inside the compiled jar I tried calling:
>
> (clojure.pprint/pprint (.getURLs (java.lang.ClassLoader/getSystemClassLoader))).
>
> This was the result:
>
> [#<URL file:/Users/max/Documents/projects/my-app/target/my-app-0.1.0-SNAPSHOT-standalone.jar>]
>
> I'm wondering if this could have something to do with AOT complication given that it works fine from the repl?
>
> Thanks,
>
>
> Max
>
> On Sep 7, 2013, at 7:28 PM, Everett Toews <ev...@RACKSPACE.COM> wrote:
>
>> It means that the cloudfiles-us JAR isn't contained on your classpath. Although [org.jclouds/jclouds-allblobstore "1.6.0"] should contain it. Can you list your classpath from within your app or see what leiningen is using for the classpath?
>>
>> You might also want to try [org.apache.jclouds/jclouds-allblobstore "1.6.2-incubating"] as that's our most recent release.
>>
>> HTH,
>> Everett
>>
>>
>> On Sep 7, 2013, at 9:12 PM, Max Countryman wrote:
>>
>>> Hi all,
>>>
>>> I am attempting to compile a jar via leiningen's uberjar command that uses JCloud's org.jclouds.blobstore2.
>>>
>>> The trouble I'm running into is that it seems the providers list isn't populated. Interestingly this works fine from the repl, but the compiled jar throws this error:
>>>
>>> Exception in thread "main" java.util.NoSuchElementException: key [cloudfiles-us] not in the list of providers or apis: {providers=[hpcloud-objectstorage], apis=[atmos]}
>>> 	at org.jclouds.ContextBuilder.newBuilder(ContextBuilder.java:178)
>>> 	at org.jclouds.blobstore2$blobstore.doInvoke(blobstore2.clj:103)
>>> 	at clojure.lang.RestFn.invoke(RestFn.java:445)
>>> 	at stint_uploader.core$_main.invoke(core.clj:40)
>>> 	at clojure.lang.AFn.applyToHelper(AFn.java:159)
>>> 	at clojure.lang.AFn.applyTo(AFn.java:151)
>>> 	at stint_uploader.core.main(Unknown Source)
>>>
>>> Here's a simple example:
>>>
>>> (ns my-app.core
>>> (:require [org.jclouds.blobstore2 :refer :all])
>>> (:gen-class))
>>>
>>> (defn -main []
>>> (blobstore "cloudfiles-us" "foo" "bar"))
>>>
>>> And the project.clj would look something like:
>>>
>>> (defproject my-app "0.1.0-SNAPSHOT"
>>> :description "FIXME: write description"
>>> :url "http://example.com/FIXME"
>>> :license {:name "Eclipse Public License"
>>>            :url "http://www.eclipse.org/legal/epl-v10.html"}
>>> :dependencies [[org.clojure/clojure "1.4.0"]
>>>                 [org.clojure/tools.logging "0.2.3"]
>>>                 [org.clojure/core.incubator "0.1.0"]
>>>                 [org.jclouds/jclouds-allblobstore "1.6.0"]]
>>> :main my-app.core)
>>>
>>> Any advice is greatly appreciated,
>>>
>>> Thanks,
>>>
>>>
>>> Max


Re: Trouble compiling JClouds with Clojure

Posted by Max Countryman <ma...@me.com>.
Hi Everett,

Thanks for the quick response. I've tried updating to 1.6.2-incubating but still seem to receive the same error.

From inside the compiled jar I tried calling:

(clojure.pprint/pprint (.getURLs (java.lang.ClassLoader/getSystemClassLoader))).

This was the result:

[#<URL file:/Users/max/Documents/projects/my-app/target/my-app-0.1.0-SNAPSHOT-standalone.jar>]

I'm wondering if this could have something to do with AOT complication given that it works fine from the repl?

Thanks,


Max

On Sep 7, 2013, at 7:28 PM, Everett Toews <ev...@RACKSPACE.COM> wrote:

> It means that the cloudfiles-us JAR isn't contained on your classpath. Although [org.jclouds/jclouds-allblobstore "1.6.0"] should contain it. Can you list your classpath from within your app or see what leiningen is using for the classpath?
> 
> You might also want to try [org.apache.jclouds/jclouds-allblobstore "1.6.2-incubating"] as that's our most recent release.
> 
> HTH,
> Everett
> 
> 
> On Sep 7, 2013, at 9:12 PM, Max Countryman wrote:
> 
>> Hi all,
>> 
>> I am attempting to compile a jar via leiningen's uberjar command that uses JCloud's org.jclouds.blobstore2.
>> 
>> The trouble I'm running into is that it seems the providers list isn't populated. Interestingly this works fine from the repl, but the compiled jar throws this error:
>> 
>> Exception in thread "main" java.util.NoSuchElementException: key [cloudfiles-us] not in the list of providers or apis: {providers=[hpcloud-objectstorage], apis=[atmos]}
>> 	at org.jclouds.ContextBuilder.newBuilder(ContextBuilder.java:178)
>> 	at org.jclouds.blobstore2$blobstore.doInvoke(blobstore2.clj:103)
>> 	at clojure.lang.RestFn.invoke(RestFn.java:445)
>> 	at stint_uploader.core$_main.invoke(core.clj:40)
>> 	at clojure.lang.AFn.applyToHelper(AFn.java:159)
>> 	at clojure.lang.AFn.applyTo(AFn.java:151)
>> 	at stint_uploader.core.main(Unknown Source)
>> 
>> Here's a simple example:
>> 
>> (ns my-app.core
>> (:require [org.jclouds.blobstore2 :refer :all])
>> (:gen-class))
>> 
>> (defn -main []
>> (blobstore "cloudfiles-us" "foo" "bar"))
>> 
>> And the project.clj would look something like:
>> 
>> (defproject my-app "0.1.0-SNAPSHOT"
>> :description "FIXME: write description"
>> :url "http://example.com/FIXME"
>> :license {:name "Eclipse Public License"
>>           :url "http://www.eclipse.org/legal/epl-v10.html"}
>> :dependencies [[org.clojure/clojure "1.4.0"]
>>                [org.clojure/tools.logging "0.2.3"]
>>                [org.clojure/core.incubator "0.1.0"]
>>                [org.jclouds/jclouds-allblobstore "1.6.0"]]
>> :main my-app.core)
>> 
>> Any advice is greatly appreciated,
>> 
>> Thanks,
>> 
>> 
>> Max
> 


Re: Trouble compiling JClouds with Clojure

Posted by Everett Toews <ev...@RACKSPACE.COM>.
It means that the cloudfiles-us JAR isn't contained on your classpath. Although [org.jclouds/jclouds-allblobstore "1.6.0"] should contain it. Can you list your classpath from within your app or see what leiningen is using for the classpath?

You might also want to try [org.apache.jclouds/jclouds-allblobstore "1.6.2-incubating"] as that's our most recent release.

HTH,
Everett


On Sep 7, 2013, at 9:12 PM, Max Countryman wrote:

> Hi all,
> 
> I am attempting to compile a jar via leiningen's uberjar command that uses JCloud's org.jclouds.blobstore2.
> 
> The trouble I'm running into is that it seems the providers list isn't populated. Interestingly this works fine from the repl, but the compiled jar throws this error:
> 
> Exception in thread "main" java.util.NoSuchElementException: key [cloudfiles-us] not in the list of providers or apis: {providers=[hpcloud-objectstorage], apis=[atmos]}
> 	at org.jclouds.ContextBuilder.newBuilder(ContextBuilder.java:178)
> 	at org.jclouds.blobstore2$blobstore.doInvoke(blobstore2.clj:103)
> 	at clojure.lang.RestFn.invoke(RestFn.java:445)
> 	at stint_uploader.core$_main.invoke(core.clj:40)
> 	at clojure.lang.AFn.applyToHelper(AFn.java:159)
> 	at clojure.lang.AFn.applyTo(AFn.java:151)
> 	at stint_uploader.core.main(Unknown Source)
> 
> Here's a simple example:
> 
> (ns my-app.core
>  (:require [org.jclouds.blobstore2 :refer :all])
>  (:gen-class))
> 
> (defn -main []
>  (blobstore "cloudfiles-us" "foo" "bar"))
> 
> And the project.clj would look something like:
> 
> (defproject my-app "0.1.0-SNAPSHOT"
>  :description "FIXME: write description"
>  :url "http://example.com/FIXME"
>  :license {:name "Eclipse Public License"
>            :url "http://www.eclipse.org/legal/epl-v10.html"}
>  :dependencies [[org.clojure/clojure "1.4.0"]
>                 [org.clojure/tools.logging "0.2.3"]
>                 [org.clojure/core.incubator "0.1.0"]
>                 [org.jclouds/jclouds-allblobstore "1.6.0"]]
>  :main my-app.core)
> 
> Any advice is greatly appreciated,
> 
> Thanks,
> 
> 
> Max