Google App Engine and Spring Boot Data JPA

瀏覽次數:211 次
跳到第一則未讀訊息

Nikita Koroed

未讀,
2018年1月12日 上午9:53:182018/1/12
收件者:Google App Engine
I want to use Spring Boot Data JPA on GAE server and Google Cloud SQL MySql as database.


I get this error on app engine server:

com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create socket factory 'com.google.cloud.sql.mysql.SocketFactory' due to underlying exception: 
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

	at com.google.apphosting.runtime.JavaRuntime$NullSandboxRequestRunnable.run(JavaRuntime.java:806)
	at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:274)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassCastException: com.google.cloud.sql.mysql.SocketFactory cannot be cast to com.mysql.jdbc.SocketFactory
	at com.mysql.jdbc.MysqlIO.createSocketFactory(MysqlIO.java:3325)

full log in attachments.

On local server in SDK environment all work fine.

New dependencies:

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>

<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>6.0.5</version>
</dependency>

<dependency>
<groupId>com.google.cloud.sql</groupId>
<artifactId>mysql-socket-factory-connector-j-6</artifactId>
<version>1.0.4</version>
</dependency>

i put <use-google-connector-j>true</use-google-connector-j> in appengine-web.xml

And created application.yml

spring:
datasource:
url: jdbc:mysql://google/test-db?cloudSqlInstance=test-project:europe-west3:my-test-db&socketFactory=com.google.cloud.sql.mysql.SocketFactory
username: root
password: db-pwd

full app in attachments

what am I doing wrong?



gae.log
springboot-appengine-standard.zip

Les Vogel

未讀,
2018年1月12日 下午1:29:592018/1/12
收件者:Google App Engine、Jisha Abubaker、Kurtis Van Gent、Dane Liergaard
That doesn't look quite right - on GAE Standard, it should be using the injected driver, not the socket factory.  It might also need a user and password in that path.



--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengine+unsubscribe@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/dbe522ae-ce37-4e1e-8e26-65957a51e41b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

  •  
Les Vogel
  •  Cloud Developer Relations
  •  le...@google.com
  •  +1-408-676-7023 

Jisha Abubaker

未讀,
2018年1月12日 下午2:34:002018/1/12
收件者:Les Vogel、Google App Engine、Kurtis Van Gent、Dane Liergaard
If they want to use Spring Data source configuration, it might be best to use the Spring Cloud GCP integration that is available that auto-configures the CloudSQL as a Spring Data source.
回覆所有人
回覆作者
轉寄
0 則新訊息