beginners

Anton Shastun 2025-05-07T17:22:42.194359Z

Hello, I'm using latest java and latest clojure tools, trying to load [ring.adapter.jetty :refer [run-jetty]] in deps: ring/ring-jetty-adapter {:mvn/version "1.12.2"} but got error -

2. Unhandled clojure.lang.Compiler$CompilerException
   Error compiling ring/util/jakarta/servlet.clj at (1:1)
1. Caused by java.lang.ClassNotFoundException
   jakarta.servlet.AsyncContext
what I'm doing wrong?

Anton Shastun 2025-05-07T17:24:05.740489Z

clj -X:deps tree https://gist.github.com/faust451/6d3a7b351136aae5992deb591f4ec6d0

p-himik 2025-05-07T17:36:44.937419Z

That class comes from org.eclipse.jetty.toolchain/jetty-jakarta-servlet-api and that dependency is on the classpath as reported by the last command. But are you sure that the process where you see the exception is running with the same classpath? Meaning, it was restarted after any change to deps.edn, it doesn't use any aliases.

Anton Shastun 2025-05-07T17:37:52.982749Z

yes sure, I restarted clj -M:cider-clj:jvm-base

Anton Shastun 2025-05-07T17:39:54.788089Z

I'm connecting to nrepl

p-himik 2025-05-07T17:40:06.131989Z

In the same process where the error happens, what does this output?

