“帮助亚瑟找到他的受限班级”或“我怎样才能让谷歌应用程序引擎满意”

发布于 2024-11-10 10:28:59 字数 2898 浏览 0 评论 0原文

我在这里的某个地方使用 java.rmi.server.UID ,这让 GAE 感到不安。 在 :only'ing 我对骨头的依赖之后,我陷入了僵局。

(ns helloworld.core
  (:use ;[hiccup.core]
        [hiccup.page-helpers :only (html5 include-css)]
        [clojure.contrib.string :only (split)]
        [compojure.core :only (defroutes GET)]
        [hiccup.middleware :only (wrap-base-url)])
  (:require [appengine-magic.core :as ae]
            [compojure.route :as route
              :only (resources not-found) ]
            [compojure.handler :as handler :only (site)])
  (:gen-class :extends javax.servlet.http.HttpServlet))

 (defn index-page
  ([name]
     (html5
      [:head
       [:title (str "Hello " name)]
       (include-css "/css/style.css")]
      [:body
       [:h1 (str "Hello " name)]]))
  ([] (index-page "World")))

(def match-opperator
  { "add"      +
    "subtract" -
    "multiply" *
    "divide"   /})

(defroutes hello-routes
  (GET "/:f/*" [f & x]
       (index-page (apply (match-opperator f)
                          (map #(Integer/parseInt %)
                               (split #" " (:* x))))))
  (GET "/" [] (index-page))
  (route/resources "/")
  (route/not-found "Page not found"))

(def app
     (-> (handler/site hello-routes)
         (wrap-base-url)))

(ae/def-appengine-app helloworld-app #'app)

我可以把它装到码头上,效果很好, 将其加载到 dev-appserver 后,我得到以下信息:

HTTP ERROR 500

Problem accessing /multiply/1%202%204%208. Reason:

    java.rmi.server.UID is a restricted class. Please see the Google  App Engine developer's guide for more details.

Caused by:

java.lang.NoClassDefFoundError: java.rmi.server.UID is a restricted class. Please see the Google  App Engine developer's guide for more details.
    at com.google.appengine.tools.development.agent.runtime.Runtime.reject(Runtime.java:51)
    at org.apache.commons.fileupload.disk.DiskFileItem.(DiskFileItem.java:103)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:186)
    at ring.middleware.multipart_params$loading__4414__auto__.invoke(multipart_params.clj:1)
    at ring.middleware.multipart_params__init.load(Unknown Source)
    at ring.middleware.multipart_params__init.(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:264)
    at clojure.lang.RT.loadClassForName(RT.java:1578)
    at clojure.lang.RT.load(RT.java:399)
    at clojure.lang.RT.load(RT.java:381)
    at clojure.core$load$fn__4519.invoke(core.clj:4915)

ps:这是我的project.clj,以防万一这有帮助:

(defproject helloworld "1.0.0-SNAPSHOT"
  :description "FIXME: write description"
  :dependencies [[org.clojure/clojure "1.2.1"]
                 [org.clojure/clojure-contrib "1.2.0"]
                 [compojure "0.6.2"]
                 [hiccup "0.3.4"]]

  :dev-dependencies [[appengine-magic "0.4.1"]
                     [swank-clojure "1.2.1"]])

somewhere in here I'm using java.rmi.server.UID which is upsetting GAE.
After :only'ing my dependencies to the bone I'm at an impasse.

(ns helloworld.core
  (:use ;[hiccup.core]
        [hiccup.page-helpers :only (html5 include-css)]
        [clojure.contrib.string :only (split)]
        [compojure.core :only (defroutes GET)]
        [hiccup.middleware :only (wrap-base-url)])
  (:require [appengine-magic.core :as ae]
            [compojure.route :as route
              :only (resources not-found) ]
            [compojure.handler :as handler :only (site)])
  (:gen-class :extends javax.servlet.http.HttpServlet))

 (defn index-page
  ([name]
     (html5
      [:head
       [:title (str "Hello " name)]
       (include-css "/css/style.css")]
      [:body
       [:h1 (str "Hello " name)]]))
  ([] (index-page "World")))

(def match-opperator
  { "add"      +
    "subtract" -
    "multiply" *
    "divide"   /})

(defroutes hello-routes
  (GET "/:f/*" [f & x]
       (index-page (apply (match-opperator f)
                          (map #(Integer/parseInt %)
                               (split #" " (:* x))))))
  (GET "/" [] (index-page))
  (route/resources "/")
  (route/not-found "Page not found"))

(def app
     (-> (handler/site hello-routes)
         (wrap-base-url)))

(ae/def-appengine-app helloworld-app #'app)

I can load it up in jetty and it works fine,
after loading it into the dev-appserver i get this:

HTTP ERROR 500

Problem accessing /multiply/1%202%204%208. Reason:

    java.rmi.server.UID is a restricted class. Please see the Google  App Engine developer's guide for more details.

Caused by:

java.lang.NoClassDefFoundError: java.rmi.server.UID is a restricted class. Please see the Google  App Engine developer's guide for more details.
    at com.google.appengine.tools.development.agent.runtime.Runtime.reject(Runtime.java:51)
    at org.apache.commons.fileupload.disk.DiskFileItem.(DiskFileItem.java:103)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:186)
    at ring.middleware.multipart_params$loading__4414__auto__.invoke(multipart_params.clj:1)
    at ring.middleware.multipart_params__init.load(Unknown Source)
    at ring.middleware.multipart_params__init.(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:264)
    at clojure.lang.RT.loadClassForName(RT.java:1578)
    at clojure.lang.RT.load(RT.java:399)
    at clojure.lang.RT.load(RT.java:381)
    at clojure.core$load$fn__4519.invoke(core.clj:4915)

ps: here is my project.clj incase this helps:

(defproject helloworld "1.0.0-SNAPSHOT"
  :description "FIXME: write description"
  :dependencies [[org.clojure/clojure "1.2.1"]
                 [org.clojure/clojure-contrib "1.2.0"]
                 [compojure "0.6.2"]
                 [hiccup "0.3.4"]]

  :dev-dependencies [[appengine-magic "0.4.1"]
                     [swank-clojure "1.2.1"]])

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

清旖 2024-11-17 10:28:59

FWIW 我认为 :only 不会对 GAE 产生任何影响。它可能会监视您加载的类,并且拒绝引用函数不会阻止其代码被加载。

除了查看堆栈跟踪之外,没有特定于域的经验,我认为导致问题的处理程序可能是 compojure.handler/site,其中包括 wrap-multipart-params 。我怀疑您的应用程序是否需要该功能,因此请看看是否可以使用compojure.handler/api。然后,如果有来自 site您确实需要,请手动将它们包装起来。

再说一遍,考虑到我之前关于加载类的观点,我猜一旦您requirecompojure.handler,multipart-params的代码就会被加载。 code> 命名空间,所以之后你做什么可能并不重要。我想您甚至可能需要手动完成 apisite 的所有包装;这不是很复杂。那么您应该能够避免需要 multipart-params 命名空间。

FWIW I don't think :only will make a bit of difference to GAE. It's probably watching what classes you load, and refusing to refer to a function doesn't stop its code from being loaded.

With no domain-specific experience other than looking at the stacktrace, I think the handler that's causing the issue is probably compojure.handler/site, which includes wrap-multipart-params. I doubt you need that feature for your application, so see if you can make do with compojure.handler/api. Then if there are particular wrappers from site that you do need, wrap them in manually.

Then again, given my earlier point about loading classes, I guess the code for multipart-params is getting loaded as soon as you require the compojure.handler namespace, so what you do after that might not matter. I suppose you might even have to just do all the wrapping from api and site manually; it's not very complicated. Then you should be able to avoid ever requireing the multipart-params namespace.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文