2
votes

I am trying to upload clojure web app with postgresql to google app engine.

but I have a problem with uploading wep app.

and this is tutorial I saw http://flowa.fi/blog/2014/04/25/clojure-gae-howto.html

https://cloud.google.com/solutions/setup-postgres

OS: window7

process I did is like below :

  1. Make war file from my app

  2. extract war file and upload to google app engine

  3. configure postgresql to work well in google app engine referencing https://cloud.google.com/solutions/setup-postgres

  4. upload app to google app engine using

appcfg update .

enter image description here

It is uploaded successfully like above

but when I go to website http://tmxkwkfgka.appspot.com. error happens in this website

Error: Server Error
The server encountered an error and could not complete your request.

Please try again in 30 seconds.

when I upload web to appengine in local using command

dev_appserver .

It work well in local.

google app engine log error message is below:

 W 13:56:18.403
/
java.lang.NullPointerException
    at com.google.appengine.runtime.Request.process-7fd2ef9e4add08a2(Request.java)
    at java.util.Hashtable.put(Hashtable.java:522)
    at java.util.Properties.setProperty(Properties.java:161)
    at org.postgresql.Driver.loadDefaultProperties(Driver.java:121)
    at org.postgresql.Driver.access$000(Driver.java:47)
    at org.postgresql.Driver$1.run(Driver.java:88)
    at java.security.AccessController.doPrivileged(AccessController.java:62)
    at org.postgresql.Driver.getDefaultProperties(Driver.java:85)
    at org.postgresql.Driver.connect(Driver.java:231)
    at java.sql.DriverManager.getConnection(DriverManager.java:571)
    at java.sql.DriverManager.getConnection(DriverManager.java:187)
    at clojure.java.jdbc$get_connection.invoke(jdbc.clj:177)
    at clojure.java.jdbc$with_connection_STAR_.invoke(jdbc.clj:300)
    at picture_gallery.models.db$get_gallery_previews.invoke(db.clj:44)
    at picture_gallery.routes.gallery$show_galleries.invoke(gallery.clj:36)
    at picture_gallery.routes.home$home.invoke(home.clj:9)
    at picture_gallery.routes.home$fn__153.invoke(home.clj:12)
    at compojure.core$make_route$fn__390.invoke(core.clj:94)
    at compojure.core$if_route$fn__378.invoke(core.clj:40)
    at compojure.core$if_method$fn__371.invoke(core.clj:25)
    at compojure.core$routing$fn__396.invoke(core.clj:107)
    at clojure.core$some.invoke(core.clj:2515)
    at compojure.core$routing.doInvoke(core.clj:107)
    at clojure.lang.RestFn.applyTo(RestFn.java:139)
    at clojure.core$apply.invoke(core.clj:626)
    at compojure.core$routes$fn__400.invoke(core.clj:112)
    at compojure.core$routing$fn__396.invoke(core.clj:107)
    at clojure.core$some.invoke(core.clj:2515)
    at compojure.core$routing.doInvoke(core.clj:107)
    at clojure.lang.RestFn.applyTo(RestFn.java:139)
    at clojure.core$apply.invoke(core.clj:626)
    at compojure.core$routes$fn__400.invoke(core.clj:112)
    at noir.util.middleware$wrap_request_map$fn__3756.invoke(middleware.clj:44)
    at ring.middleware.keyword_params$wrap_keyword_params$fn__733.invoke(keyword_params.clj:32)
    at ring.middleware.nested_params$wrap_nested_params$fn__775.invoke(nested_params.clj:70)
    at ring.middleware.params$wrap_params$fn__706.invoke(params.clj:58)
    at hiccup.middleware$wrap_base_url$fn__683.invoke(middleware.clj:12)
    at ring.middleware.multipart_params$wrap_multipart_params$fn__812.invoke(multipart_params.clj:107)
    at noir.util.middleware$wrap_access_rules$fn__3770.invoke(middleware.clj:139)
    at noir.validation$wrap_noir_validation$fn__2891.invoke(validation.clj:135)
    at noir.cookies$noir_cookies$fn__2922.invoke(cookies.clj:66)
    at ring.middleware.cookies$wrap_cookies$fn__1690.invoke(cookies.clj:171)
    at noir.session$noir_flash$fn__2159.invoke(session.clj:141)
    at ring.middleware.flash$wrap_flash$fn__1797.invoke(flash.clj:31)
    at noir.session$noir_session$fn__2149.invoke(session.clj:96)
    at ring.middleware.session$wrap_session$fn__1784.invoke(session.clj:85)
    at picture_gallery.servlet$_service$fn__298.invoke(servlet.clj:1)
    at ring.util.servlet$make_service_method$fn__52.invoke(servlet.clj:126)
    at picture_gallery.servlet$_service.invoke(servlet.clj:1)
    at picture_gallery.servlet.service(Unknown Source)
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
    at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
    at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.Server.handle(Server.java:326)
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
    at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:437)
    at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:444)
    at com.google.tracing.CurrentContext.runInContext(CurrentContext.java:256)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:308)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:300)
    at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:441)
    at java.lang.Thread.run(Thread.java:745)

I think It is related with postgresql db. but I cannot know how to fix it. this is part of code where error happens.

;db.clj 44 line
(defn get-gallery-previews []
  (with-db
    sql/with-query-results
    res
    ["select * from
      (select *, row_number() over (partition by userid) as row_number from images)
      as rows where row_number = 1"]
    (doall res)))

;with-db macro
(defmacro with-db [f & body]
  `(sql/with-connection ~db (~f ~@body)))

(def db
  {:subprotocol "postgresql"
   :subname "//104.196.51.134/gallery"
   :user "postgres"
   :password "dhodua"
   })
1
WHere is postgresql running? To use an outbound socket you need to have billing enabled. Though the error message may not indicate this.Tim Hoffman
I bought vm instance follwing cloud.google.com/solutions/setup-postgres.jijijijiji

1 Answers

0
votes

I'd agree it's likely socket related. You're seeing the NullPointerException once you try to use the null db object after the connection fails, which doesn't throw any errors on its own. You may see details about the connection somewhere else in the logs.

To use sockets, make sure you have billing enabled for your app and that the Daily Budget is not set to zero (it should be automatically unlimited by default):

Quotas
https://cloud.google.com/appengine/docs/quotas?hl=en

Billing settings
https://cloud.google.com/appengine/pricing#billing_settings