Full stack trace of an error/exception in clojure - exception

I'm using clojure with lein. Executing a function from repl gives the following error message:
ClassCastException java.lang.Long cannot be cast to clojure.lang.IFn user/eval3873/fn--3874 (form-init6374407951848346782.clj:1)
So somewhere in the code a long is placed where there's supposed to be a function. But I can't figure out the location of the error in my code. Is there a way I could get the repl to print the full stack trace of the exception?

Just examine the special variable *e which is also described in your REPL introduction banner.
For example:
Clojure 1.8.0
Java HotSpot(TM) 64-Bit Server VM 1.8.0_161-b12
Docs: (doc function-name-here)
(find-doc "part-of-name-here")
Source: (source function-name-here)
Javadoc: (javadoc java-object-or-class-here)
Exit: Control+D or (exit) or (quit)
Results: Stored in vars *1, *2, *3, an exception in *e
user=> (+ 1 "r")
ClassCastException java.lang.String cannot be cast to java.lang.Number clojure.lang.Numbers.add (Numbers.java:128)
user=> *e
#error {
:cause "java.lang.String cannot be cast to java.lang.Number"
:via
[{:type java.lang.ClassCastException
:message "java.lang.String cannot be cast to java.lang.Number"
:at [clojure.lang.Numbers add "Numbers.java" 128]}]
:trace
[[clojure.lang.Numbers add "Numbers.java" 128]
[clojure.lang.Numbers add "Numbers.java" 3640]
[user$eval1244 invokeStatic "form-init8915652650489400713.clj" 1]
[user$eval1244 invoke "form-init8915652650489400713.clj" 1]
[clojure.lang.Compiler eval "Compiler.java" 6927]
[clojure.lang.Compiler eval "Compiler.java" 6890]
[clojure.core$eval invokeStatic "core.clj" 3105]
[clojure.core$eval invoke "core.clj" 3101]
[clojure.main$repl$read_eval_print__7408$fn__7411 invoke "main.clj" 240]
[clojure.main$repl$read_eval_print__7408 invoke "main.clj" 240]
[clojure.main$repl$fn__7417 invoke "main.clj" 258]
[clojure.main$repl invokeStatic "main.clj" 258]
[clojure.main$repl doInvoke "main.clj" 174]
[clojure.lang.RestFn invoke "RestFn.java" 1523]
[clojure.tools.nrepl.middleware.interruptible_eval$evaluate$fn__648 invoke "interruptible_eval.clj" 87]
[clojure.lang.AFn applyToHelper "AFn.java" 152]
[clojure.lang.AFn applyTo "AFn.java" 144]
[clojure.core$apply invokeStatic "core.clj" 646]
[clojure.core$with_bindings_STAR_ invokeStatic "core.clj" 1881]
[clojure.core$with_bindings_STAR_ doInvoke "core.clj" 1881]
[clojure.lang.RestFn invoke "RestFn.java" 425]
[clojure.tools.nrepl.middleware.interruptible_eval$evaluate invokeStatic "interruptible_eval.clj" 85]
[clojure.tools.nrepl.middleware.interruptible_eval$evaluate invoke "interruptible_eval.clj" 55]
[clojure.tools.nrepl.middleware.interruptible_eval$interruptible_eval$fn__693$fn__696 invoke "interruptible_eval.clj" 222]
[clojure.tools.nrepl.middleware.interruptible_eval$run_next$fn__688 invoke "interruptible_eval.clj" 190]
[clojure.lang.AFn run "AFn.java" 22]
[java.util.concurrent.ThreadPoolExecutor runWorker "ThreadPoolExecutor.java" 1149]
[java.util.concurrent.ThreadPoolExecutor$Worker run "ThreadPoolExecutor.java" 624]
[java.lang.Thread run "Thread.java" 748]]}
user=>

Related

I use the emacs to start or connect clojurescript but show error: ClojureScript is not available

