首页 \ 问答 \ Clojure NPE主要(Clojure NPE in main)

Clojure NPE主要(Clojure NPE in main)

我在我的clojure hello世界里得到了这个奇怪的NPE

(ns test-app.core
    (:gen-class))

(defn -main [& args]
    ( (println "Hello")) )

注意(println“Hello”)周围的extra()。 这似乎是问题,如果我删除它就好了。

和程序的输出。 请注意,代码实际上打印了“Hello”并且扔了。

Hello
Exception in thread "main" java.lang.NullPointerException
    at test_app.core$_main.doInvoke(core.clj:5)
    at clojure.lang.RestFn.invoke(RestFn.java:397)
    at clojure.lang.Var.invoke(Var.java:411)
    at user$eval5$fn__7.invoke(form-init9064825970813284041.clj:1)
    at user$eval5.invoke(form-init9064825970813284041.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)
[Finished in 4.0s with exit code 1]

我的问题是为什么会发生这种情况?

或者更好:这是一个错误或预期的行为?

我假设这是因为列表的第一个arg应该是一个函数的名称,这里是另一个列表:P。 但在这种情况下,编译器/运行时不应该给出更好的错误吗?

Thx提前。


I'm getting this weird NPE in my clojure hello world

(ns test-app.core
    (:gen-class))

(defn -main [& args]
    ( (println "Hello")) )

Notice the extra () around the (println "Hello"). That seems to be the problem, if i remove that its just fine.

And the output of the program. Notice that the code actually printed "Hello" and the threw.

Hello
Exception in thread "main" java.lang.NullPointerException
    at test_app.core$_main.doInvoke(core.clj:5)
    at clojure.lang.RestFn.invoke(RestFn.java:397)
    at clojure.lang.Var.invoke(Var.java:411)
    at user$eval5$fn__7.invoke(form-init9064825970813284041.clj:1)
    at user$eval5.invoke(form-init9064825970813284041.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)
[Finished in 4.0s with exit code 1]

My question is why is this happening?

Or better: So is this a bug in or is it expected behaviour?

I assume that's because the first arg of a list should be the name of a function, and here its another list :P. but shouldn't the complier/runtime give a nicer error in that case?

Thx in advance.


原文:https://stackoverflow.com/questions/24172983
更新时间:2022-03-19 08:03

相关问答

更多
  • 我正在使用Rails 3.0.3,这是Rails 3和bundler的新功能。 我得到了这个相同的错误: gem 'mygem', :path => '/path/to/gem' 通过指定版本号来解决: gem 'mygem', '0.0.1', :path => '/path/to/gem' 版本使用>=0.0.1恢复为原始错误。 然而,我无法解释这一点。 从Gemfile手册页引用JD的有用的提示:“类似于:git选项的语义,:path选项要求所讨论的目录包含gem的.gemspec,或者指定一个明 ...
  • 我不认为这是一个Rails版本问题,也不是Heroku特有的问题。 (我今天遇到同样的问题,在我的本地开发机器上运行bundle install时,使用Rails 3.0.3。) 如Andrew所说,在本地运行bundle update解决问题。 编辑 :正如在评论中建议:记得要git add . , git commit -m "message" I don't think it's a Rails version problem, nor is it specific to Heroku. (I hit ...
  • 这是由于Bundler最近引入的变化。 我们(Heroku)需要追踪它为什么认为它运行在--dry-run模式并修复它。 与此同时,这不是有害的,不应该引起任何问题。 不幸的是,如果您担心这一点,则无法手动清除缓存。 This is due to a recently-introduced change in Bundler. We (Heroku) need to track down why it thinks it is running in --dry-run mode and fix it. In ...
  • 它很短,但没有。 如果您正在使用Bundler,那么您要规定Gemfile中使用了哪些版本(这些版本又定义了Gemfile.lock中的版本号,两者都应该提交给Git)。 如果您没有使用Bundler,并且仍然在项目的根目录中使用.gems文件,Heroku将使用它最新的文件,除非您定义了不同的版本,在这种情况下它将使用它。 更多信息可以在这里找到: http : //devcenter.heroku.com/articles/gems It short, it doesn't. If you're usi ...
  • (假设您没有依赖项问题)您可以运行软件包更新,或者在Gemfile中,您可以删除版本号或获取所需的特定版本,然后执行软件包更新。 如果你确实需要那些版本,那么我猜你需要在bundle exec加上命令,然后让bundler管理依赖项。 例如bundle exec rspec spec/.. (Assuming that you don't have an dependency issues) You can run a bundle update or In your Gemfile, you can re ...
  • 您跳过了部分安装说明 ,即: 我们需要将Gemfile.lock切换到PostgreSQL。 编辑Gemfile并将ENV['DB'] ||= 'mysql'更改为ENV['DB'] ||= 'postgres' 。 然后运行: bundle --without development test heroku production assets git add Gemfile Gemfile.lock git commit -m "switch Gemfile.lock to pg exclusivly" ...
  • 我联系了Heroku,他们告诉我我有多个buildpack: 感谢您就安装红宝石的问题与我们联系。 似乎该应用程序已将Heroku Buildpack for Ruby指定两次,后者指定主版本而不是发布版本: $ heroku buildpacks -a app-name === app-name Buildpack URLs 1. heroku/ruby 2. https://github.com/heroku/heroku-buildpack-nodejs.git 3. https://github.c ...
  • 确保heroku不是你的Gemfile一部分 - 它不应该在那里。 然后删除./bundler_stubs/heroku : rm -f ./bundler_stubs/heroku ./bundler_stubs/heroku可能是您项目的一部分,并且是由您的同事提交的,存根不应该是项目的一部分。 make sure heroku is not part of your Gemfile - it should not be there. then remove ./bundler_stubs/herok ...
  • Bundler确保Ruby可以找到Gemfile中的所有gem(及其所有依赖项)。 它通过配置加载路径来实现,因此可能需要Gemfile中的所有依赖项。 这是通过以下调用完成的: Bundler.setup ruby LOAD_PATH是文件系统上ruby将查找文件的位置列表,如果你需要的话。 我认为它类似于Linux / Windows操作系统中的PATH变量,但是对于ruby。 要查看此操作,请以root用户身份运行load_path。 我是从我的mac做的 $ sudo ruby -e 'p $LO ...
  • 我解决了这个问题,如下所示! 谢谢你的帮助! gem 'net-ssh', '!= 2.10.0' bundle update I've solved the problem doing as follows! Thank your for your help! gem 'net-ssh', '!= 2.10.0' bundle update

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)