(->> (clojure.string/split (System/getProperty "java.class.path") #":")
     (filter #(clojure.string/includes? % "jakarta")))

Anton Shastun 2025-05-07T17:41:35.893279Z

/home/moon/.m2/repository/org/ring-clojure/ring-jakarta-servlet/1.12.2/ring-jakarta-servlet-1.12.2.jar

p-himik 2025-05-07T17:48:33.342759Z

There should also be /home/moon/.m2/repository/org/eclipse/jetty/toolchain/jetty-jakarta-servlet-api/5.0.2/jetty-jakarta-servlet-api-5.0.2.jar, but it isn't, somehow. I don't have better ideas here except trying to: 1. Run clj -Sdeps '{:deps {org.eclipse.jetty.toolchain/jetty-jakarta-servlet-api {:mvn/version "5.0.2"}}}' and execute (import 'jakarta.servlet.AsyncContext) to see what happens 2. Removing .cpcache directory at the root of the project 3. Checking what's inside /home/moon/.m2/repository/org/eclipse/jetty/toolchain/jetty-jakarta-servlet-api/5.0.2/, maybe removing the whole directory

Anton Shastun 2025-05-07T17:52:12.537369Z

clj -Sdeps '{:deps {org.eclipse.jetty.toolchain/jetty-jakarta-servlet-api {:mvn/version "5.0.2"}}}'

user=> (import 'jakarta.servlet.AsyncContext) 
jakarta.servlet.AsyncContext

Anton Shastun 2025-05-07T17:53:20.334039Z

/home/moon/.m2/repository/org/eclipse/jetty/toolchain/jetty-jakarta-servlet-api/5.0.2/

is in place

Anton Shastun 2025-05-07T17:58:07.117789Z

after removing /home/moon/.m2/repository/org/eclipse/ and reinstall deps

ls /home/moon/.m2/repository/org/eclipse/jetty/
jetty-project/  jetty-server/  websocket/ 

p-himik 2025-05-07T18:08:13.281819Z

What happens if you run you project not through CIDER but via plain clj?

Anton Shastun 2025-05-07T18:22:22.433559Z

by the way my output on starting clj looks:

clj -M:cider-clj:jvm-base
Warning: failed to load the S3TransporterFactory class
Warning: failed to load the S3TransporterFactory class
Warning: failed to load the S3TransporterFactory class
Warning: failed to load the S3TransporterFactory class
Warning: failed to load the S3TransporterFactory class
Warning: failed to load the S3TransporterFactory class
Warning: failed to load the S3TransporterFactory class
Warning: failed to load the S3TransporterFactory class
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See  for further details.
Warning: failed to load the S3TransporterFactory class
Warning: failed to load the S3TransporterFactory class
Warning: failed to load the S3TransporterFactory class
Warning: failed to load the S3TransporterFactory class
nREPL server started on port 43081 on host localhost - 

Anton Shastun 2025-05-07T18:26:28.553279Z

What happens if you run you project not through CIDER but via plain clj? Sorry, could you clarify please?

2025-05-07T18:59:10.758549Z

I have seen this in the past, I don't remember what it was related to 🤔

2025-05-07T19:01:00.649799Z

this works fine on my box :

clj -Sdeps '{:deps {ring/ring-jetty-adapter {:mvn/version "1.12.2"}}}'
user=> (require '[ring.adapter.jetty :refer [run-jetty]])

Anton Shastun 2025-05-07T19:02:13.409919Z

on my side:

Clojure 1.12.0
user=> (require '[ring.adapter.jetty :refer [run-jetty]])
Execution error (ClassNotFoundException) at java.net.URLClassLoader/findClass (REPL:-1).
jakarta.servlet.AsyncContext

2025-05-07T19:03:55.500619Z

can you paste the output of clj -Sdeps '{:deps {ring/ring-jetty-adapter {:mvn/version "1.12.2"}}}' -Spath ?

Anton Shastun 2025-05-07T19:04:28.142819Z

clj -X:deps tree |grep jakart
  . org.ring-clojure/ring-jakarta-servlet 1.12.2
    . org.eclipse.jetty.toolchain/jetty-jakarta-servlet-api 5.0.2
    . org.eclipse.jetty.toolchain/jetty-jakarta-servlet-api 5.0.2

Anton Shastun 2025-05-07T19:04:31.904419Z

ls /home/moon/.m2/repository/org/eclipse/jetty/toolchain/jetty-jakarta-servlet-api/5.0.2/

jetty-jakarta-servlet-api-5.0.2.jar       jetty-jakarta-servlet-api-5.0.2.pom       _remote.repositories
jetty-jakarta-servlet-api-5.0.2.jar.sha1  jetty-jakarta-servlet-api-5.0.2.pom.sha1

2025-05-07T19:04:53.097699Z

I mean the full -Spath, not the -Stree

2025-05-07T19:09:33.038919Z

oh, but looks you are running that inside a folder with a deps.edn

2025-05-07T19:09:43.404749Z

try on a empty folder

2025-05-07T19:12:22.359599Z

what is the output of clj --version ?

Anton Shastun 2025-05-07T19:12:38.866849Z

clj --version
Clojure CLI version 1.12.0.1530

2025-05-07T19:13:09.072579Z

hmmm that is weird, because for some reason it is loading clojure 1.11

2025-05-07T19:14:02.032209Z

and also all those Warning: failed to load the S3TransporterFactory class

Anton Shastun 2025-05-07T19:14:18.335929Z

i think 1.12.0 version of tools, but clojure version is 1.11

Anton Shastun 2025-05-07T19:14:41.821579Z

yes that strange Warning: failed to load the S3TransporterFactory class

2025-05-07T19:14:42.095859Z

but the latest version of the cli should by default start with clojure 1.12

Anton Shastun 2025-05-07T19:14:56.138299Z

hm strange

2025-05-07T19:15:17.911069Z

so there is something weird with your clojure installation

Anton Shastun 2025-05-07T19:16:10.039809Z

just downloaded from https://download.clojure.org/install/

2025-05-07T19:16:28.046239Z

can you do a which clojure and then cat /path/to/clojure ?

Anton Shastun 2025-05-07T19:16:59.703989Z

which clojure
/gnu/store/59savh0mi0la9ri97cqck37drxlh9av1-profile/bin/clojure

2025-05-07T19:17:17.917379Z

oh you are using guix

Anton Shastun 2025-05-07T19:17:18.396389Z

ls -l /gnu/store/59savh0mi0la9ri97cqck37drxlh9av1-profile/bin/clojure
lrwxrwxrwx 1 root root 81 Jan  1  1970 /gnu/store/59savh0mi0la9ri97cqck37drxlh9av1-profile/bin/clojure -> /gnu/store/d8c8vlbf3690r0p70qqinkgrfc9d4rqs-clojure-tools-1.12.0.1530/bin/clojure

Anton Shastun 2025-05-07T19:17:23.813789Z

yes guix

2025-05-07T19:18:31.951609Z

what does clj -Sverbose shows?

Anton Shastun 2025-05-07T19:18:53.793059Z

clj -Sverbose
version      = 1.12.0.1530
install_dir  = /gnu/store/d8c8vlbf3690r0p70qqinkgrfc9d4rqs-clojure-tools-1.12.0.1530/lib/clojure
config_dir   = /home/moon/.clojure
config_paths = /gnu/store/d8c8vlbf3690r0p70qqinkgrfc9d4rqs-clojure-tools-1.12.0.1530/lib/clojure/deps.edn /home/moon/.clojure/deps.edn deps.edn
cache_dir    = /home/moon/.clojure/.cpcache
cp_file      = /home/moon/.clojure/.cpcache/1083142194.cp

2025-05-07T19:20:48.305539Z

and the output of cat /gnu/store/d8c8vlbf3690r0p70qqinkgrfc9d4rqs-clojure-tools-1.12.0.1530/lib/clojure/deps.edn

Anton Shastun 2025-05-07T19:21:14.063319Z

cat /gnu/store/d8c8vlbf3690r0p70qqinkgrfc9d4rqs-clojure-tools-1.12.0.1530/lib/clojure/deps.edn 
{
  :paths ["src"]

  :deps {
    org.clojure/clojure {:mvn/version "1.12.0"}
  }

  :aliases {
    :deps {:replace-paths []
           :replace-deps {org.clojure/tools.deps.cli {:mvn/version "0.11.78"}}
           :ns-default clojure.tools.deps.cli.api
           :ns-aliases {help }}
    :test {:extra-paths ["test"]}
  }

  :mvn/repos {
    "central" {:url ""}
    "clojars" {:url ""}
  }
}

2025-05-07T19:21:25.352109Z

weird, it says 1.12.0 for clojure, as it should be

2025-05-07T19:21:48.297279Z

what is in /home/moon/.clojure/deps.edn ?

Anton Shastun 2025-05-07T19:22:13.456459Z

cat /home/moon/.clojure/deps.edn 
{
  :aliases {
    ;; Add cross-project aliases here
  }
}

2025-05-07T19:23:08.700669Z

to start with I have no idea where is the clojure 1.11 coming from

2025-05-07T19:23:46.655649Z

if you just do clj on an empty folder, I have :

clj
Clojure 1.12.0
user=> 

Anton Shastun 2025-05-07T19:24:18.728889Z

but not in my case )

clj
Clojure 1.11.1
user=> 

2025-05-07T19:24:33.768559Z

and what about running just clojure

Anton Shastun 2025-05-07T19:25:10.430219Z

clojure 
Clojure 1.11.1
user=> 

2025-05-07T19:25:15.072069Z

dang

2025-05-07T19:26:23.847349Z

what if you remove your .m2/repository/org/clojure/ folder?

2025-05-07T19:27:07.491099Z

and also your /home/moon/.clojure/.cpcache

2025-05-07T19:27:19.491209Z

just to start from zero

2025-05-07T19:28:09.825459Z

when you run clj, it should go and download clojure 1.12

Anton Shastun 2025-05-07T19:28:31.400769Z

rm -rf ~/.m2/repository/org/clojure/
moon@antelope ~/code/test [env]$ rm -rf ~/.clojure/.cpcache
moon@antelope ~/code/test [env]$ clj
Warning: failed to load the S3TransporterFactory class
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See  for further details.
Downloading: org/clojure/clojure/1.11.1/clojure-1.11.1.pom from central
Warning: failed to load the S3TransporterFactory class
Warning: failed to load the S3TransporterFactory class
Downloading: org/clojure/core.specs.alpha/0.2.62/core.specs.alpha-0.2.62.pom from central
Downloading: org/clojure/spec.alpha/0.3.218/spec.alpha-0.3.218.pom from central
Downloading: org/clojure/pom.contrib/1.1.0/pom.contrib-1.1.0.pom from central
Downloading: org/clojure/pom.contrib/1.1.0/pom.contrib-1.1.0.pom from central
Warning: failed to load the S3TransporterFactory class
Warning: failed to load the S3TransporterFactory class
Warning: failed to load the S3TransporterFactory class
Downloading: org/clojure/clojure/1.11.1/clojure-1.11.1.jar from central
Downloading: org/clojure/spec.alpha/0.3.218/spec.alpha-0.3.218.jar from central
Downloading: org/clojure/core.specs.alpha/0.2.62/core.specs.alpha-0.2.62.jar from central
Clojure 1.11.1
user=> 

Anton Shastun 2025-05-07T19:28:43.874469Z

I'm sorry guys )

2025-05-07T19:29:02.593109Z

haha that is so weird

Anton Shastun 2025-05-07T19:29:10.898409Z

yes crazy )

2025-05-07T19:30:08.935259Z

what about running clj -Strace

2025-05-07T19:30:17.038169Z

it should generate a trace.edn file

2025-05-07T19:31:12.556219Z

dang

2025-05-07T19:31:20.691989Z

and what if you run with the full path /gnu/store/d8c8vlbf3690r0p70qqinkgrfc9d4rqs-clojure-tools-1.12.0.1530/lib/clojure

2025-05-07T19:32:12.223249Z

maybe there is something weird with the PATH resolution

Anton Shastun 2025-05-07T19:33:20.460819Z

ls /gnu/store/d8c8vlbf3690r0p70qqinkgrfc9d4rqs-clojure-tools-1.12.0.1530/lib/clojure
deps.edn  example-deps.edn  libexec/  tools.edn

2025-05-07T19:33:46.576079Z

I mean, what happens is you run that with the full path

Anton Shastun 2025-05-07T19:34:00.930529Z

ls -l /gnu/store/59savh0mi0la9ri97cqck37drxlh9av1-profile/bin/clojure
lrwxrwxrwx 1 root root 81 Jan  1  1970 /gnu/store/59savh0mi0la9ri97cqck37drxlh9av1-profile/bin/clojure -> /gnu/store/d8c8vlbf3690r0p70qqinkgrfc9d4rqs-clojure-tools-1.12.0.1530/bin/clojure
moon@antelope ~/code/test [env]$ /gnu/store/d8c8vlbf3690r0p70qqinkgrfc9d4rqs-clojure-tools-1.12.0.1530/bin/clojure
Clojure 1.11.1
user=> 

2025-05-07T19:36:57.136029Z

can you paste me the contents of that file /gnu/store/d8c8vlbf3690r0p70qqinkgrfc9d4rqs-clojure-tools-1.12.0.1530/bin/clojure

2025-05-07T19:42:19.872289Z

one weird thing is that our scripts are different

Anton Shastun 2025-05-07T19:42:53.921739Z

might be something wrong with the package definition there is no package in guix for latest clojure-tools so i changed abit the definition of existing package

(define clojure-tools
  (package
    (inherit clj:clojure-tools)
    (version "1.12.0.1530")
    (source (origin
              (method url-fetch)
              (uri (string-append ""
				  version
				  ".tar.gz"))
              (sha256 (base32 "0jgd0lki1mml7ppccxnbhj9jbpy5cy3s11775p9kkfi6h654pwhg"))))))

Anton Shastun 2025-05-07T19:43:09.302019Z

just changed version

2025-05-07T19:43:49.241139Z

oh, so that is probably it

2025-05-07T19:44:09.972959Z

but not sure what that inherit does

2025-05-07T19:44:24.037249Z

I never used guix

Anton Shastun 2025-05-07T19:44:29.402119Z

just inherit all properties from old package

2025-05-07T19:44:40.835839Z

and what are those?

2025-05-07T19:46:34.616949Z

because for example, the clojure script I'm using has a line inside that defines the tools classpath :

...
tools_cp="$install_dir/libexec/clojure-tools-$version.jar"
...

2025-05-07T19:46:59.232399Z

and yours has a bunch of jars but no even a reference to clojure-tools

Anton Shastun 2025-05-07T19:52:18.917909Z

if I'm installing via

sudo ./linux-install.sh --prefix /opt/infrastructure/clojure
then I got error
~/code/tools/clojure/bin/clojure 
Error: Could not find or load main class clojure.main
Caused by: java.lang.ClassNotFoundException: clojure.main

Anton Shastun 2025-05-07T19:52:39.930749Z

how I can work around?

2025-05-07T19:55:02.729939Z

but what if you run /opt/infrastructure/clojure/bin/clojure

Anton Shastun 2025-05-07T19:55:23.228319Z

oh sorry

Anton Shastun 2025-05-07T19:55:38.688539Z

sudo ./linux-install.sh --prefix ~/code/tools/clojure

2025-05-07T19:56:32.859239Z

I'm not following, you are installing it to /opt/infrastructure but then running it from some other place

2025-05-07T19:56:45.783639Z

oh ok I see

2025-05-07T19:56:57.937669Z

and what now?

Anton Shastun 2025-05-07T19:57:32.057429Z

moon@antelope ~/code/tools [env]$ clojure/bin/clojure 
Clojure 1.12.0
user=> 

Anton Shastun 2025-05-07T19:57:41.791729Z

but if I change dir

Anton Shastun 2025-05-07T19:58:07.141239Z

moon@antelope ~/code/test [env]$ ~/code/tools/clojure/bin/clojure 
Error: Could not find or load main class clojure.main
Caused by: java.lang.ClassNotFoundException: clojure.main

2025-05-07T19:59:17.314289Z

yeah, that is probably because of the line 5 of the clojure script

2025-05-07T19:59:21.769609Z

which contains a relative path

2025-05-07T19:59:37.564129Z

when you install with prefix

2025-05-07T20:00:03.993999Z

you can change that to an absolute path of ~/code/tools/clojure/

Anton Shastun 2025-05-07T20:00:35.207209Z

Cool! it works now )

Anton Shastun 2025-05-07T20:01:03.526509Z

Thank you a lot for help!!

2025-05-07T20:01:24.435349Z

hey you are welcome. I'm not sure what is going on with the other installation method

Anton Shastun 2025-05-07T20:01:45.885929Z

I'm going to use clj tools form ./linux-install.sh

✅ 1
2025-05-07T20:01:56.528009Z

I've always installed from that linux-install.sh

Anton Shastun 2025-05-07T20:03:44.156529Z

now i can load without any issues )

[ring.adapter.jetty :refer [run-jetty]

Anton Shastun 2025-05-07T20:03:53.885119Z

sorry for taking so much time

p-himik 2025-05-07T20:10:47.493239Z

Huh, it seems that soon comes the time when one of the first questions asked in similar situations should be "are you using guix/nix?". :)

🙏 1
seancorfield 2025-05-07T21:02:47.031749Z

That S3Transporter warning generally indicates you're running tools.deps from a git dep or source, without the Java classes compiled -- which tracks with the weird "bunch of jars" in the script instead of the full uberjar of clojure-tools. I suspect this harks back to these *nix packager folks obsession with trying to build everything from source (and clearly getting something wrong here).

🙏 1