Can I deploy a Grails 4 app to Google Cloud Platform? - mysql

I have been able to run through the following Grails 3 guide for deploying a Grails application to GCP.
https://guides.grails.org/grails-google-cloud/guide/index.html
I've tried to mirror this using my own Grails 4 application but it fails when I try to access it.
appengineDeploy completes successfully but when I try and access the webapp URL, I get a long stacktrace which culminates in the following error;
Failed to instantiate [org.grails.orm.hibernate.HibernateDatastore]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: com/mysql/cj/api/io/SocketFactory
...
...
Caused by: java.lang.ClassNotFoundException: com.mysql.cj.api.io.SocketFactory
I've been trying all sorts of various versions of the socket factory dependency to try and solve and redeploy but all result in the same error.
I have used various version of the j-6 connector (com.google.cloud.sql:mysql-socket-factory-connector-j-6) and my most recent attempt used the j-8 (1.0.14).
At this point it would be great to even know if what I'm trying is even possible. Java 11 support has been added quite recently and I have made the necessary config adjustments to get my app to deploy, but I cannot then access it.

Upgrading to version 8 of mysql-connector-java in tandem with mysql-socket-factor-connector-j-8 appears to have made this particular issue go away (and moved me to the next).
Dependencies are as follows;
runtime "mysql:mysql-connector-java:8.0.15"
runtime "com.google.cloud.sql:mysql-socket-factory-connector-j-8:1.0.14"

Related

Constructor NotImplementedException?

I am starting and doing testing with PostSharp 6.9.4 Community version, upgrading from 3.0.27 Express. Everything is fine building in VS2017, but when we queue a new build in tfs we get this error:
c:\B1\Net\SEP TR dev Visual Studio 2017\Sources\src\projectName\projectName.csproj : error LA0014: The custom attribute 'Helpers.TimeTraceAspect' constructor threw the exception NotImplementedException: The method cannot be executed at build time.
What does it mean?
Same code works and builds fine in 3.0.27 but not in 6.9.4.
I have not found any information about this error in PostSharp's support page.
Thank you for your help.

JBPM: Add MySQL connector dependency to kie workbench [ver 6.2]

I'm trying to add mysql connector dependency to kie workbench. I added it by uploading the jar to the artifact repository and adding the dependency by going to project settings. When the service task that uses the connector executes, it's not able to load the mysql's Driver class. Here's more detail on how I'm using the service task - Service task using Hibernate
When the service task execute I get this message on the workbench - Unexpected error encountered : [com.sample.bpmn.hello:36 - GetData:3] -- Unable to build entity manager factory
When I look at wildfly's server.log, it seems the jar didn't get added properly - java.lang.ClassNotFoundException: Could not load requested class : com.mysql.jdbc.Driver
When I add the dependency on the workbench, I see the following warnings. I'm not able to figure out what they mean -
Verification of class com.mysql.jdbc.integration.c3p0.MysqlConnectionTester failed and will not be available for authoring. Please check the necessary external dependencies for this project are configured correctly.
Verification of class com.mysql.jdbc.integration.jboss.ExtendedMysqlExceptionSorter failed and will not be available for authoring. Please check the necessary external dependencies for this project are configured correctly.
Verification of class com.mysql.jdbc.integration.jboss.MysqlValidConnectionChecker failed and will not be available for authoring. Please check the necessary external dependencies for this project are configured correctly.
Please let me know if more info is needed.
Much appreciated.
[PS] - I must say that I just got started with hibernate as well with no prior experience. So it could be a basic thing I'm missing there.

Getting 'java.sql.SQLException: com.mysql.jdbc.Driver' with grails run-app (when BuildConfig.groovy doesn't need to be recompiled)

I've upgraded my grails application from 1.3.9 to 2.2.3 and then to 2.3.3. I read the release and upgrade notes for 1.3.9->2.2.3 and then from 2.2.3->2.3.3
I am using OpenJDK 6, Jetty 6 and the plugin jetty 1.1, MySQL 5.5 and I have the connector library under lib
Now my issue is if I run grails clean and then grails run-app the application runs without any problems but if I stop it and run grails run-app again I get a gigantic error (see here: http://pastebin.com/36MpXhir)
I also found that changing something like adding a space somewhere in BuildConfig.groovy (anything that makes it be recompiled) makes the application run normally.
Looking at the stacktrace the first thing that puzzles me is
[02.12.13 16:13:59.919] [main] pool.ConnectionPool Unable to create initial connections of pool.
java.sql.SQLException: com.mysql.jdbc.Driver
at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:254)
at org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:182)
at org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:701)
at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:635)
at org.apache.tomcat.jdbc.pool.ConnectionPool.init(ConnectionPool.java:486)
at org.apache.tomcat.jdbc.pool.ConnectionPool.<init>(ConnectionPool.java:144)
at org.apache.tomcat.jdbc.pool.DataSourceProxy.pCreatePool(DataSourceProxy.java:116)
at org.apache.tomcat.jdbc.pool.DataSourceProxy.createPool(DataSourceProxy.java:103)
at org.apache.tomcat.jdbc.pool.DataSourceProxy.getConnection(DataSourceProxy.java:127)
at org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy.afterPropertiesSet(LazyConnectionDataSourceProxy.java:162)
There are references to org.apache.tomcat even though I'm using jetty (and removed tomcat from BuildConfig.groovy).
Did anyone else encounter such a problem?
Don't put jar files in the lib directory if they're available in a public Maven repo. It's far better to download jars once and keep them in a local cache, and reuse them as needed.
The MySQL driver is used as the commented-out example in the generated BuildConfig.groovy - just un-comment it :) You might want to bump up the version to the latest, e.g.
dependencies {
runtime 'mysql:mysql-connector-java:5.1.27'
}
This is a good site for finding Maven artifacts: http://mvnrepository.com/artifact/mysql/mysql-connector-java
If you do have a jar that's not in a Maven repo (e.g. one with shared code at your company) then you can put it in the lib directory, but it's not auto-discovered. Run grails compile --refresh-dependencies to get it added to the classpath.
For me same error has occurred while running the Grails Application.Then I debug and view the code history of my code which was committed recently.
From that I found the issue that was:
Inside the controller file I send the instance with-out properly
Eg:
**def list=[personInstance.]---> error occurred.**
**render list as JSON**
Then I correct my mistake-->clean the app --> run the app
Now its working fine.