I use the emacs to start or connect clojurescript but show error:
error in process filter: ClojureScript is not available. See https://docs.cider.mx/cider/basics/clojurescript for details
In terminal I use `npx shadow-cljs watch main` to start clojurescript app. It's to started. so in emacs I use `cider-connect-cljs` connect
M-x cider-connect-cljs
Host: localhost
Port: 3477
Select ClojureScript REPL type: shandow
Select shadow-cljs build: main
[terminal starts app](https://i.stack.imgur.com/Ait43.png)
[emacs](https://i.stack.imgur.com/0WUfC.png)
On the other hand. I use `cider-jack-in-cljs` to start app in emacs alone. the error as same as up.
shadow-cljs.edn
;; shadow-cljs configuration
{:deps {:aliases [:dev]}
:http {:port 3448}
:nrepl {:port 3447 :host "0.0.0.0"}
:jvm-opts ["-Xmx700m" "-Xms100m" "-XX:+UseSerialGC" "-XX:-OmitStackTraceInFastThrow"]
:dev-http {8888 "classpath:public"}
:builds
{:main
{:target :browser
:output-dir "resources/public/js/"
:asset-path "/js"
:devtools {:browser-inject :main
:watch-dir "resources/public"}
:build-options {:manifest-name "manifest.json"}
:modules
{:main {:entries [app.main]
:init-fn app.main/init}}}
}}
deps.edn
{:paths ["src" "vendor" "resources" "test"]
:deps {org.clojure/clojure {:mvn/version "1.11.1"}
org.clojure/clojurescript {:mvn/version "1.11.60"}
lilactown/helix {:mvn/version "0.1.9"}}
:aliases {:dev
{:extra-paths ["test" "dev"]
:extra-deps
{thheller/shadow-cljs {:mvn/version "2.20.2"}
org.clojure/tools.namespace {:mvn/version "RELEASE"}
cider/cider-nrepl {:mvn/version "0.29.0"}}}}}

SQL Server did not return a response error

When I try accessing Azure SQL server I get the following error. The connection looks fine via DBeaver though.
I recently updated my mac OS to Mojave, would that have caused any driver incompatibility? Any thoughts on how to solve this issue? This is really bugging me, any help will be much appreciated!
I am trying to access a table in Azure My SQL, and the code is in clojure hence the error stack trace as below:
#error {
:cause SQL Server did not return a response. The connection has been closed. ClientConnectionId:98906d8f-3e0c-424e-8145-04636958e14b
:via
[{:type com.microsoft.sqlserver.jdbc.SQLServerException
:message SQL Server did not return a response. The connection has been closed. ClientConnectionId:98906d8f-3e0c-424e-8145-04636958e14b
:at [com.microsoft.sqlserver.jdbc.SQLServerConnection terminate SQLServerConnection.java 1667]}]
:trace
[[com.microsoft.sqlserver.jdbc.SQLServerConnection terminate SQLServerConnection.java 1667]
[com.microsoft.sqlserver.jdbc.SQLServerConnection terminate SQLServerConnection.java 1654]
[com.microsoft.sqlserver.jdbc.TDSReader readPacket IOBuffer.java 4844]
[com.microsoft.sqlserver.jdbc.TDSCommand startResponse IOBuffer.java 6154]
[com.microsoft.sqlserver.jdbc.TDSCommand startResponse IOBuffer.java 6106]
[com.microsoft.sqlserver.jdbc.SQLServerConnection sendLogon SQLServerConnection.java 2907]
[com.microsoft.sqlserver.jdbc.SQLServerConnection logon SQLServerConnection.java 2234]
[com.microsoft.sqlserver.jdbc.SQLServerConnection access$000 SQLServerConnection.java 41]
[com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand doExecute SQLServerConnection.java 2220]
[com.microsoft.sqlserver.jdbc.TDSCommand execute IOBuffer.java 5696]
[com.microsoft.sqlserver.jdbc.SQLServerConnection executeCommand SQLServerConnection.java 1715]
[com.microsoft.sqlserver.jdbc.SQLServerConnection connectHelper SQLServerConnection.java 1326]
[com.microsoft.sqlserver.jdbc.SQLServerConnection login SQLServerConnection.java 991]
[com.microsoft.sqlserver.jdbc.SQLServerConnection connect SQLServerConnection.java 827]
[com.microsoft.sqlserver.jdbc.SQLServerDriver connect SQLServerDriver.java 1012]
[java.sql.DriverManager getConnection DriverManager.java 664]
[java.sql.DriverManager getConnection DriverManager.java 208]
[clojure.java.jdbc$get_connection invokeStatic jdbc.clj 272]
[clojure.java.jdbc$get_connection invoke jdbc.clj 193]
[korma.db$do_query invokeStatic db.clj 286]
[korma.db$do_query invoke db.clj 283]
[korma.core$exec invokeStatic core.clj 498]
[korma.core$exec invoke core.clj 477]
[swbimodel.provider_info$get_for_pid invokeStatic provider_info.clj 22]
[swbimodel.provider_info$get_for_pid invoke provider_info.clj 18]
[genki.utils$sql_app_status_check invokeStatic utils.clj 159]
[genki.utils$sql_app_status_check invoke utils.clj 157]
[user$eval40383 invokeStatic form-init5576567307560081321.clj 1]
[user$eval40383 invoke form-init5576567307560081321.clj 1]
[clojure.lang.Compiler eval Compiler.java 6927]
[clojure.lang.Compiler eval Compiler.java 6890]
[clojure.core$eval invokeStatic core.clj 3105]
[clojure.core$eval invoke core.clj 3101]
[clojure.main$repl$read_eval_print__7408$fn__7411 invoke main.clj 240]
[clojure.main$repl$read_eval_print__7408 invoke main.clj 240]
[clojure.main$repl$fn__7417 invoke main.clj 258]
[clojure.main$repl invokeStatic main.clj 258]
[clojure.main$repl doInvoke main.clj 174]
[clojure.lang.RestFn invoke RestFn.java 1523]
[clojure.tools.nrepl.middleware.interruptible_eval$evaluate$fn__39798 invoke interruptible_eval.clj 87]
[clojure.lang.AFn applyToHelper AFn.java 152]
[clojure.lang.AFn applyTo AFn.java 144]
[clojure.core$apply invokeStatic core.clj 646]
[clojure.core$with_bindings_STAR_ invokeStatic core.clj 1881]
[clojure.core$with_bindings_STAR_ doInvoke core.clj 1881]
[clojure.lang.RestFn invoke RestFn.java 425]
[clojure.tools.nrepl.middleware.interruptible_eval$evaluate invokeStatic interruptible_eval.clj 85]
[clojure.tools.nrepl.middleware.interruptible_eval$evaluate invoke interruptible_eval.clj 55]
[clojure.tools.nrepl.middleware.interruptible_eval$interruptible_eval$fn__39843$fn__39846 invoke interruptible_eval.clj 222]
[clojure.tools.nrepl.middleware.interruptible_eval$run_next$fn__39838 invoke interruptible_eval.clj 190]
[clojure.lang.AFn run AFn.java 22]
[java.util.concurrent.ThreadPoolExecutor runWorker ThreadPoolExecutor.java 1149]
[java.util.concurrent.ThreadPoolExecutor$Worker run ThreadPoolExecutor.java 624]
[java.lang.Thread run Thread.java 748]]}
Clojure code where am referencing sql:
(defn get-for-pid [pid]
(let [query (-> (select* sql-table)
(where (= :PID pid)))]
(select query)))
(defn status-check [pid]
(let [sqlstatus (vec (get-for-pid pid))]
(if (empty? sqlstatus) false
(if (contains? (first sqlstatus) :Status)
(get-in (first sqlstatus) [:Status]) false))))
Could it be that during your OS upgrade you got a new set of firewall rules and DBeaver is authorized but other Java programs are not allowed to use the port required for the connection?
Update: This post helped me solve it. I just set the hostname by running:
sudo scutil --set HostName "YOUR HOSTNAME HERE"

Cloud Functions Not Downloading Dependencies

I am trying to deploy a Node.js app on Google Cloud Functions but it seems that it is not downloading any of my dependencies. Whenever my code hits a require line, it throws the following error:
Deployment failure:
Function load error: Code in file app.js can't be loaded.
Did you list all required modules in the package.json dependencies?
Detailed stack trace: Error: Cannot find module 'googleapis'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/user_code/app.js:1:63)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
My package.json dependencies block:
"dependencies": {
"actions-on-google": "^1.0.9",
"body-parser": "^1.15.2",
"chai-as-promised": "^6.0.0",
"express": "^4.14.0",
"express-healthcheck": "^0.1.0",
"googleapis": "^19.0.0",
"https": "^1.0.0",
"istanbul": "^0.4.5",
"newrelic": "^1.40.0",
"nodemailer": "^4.0.1",
"querystring": "^0.2.0",
"request": "^2.81.0",
"string-format": "^0.5.0",
"universal-analytics": "^0.4.13",
"xml2js": "^0.4.17"
},
Is there a way to force the install, or is there something wrong with the way I am doing this? I get no errors running the functions package locally via the command functions deploy runApp --trigger-http and can do everything I want via my local computer. The error only happens when trying to set it up in the cloud
I also tried via the gcloud beta functions CLI using the --verbose flag as mentioned in this answer and I got the following trace:
DEBUG: (gcloud.beta.functions.deploy) OperationError: code=13, message=Error in the build environment
Traceback (most recent call last):
File "/Users/<username>/google-cloud-sdk/lib/googlecloudsdk/calliope/cli.py", line 789, in Execute
resources = args.calliope_command.Run(cli=self, args=args)
File "/Users/<username>/google-cloud-sdk/lib/googlecloudsdk/calliope/backend.py", line 754, in Run
resources = command_instance.Run(args)
File "/Users/<username>/google-cloud-sdk/lib/surface/functions/deploy.py", line 482, in Run
return self._UpdateFunction(location, function)
File "/Users/<username>/google-cloud-sdk/lib/googlecloudsdk/api_lib/functions/util.py", line 364, in CatchHTTPErrorRaiseHTTPExceptionFn
return func(*args, **kwargs)
File "/Users/<username>/google-cloud-sdk/lib/surface/functions/deploy.py", line 441, in _UpdateFunction
operations.Wait(op, messages, client, _DEPLOY_WAIT_NOTICE)
File "/Users/<username>/google-cloud-sdk/lib/googlecloudsdk/api_lib/functions/operations.py", line 108, in Wait
_WaitForOperation(client, request, notice)
File "/Users/<username>/google-cloud-sdk/lib/googlecloudsdk/api_lib/functions/operations.py", line 83, in _WaitForOperation
sleep_ms=SLEEP_MS)
File "/Users/<username>/google-cloud-sdk/lib/googlecloudsdk/core/util/retry.py", line 212, in RetryOnResult
result = func(*args, **kwargs)
File "/Users/<username>/google-cloud-sdk/lib/googlecloudsdk/api_lib/functions/operations.py", line 47, in _GetOperationStatus
raise exceptions.FunctionsError(util.GetOperationError(op.error))
FunctionsError: OperationError: code=13, message=Error in the build environment
I managed to get it working by simply removing "express-healthcheck": "^0.1.0". I'm not sure why that was causing it to break but since it is Cloud Functions I don't actually need anything related to Express anymore so removing wasn't a problem for my use case.
If anyone knows why this was causing an error please post here, I am curious

