java.net.MalformedURLException on index delete.

118 views
Skip to first unread message

Mark Mandel

unread,
Aug 26, 2013, 4:46:52 AM8/26/13
to clojure-el...@googlegroups.com
Disclaimer: I am a clojure newbie, so hopefully I'm not doing something dumb here.  Please feel free to point it out to me if I am.

I'm attempting to delete my test index on each test run through in Midje, so that I have a clean slate on each unit test.

My clojure code looks like the following:

```
(ns chaperone.persistence.core-test
(:use midje.sweet)
(:use foo.core)
(:require [clojurewerkz.elastisch.rest :as esr]))


(defn- clean-es []
(println "Cleaning")
(esr/connect! "http://dev.foo:9200")
(esr/delete "test_foo"))

(namespace-state-changes (before :facts (clean-es)))

(fact
"I am doing something awesome."
(conj [1 2] 3) => [1 2 3])
```

No matter which way I try and do this, I get back the following exception (full version at the bottom of the email):

```
Exception in thread "main" java.net.MalformedURLException: no protocol: test_chaperone
        at java.net.URL.<init>(URL.java:585)
```

I cannot seem to find the correct way to do this, so that I don't get the MalformedURLException. It seems like the default URL endpoint for elastish is not being set? Or if it is it's not being used properly? I had a dig into the code, and nothing looked weird, so I am very confused.

Any help would be appreciated.

Full Stack Trace:

log4j:WARN No appenders could be found for logger (org.apache.http.impl.conn.BasicClientConnectionManager).
log4j:WARN Please initialize the log4j system properly.
Cleaning
Exception in thread "main" java.net.MalformedURLException: no protocol: test_foo
        at java.net.URL.<init>(URL.java:585)
        at java.net.URL.<init>(URL.java:482)
        at java.net.URL.<init>(URL.java:431)
        at clj_http.client$parse_url.invoke(client.clj:81)
        at clj_http.client$wrap_url$fn__7979.invoke(client.clj:560)
        at clj_http.client$wrap_redirects$fn__7783.invoke(client.clj:170)
        at clj_http.client$wrap_decompression$fn__7810.invoke(client.clj:224)
        at clj_http.client$wrap_input_coercion$fn__7882.invoke(client.clj:354)
        at clj_http.client$wrap_additional_header_parsing$fn__7903.invoke(client.clj:397)
        at clj_http.client$wrap_output_coercion$fn__7873.invoke(client.clj:308)
        at clj_http.client$wrap_exceptions$fn__7765.invoke(client.clj:127)
        at clj_http.client$wrap_accept$fn__7913.invoke(client.clj:424)
        at clj_http.client$wrap_accept_encoding$fn__7919.invoke(client.clj:439)
        at clj_http.client$wrap_content_type$fn__7908.invoke(client.clj:415)
        at clj_http.client$wrap_form_params$fn__7957.invoke(client.clj:526)
        at clj_http.client$wrap_nested_params$fn__7975.invoke(client.clj:550)
        at clj_http.client$wrap_method$fn__7952.invoke(client.clj:509)
        at clj_http.cookies$wrap_cookies$fn__6356.invoke(cookies.clj:118)
        at clj_http.links$wrap_links$fn__6393.invoke(links.clj:50)
        at clj_http.client$wrap_unknown_host$fn__7984.invoke(client.clj:569)
        at clj_http.client$delete.doInvoke(client.clj:693)
        at clojure.lang.RestFn.invoke(RestFn.java:423)
        at clojurewerkz.elastisch.rest$delete.invoke(rest.clj:43)
        at foo.core_test$clean_es.invoke(core_test.clj:10)
        at foo.core_test$eval8295.invoke(core_test.clj:13)
        at clojure.lang.Compiler.eval(Compiler.java:6619)
        at clojure.lang.Compiler.load(Compiler.java:7064)
        at clojure.lang.RT.loadResourceScript(RT.java:370)
        at clojure.lang.RT.loadResourceScript(RT.java:361)
        at clojure.lang.RT.load(RT.java:440)
        at clojure.lang.RT.load(RT.java:411)
        at clojure.core$load$fn__5018.invoke(core.clj:5530)
        at clojure.core$load.doInvoke(core.clj:5529)
        at clojure.lang.RestFn.invoke(RestFn.java:408)
        at clojure.core$load_one.invoke(core.clj:5336)
        at clojure.core$load_lib$fn__4967.invoke(core.clj:5375)
        at clojure.core$load_lib.doInvoke(core.clj:5374)
        at clojure.lang.RestFn.applyTo(RestFn.java:142)
        at clojure.core$apply.invoke(core.clj:619)
        at clojure.core$load_libs.doInvoke(core.clj:5413)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at clojure.core$apply.invoke(core.clj:619)
        at clojure.core$require.doInvoke(core.clj:5496)
        at clojure.lang.RestFn.invoke(RestFn.java:421)
        at midje.repl$load_facts$fn__6191.invoke(repl.clj:206)
        at midje.repl$load_facts.doInvoke(repl.clj:192)
        at clojure.lang.RestFn.invoke(RestFn.java:397)
        at user$eval6253.invoke(form-init285382800338081218.clj:1)
        at clojure.lang.Compiler.eval(Compiler.java:6619)
        at clojure.lang.Compiler.eval(Compiler.java:6609)
        at clojure.lang.Compiler.load(Compiler.java:7064)
        at clojure.lang.Compiler.loadFile(Compiler.java:7020)
        at clojure.main$load_script.invoke(main.clj:294)
        at clojure.main$init_opt.invoke(main.clj:299)
        at clojure.main$initialize.invoke(main.clj:327)
        at clojure.main$null_opt.invoke(main.clj:362)
        at clojure.main$main.doInvoke(main.clj:440)
        at clojure.lang.RestFn.invoke(RestFn.java:421)
        at clojure.lang.Var.invoke(Var.java:419)
        at clojure.lang.AFn.applyToHelper(AFn.java:163)
        at clojure.lang.Var.applyTo(Var.java:532)
        at clojure.main.main(main.java:37)
Subprocess failed

Mark Mandel

unread,
Aug 26, 2013, 5:02:43 AM8/26/13
to clojure-el...@googlegroups.com
Please ignore me. Just realised I was not calling against clojurewerkz.elastisch.rest and not clojurewerkz.elastisch.rest.index

Now it works.

(facepalm)

Thanks for the library!

Mark
Reply all
Reply to author
Forward
0 new messages