Grails IncompatibleClassChangeError

I deploy a war made with "grails war" to a jetty server.
As far as I can determine, Grails builds with Sun JDK 1.6.0_17-b04 and jetty runs on Sun JDK 1.6.0.16 (both on linux).
2010-08-18 07:33:47.018:WARN::Nested in org.springframework.beans.factory.access.BootstrapException: Error executing bootstraps; nested exception is org.codehaus.groovy.runtime.InvokerInvocationException:
java.lang.IncompatibleClassChangeError: the number of constructors during runtime and compile time for java.lang.ClassLoader do not match. Expected 3 but got 2:
java.lang.IncompatibleClassChangeError: the number of constructors during runtime and compile time for java.lang.ClassLoader do not match. Expected 3 but got 2
at grails.plugin.scopedproxy.AlwaysReloadableSmartClassLoader.<init>(AlwaysReloadableSmartClassLoader.groovy:28)
at grails.plugin.scopedproxy.ScopedProxyUtils.wrapInSmartClassLoader(ScopedProxyUtils.groovy:154)
How can this problem be solved or debugged further?
Run grails clean before you run grails war.
According to another post, Groovy code that uses exceptions that was compiled with a version of Java prior to 7 is not compatible with Java 7.
More information can be found here.
You are probably running into a JAR conflict. Namely your build environment is using one jar, and runtime (Jetty) is using a conflicting jar. This used to often happen with various XML parsing stacks.
Try looking at the Jars used by jetty and compare them to the ones in your project.

Groovy: deploying a war file

I have a groovy application running locally on my desktop.
Apparently it runs error free. At least all unit tests I wrote are fulfilled.
I want to deploy the application using a war file. For this I use the command
grails war
in the home directory of the application. When doing this I am getting the following exception:
Error executing script War: java.lang.NullPointerException
gant.TargetExecutionException: java.lang.NullPointerException
at gant.Gant$_dispatch_closure4.doCall(Gant.groovy:331)
at gant.Gant$_dispatch_closure6.doCall(Gant.groovy:334)
at gant.Gant$_dispatch_closure6.doCall(Gant.groovy)
at gant.Gant.withBuildListeners(Gant.groovy:344)
at gant.Gant.this$2$withBuildListeners(Gant.groovy)
at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
at gant.Gant.dispatch(Gant.groovy:334)
at gant.Gant.this$2$dispatch(Gant.groovy)
at gant.Gant.invokeMethod(Gant.groovy)
at gant.Gant.processTargets(Gant.groovy:495)
at gant.Gant.processTargets(Gant.groovy:480)
Caused by: java.lang.NullPointerException
at _GrailsWar_groovy$_run_closure5_closure25_closure26_closure28.doCall(_GrailsWar_groovy:289)
at _GrailsWar_groovy$_run_closure5_closure25_closure26_closure28.doCall(_GrailsWar_groovy)
at _GrailsWar_groovy$_run_closure5_closure25_closure26.doCall(_GrailsWar_groovy:282)
at _GrailsWar_groovy$_run_closure5_closure25_closure26.doCall(_GrailsWar_groovy)
at _GrailsWar_groovy$_run_closure5_closure25.doCall(_GrailsWar_groovy:258)
at _GrailsWar_groovy$_run_closure5.doCall(_GrailsWar_groovy:256)
at _GrailsWar_groovy$_run_closure4.doCall(_GrailsWar_groovy:239)
at War$_run_closure1.doCall(War.groovy:38)
at gant.Gant$_dispatch_closure4.doCall(Gant.groovy:324)
... 10 more
Any hint why?
Thanks a lot in advance
I think you'll have to find the source of Gant.groovy and see what it's doing on that line. Apparently there is some problem caused by your project's specific configuration (since such a show-stopper bug would have been caught if it always occurred), but the error message does not contain much information.
Alternatively, you could try upgrading Grails to the latest version 1.1.1 if you haven't already.