java.lang.AssertionError: Instance must be configured before use in VimeoSdl library

using this https://github.com/vimeo/vimeo-networking-java for vimeo video player.using compile
com.vimeo.networking:vimeo-networking:1.0.1
in build.gradle but still error
Getting error:
FATAL EXCEPTION: main
Process: com.sample.vimeosdkapplication, PID: 2113
java.lang.AssertionError: Instance must be configured before use
at com.vimeo.networking.VimeoClient.getInstance(VimeoClient.java:94)
at com.sample.vimeosdkapplication.MainActivity.<init>(MainActivity.java:28)
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.Class.newInstance(Class.java:1572)
at android.app.Instrumentation.newActivity(Instrumentation.java:1065)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2199)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
07-22 16:56:57.000 2113-2120/com.sample.vimeosdkapplication W/art: Suspending all threads took: 10ms
You'll need to initialize the VimeoClient class. You can find out how to do it in this section of the README.
You'll need to build the builder with the options you want for the library and then call initialize.
Here is an example of a builder:
Configuration.Builder configBuilder =
new Configuration.Builder(clientId, clientSecret, SCOPE,
testAccountStore, new AndroidGsonDeserializer())
.setCacheDirectory(this.getCacheDir())
Then you statically call initialize here:
VimeoClient.initialize(<your builder here>);

