Advertisement
Guest User

Untitled

a guest
Apr 25th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.27 KB | None | 0 0
  1. Unexpected exception
  2. ProvisionException: Unable to provision, see the following errors:
  3.  
  4. 1) Error injecting constructor, java.lang.NullPointerException
  5. at controllers.SignupCustomerJson.<init>(SignupControllerSupport.scala:61)
  6. while locating controllers.SignupCustomerJson
  7. for the 3rd parameter of controllers.SignupController.<init> (SignupController.scala:29)
  8. while locating controllers.SignupController
  9. for the 4th parameter of router.Routes.<init>(Routes.scala:55)
  10. while locating router.Routes
  11. while locating play.api.inject.RoutesProvider
  12. while locating play.api.routing.Router
  13. for the 1st parameter of play.api.http.JavaCompatibleHttpRequestHandler.<init>(HttpRequestHandler.scala:201)
  14. while locating play.api.http.JavaCompatibleHttpRequestHandler
  15. while locating play.api.http.HttpRequestHandler
  16. for the 5th parameter of play.api.DefaultApplication.<init>(Application.scala:221)
  17. at play.api.DefaultApplication.class(Application.scala:221)
  18. while locating play.api.DefaultApplication
  19. while locating play.api.Application
  20.  
  21. 1 error
  22.  
  23. No source available, here is the exception stack trace:
  24. ->com.google.inject.ProvisionException: Unable to provision, see the following errors:
  25.  
  26. com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1028)
  27. com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1054)
  28. play.api.inject.guice.GuiceInjector.instanceOf(GuiceInjectorBuilder.scala:405)
  29. play.api.inject.guice.GuiceInjector.instanceOf(GuiceInjectorBuilder.scala:400)
  30. play.api.inject.guice.GuiceApplicationBuilder.build(GuiceApplicationBuilder.scala:123)
  31. play.api.inject.guice.GuiceApplicationLoader.load(GuiceApplicationLoader.scala:21)
  32. play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1$$anonfun$2.apply(DevServerStart.scala:168)
  33. play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1$$anonfun$2.apply(DevServerStart.scala:164)
  34. play.utils.Threads$.withContextClassLoader(Threads.scala:21)
  35. play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(DevServerStart.scala:164)
  36. play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(DevServerStart.scala:131)
  37. scala.Option.map(Option.scala:146)
  38. play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1.apply(DevServerStart.scala:131)
  39. play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1.apply(DevServerStart.scala:129)
  40. scala.util.Success.flatMap(Try.scala:230)
  41. play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1.apply(DevServerStart.scala:129)
  42. play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1.apply(DevServerStart.scala:121)
  43. scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24)
  44. scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24)
  45. java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1402)
  46. java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
  47. java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
  48. java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
  49. java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
  50.  
  51. package controllers
  52.  
  53. import javax.inject._
  54. import play.api._
  55. import play.api.mvc._
  56. import views.html._
  57. import play.api.data._
  58. import play.api.data.Forms._
  59. import com.github.j5ik2o.spetstore.domain.model.customer._
  60. import com.github.j5ik2o.spetstore.application.controller.{ ControllerSupport }
  61. import com.github.j5ik2o.spetstore.application.controller.json._
  62. import java.time.LocalDateTime
  63. import util.control.Exception._
  64. import java.sql.Connection
  65. import scalikejdbc._
  66. import scalikejdbc.SQLInterpolation._
  67. import scalikejdbc.config._
  68. import com.mysql.cj.jdbc.Driver
  69. import io.circe.generic.auto._
  70.  
  71. class SignupCustomerJson @Inject() extends Controller
  72. with LoanPattern {
  73.  
  74. // ---------------------------
  75. // Preparing Connection Pool
  76. // ---------------------------
  77.  
  78. // loading jdbc.properties
  79. private val props = new java.util.Properties
  80. props.load(classOf[CustomerJson].getClassLoader.getResourceAsStream("jdbc.properties"))
  81. // loading JDBC driver
  82. val jdbcDriver = props.getProperty("com.mysql.cj.jdbc.Driver")
  83. Class.forName(jdbcDriver)
  84. // preparing the connection pool settings
  85. val poolSettings = new ConnectionPoolSettings(initialSize = 100, maxSize = 100)
  86. // JDBC settings
  87. val url = props.getProperty("jdbc:mysql://127.0.0.1:3306/spetstore?characterEncoding=utf8")
  88. val user = props.getProperty("admin")
  89. val passwordjdbc = props.getProperty("admin")
  90.  
  91. // create singleton(default) connection pool
  92. ConnectionPool.singleton(url, user, passwordjdbc, poolSettings)
  93. // named connection pool
  94. // ConnectionPool.add('spetstore, url, user, passwordjdbc, poolSettings)
  95.  
  96. // ---------------------------
  97. // Working with DBSession
  98. // ---------------------------
  99.  
  100. val tableNamePrefix = "" + System.currentTimeMillis().toString.substring(8)
  101.  
  102. val customer = tableNamePrefix + "_localTx"
  103.  
  104. /** 登録 */
  105. def insert(customerJson: CustomerJson): Unit = {
  106.  
  107. implicit val db = DB(ConnectionPool.borrow())
  108.  
  109. val status = 0
  110.  
  111. try {
  112.  
  113. using(DB(ConnectionPool.borrow())) { db =>
  114.  
  115. db.begin()
  116.  
  117. DB localTx { implicit session =>
  118.  
  119. SQL("""insert into" customer (pk, id, status, name, zipCode1 + zipCode2, prefCode, cityName, addressName, building, email, phone, loginName, password, favoriteCategoryId, version) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)""").update.apply()
  120.  
  121. }
  122.  
  123. db.commit()
  124.  
  125. }
  126.  
  127. } finally { db.rollbackIfActive() }
  128.  
  129. { db.close() }
  130.  
  131. }
  132.  
  133. }
  134.  
  135. package controllers
  136.  
  137. import javax.inject._
  138. import play.api._
  139. import play.api.mvc._
  140. import views.html._
  141. import play.api.data._
  142. import play.api.data.Forms._
  143. import com.github.j5ik2o.spetstore.domain.model.customer._
  144. import com.github.j5ik2o.spetstore.application.controller.{ ControllerSupport }
  145. import com.github.j5ik2o.spetstore.application.controller.json._
  146. import controllers.{ SignupCustomerJson }
  147. import play.api.i18n.{ I18nSupport, MessagesApi }
  148. import play.api.i18n.Messages.Implicits._
  149. import scala.util.Random
  150.  
  151. class SignupController @Inject() (val messagesApi: MessagesApi, val messagesApi2: MessagesApi, val signupCustomerJson: SignupCustomerJson) extends Controller
  152. with play.api.i18n.I18nSupport {
  153.  
  154. val customerForm = Form(
  155. // Userフォームマッピング
  156. mapping(
  157. "id" -> optional(text),
  158. "name" -> nonEmptyText(minLength = 4),
  159. "sexType" -> number,
  160. "zipCode1" -> text(minLength = 3, maxLength = 3),
  161. "zipCode2" -> text(minLength = 4, maxLength = 4),
  162. "prefCode" -> number,
  163. "cityName" -> text,
  164. "addressName" -> text,
  165. "buildingName" -> optional(text),
  166. "email" -> text,
  167. "phone" -> text,
  168. "loginName" -> text,
  169. "password" -> text,
  170. "favoriteCategoryId" -> optional(text),
  171. "version" -> optional(longNumber)
  172.  
  173. )(CustomerJson.apply)(CustomerJson.unapply)
  174. )
  175.  
  176. // 入力ページを表示するAction
  177. def signup = Action {
  178. Ok(views.html.signup(messagesApi.toString, customerForm))
  179. }
  180.  
  181. // 結果ページを表示するAction
  182. def signupresult = Action { implicit request => // リクエストオブジェクトを宣言
  183. customerForm.bindFromRequest().fold(
  184. SignupFailure => { // バインドエラー = 入力エラーが発生した場合
  185. Ok(views.html.signup(messagesApi.toString, SignupFailure)) // 入力画面を再表示します。
  186. },
  187. SignupOK => { // バインド成功 = 入力エラーがない場合
  188. val id = Random.nextInt(1000000).toString
  189. val signupstatus = 0
  190. signupstatus match {
  191. case 0 => insert(SignupOK)
  192. }
  193. Ok(views.html.signupresult(messagesApi2.toString, customerForm.fill(SignupOK))) // 結果画面を表示します。
  194. }
  195. )
  196. }
  197.  
  198. def insert(customerForm: CustomerJson) = signupCustomerJson.insert(CustomerJson(customerForm.id, customerForm.name, customerForm.sexType, customerForm.zipCode1, customerForm.zipCode2, customerForm.prefCode, customerForm.cityName, customerForm.addressName, customerForm.buildingName, customerForm.email, customerForm.phone, customerForm.loginName, customerForm.password, customerForm.favoriteCategoryId, customerForm.version))
  199.  
  200. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement