I am using luminus building a web application. I am getting type errors like
java.base/java.lang.Long cannot be cast to java.base/java.lang.String
but I can’t really find the error. My question is, is there any debugger available in clojure luminus? Like a simple step debugger (gdb etc)?
A for now I have to redirect my output to a test.html to view different variables.
and another question: How do I call a webpage from repl? that would also help a lot.
That “cannot be cast” error with the same class name seems like its reason is two different class loaders that were used to load the same class. Can’t really say anything else about it just given its description.
Update: seems like I need a break because I read the OP as if it was about casting Long to Long.
Regarding debugging - so far, I only have reasonable experience with Cursive, and it can debug Clojure code just fine. There are some peculiarities to it, but when you get used to it, it’ll become rather natural.
How do I call a webpage from repl?
What do you mean by “calling a webpage”? Executing a command that makes a browser window open at the provided URL? If so, then clojure.java.browse/browse-url.
That sounds like you’re trying to perform a String operation on a Long value. I’m not familiar with luminous, but doesn’t it give you a stack trace of the exception? It should be fairly simple to track from there.
I can access this function from repl but I want to call if from a webrequest from repl, i.e with the routing and so on. Then I can examine req and see what is being passed to the function.
I’m not sure at what level you want to test this. I use Reitit, and routinely test my handlers with request maps that have the needed shape. I suspect you could do a similar thing in whatever stack you are using. Otherwise, you should look at your console output for that stack trace of your casting exception.
As stated above, i want to call my function from repl that takes a request as an argument. The request is a dictionary with different key value pairs and I want to check these values. Normaly, you have an html page that sends these values through a router, and that router sends the request to a function. So the question is not really how to use the repl per se, it is how can I simulate a html call to my function in repl?
There is a similiar example in luminus where curl is used to call a function, but I want to do it from the repl. I hope this makes everything clear.
requires the req as an argument, and that one is not available in the repl, so the following error occur:
user=> (rental.routes.home/*debug-request*)
Execution error (ArityException) at user/eval24135 (form-init16465374154616516791.clj:1).
Wrong number of args (0) passed to: clojure.lang.PersistentHashMap