Cannot compile MySQL++

I am trying to compile MySQL++ 3.1.0 with the command:
mingw32-make -f Makefile.mingw
After a set of files gets compiled (e.g. beemutex.cpp, cmdline.cpp, connection.cpp, ...), I get these errors:
g++ -c -o mysqlpp_sql_buffer.o -g -mthreads -DUNICODE -D_UNICODE -DMYSQLPP_NO_DLL -DHAVE_MYSQL_SSL_SET -I"C:\Program Files\MySQL\MySQL Server 5.5\include" -MT
mysqlpp_sql_buffer.o -MFmysqlpp_sql_buffer.o.d -MD -MP lib/sql_buffer.cpp
In file included from lib/sql_buffer.h:31:0,
from lib/sql_buffer.cpp:26:
lib/refcounted.h:258:2: error: 'size_t' does not name a type
lib/refcounted.h: In constructor 'mysqlpp::RefCountedPointer<T, Destroyer>::RefCountedPointer()':
lib/refcounted.h:89:2: error: class 'mysqlpp::RefCountedPointer<T, Destroyer>' does not have any field named 'refs_'
lib/refcounted.h: In constructor 'mysqlpp::RefCountedPointer<T, Destroyer>::RefCountedPointer(T*)':
lib/refcounted.h:100:2: error: class 'mysqlpp::RefCountedPointer<T, Destroyer>' does not have any field named 'refs_'
lib/refcounted.h:104:4: error: 'refs_' was not declared in this scope
lib/refcounted.h:104:16: error: expected type-specifier before 'size_t'
lib/refcounted.h:104:16: error: expected ';' before 'size_t'
lib/refcounted.h: In constructor 'mysqlpp::RefCountedPointer<T, Destroyer>::RefCountedPointer(const ThisType&)':
lib/refcounted.h:112:2: error: class 'mysqlpp::RefCountedPointer<T, Destroyer>' does not have any field named 'refs_'
lib/refcounted.h:115:8: error: 'refs_' was not declared in this scope
lib/refcounted.h: In destructor 'mysqlpp::RefCountedPointer<T, Destroyer>::~RefCountedPointer()':
lib/refcounted.h:125:7: error: 'refs_' was not declared in this scope
lib/refcounted.h: In member function 'void mysqlpp::RefCountedPointer<T, Destroyer>::swap(mysqlpp::RefCountedPointer<T, Destroyer>::ThisType&)':
lib/refcounted.h:246:13: error: 'refs_' was not declared in this scope
mingw32-make: *** [mysqlpp_sql_buffer.o] Error 1
Something could be wrong in my configuration, but I can't find what. It seems strange that it cannot find, e.g., size_t.
Thank you!
Platform:
Windows 7
MinGW 2011.09 / GCC 4.6.1
MySQL 5.5
mysql++ 3.1.0
Changing size_t() with std::size_t() in refcounted.h solved the problem. It now compiles.
I still have linking problems, but they should be different issues.